org.jbox2d.collision
Class BroadPhase

java.lang.Object
  extended by org.jbox2d.collision.BroadPhase

public class BroadPhase
extends Object

This broad phase uses the Sweep and Prune algorithm as described in: Collision Detection in Interactive 3D Environments by Gino van den Bergen Also, some ideas, such as using integral values for fast compares comes from Bullet (http:/www.bulletphysics.com).

Notes:
- we use bound arrays instead of linked lists for cache coherence.
- we use quantized integral values for fast compares.
- we use short indices rather than pointers to save memory.
- we use a stabbing count for fast overlap queries (less than order N).
- we also use a time stamp on each proxy to speed up the registration of overlap query results.
- where possible, we compare bound indices instead of values to reduce cache misses (TODO_ERIN).
- no broadphase is perfect and neither is this one: it is not great for huge worlds (use a multi-SAP instead), it is not great for large objects.


Field Summary
static int INVALID
           
 Bound[][] m_bounds
           
 PairManager m_pairManager
           
 int m_proxyCount
           
 Proxy[] m_proxyPool
           
 Vec2 m_quantizationFactor
           
 AABB m_worldAABB
           
static int NULL_EDGE
           
static boolean s_validate
           
 
Constructor Summary
BroadPhase(AABB worldAABB, PairCallback callback)
           
 
Method Summary
 void commit()
           
 int createProxy(AABB aabb, Object userData)
          internal
 void destroyProxy(int proxyId)
           
 Proxy getProxy(int proxyId)
           
 boolean inRange(AABB aabb)
           
 void moveProxy(int proxyId, AABB aabb)
          internal
 Object[] query(AABB aabb, int maxCount)
          Query an AABB for overlapping proxies, returns the user data and the count, up to the supplied maximum count.
protected  boolean testOverlap(Proxy p1, Proxy p2)
           
 void validate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID

public static final int INVALID
See Also:
Constant Field Values

NULL_EDGE

public static final int NULL_EDGE
See Also:
Constant Field Values

m_pairManager

public PairManager m_pairManager

m_proxyPool

public Proxy[] m_proxyPool

m_bounds

public Bound[][] m_bounds

m_worldAABB

public AABB m_worldAABB

m_quantizationFactor

public Vec2 m_quantizationFactor

m_proxyCount

public int m_proxyCount

s_validate

public static final boolean s_validate
See Also:
Constant Field Values
Constructor Detail

BroadPhase

public BroadPhase(AABB worldAABB,
                  PairCallback callback)
Method Detail

testOverlap

protected boolean testOverlap(Proxy p1,
                              Proxy p2)

getProxy

public Proxy getProxy(int proxyId)

createProxy

public int createProxy(AABB aabb,
                       Object userData)
internal


destroyProxy

public void destroyProxy(int proxyId)

moveProxy

public void moveProxy(int proxyId,
                      AABB aabb)
internal


commit

public void commit()

query

public Object[] query(AABB aabb,
                      int maxCount)
Query an AABB for overlapping proxies, returns the user data and the count, up to the supplied maximum count.


validate

public void validate()

inRange

public boolean inRange(AABB aabb)