his broad phase uses the Sweep and Prune algorithm as described in:
ollision Detection in Interactive 3D Environments by Gino van den Bergen
lso, some ideas, such as using integral values for fast compares comes from
ullet (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.
b2internal var m_bounds:Array
b2internal var m_pairManager:b2PairManager
b2internal var m_proxyCount:int
b2internal var m_proxyPool:Array
b2internal var m_quantizationFactor:b2Vec2
b2internal var m_worldAABB:b2AABB
public static var s_validate:Boolean = false
public function b2BroadPhase(worldAABB:b2AABB, callback:b2PairCallback)
Parameters
public static function BinarySearch(bounds:Array, count:int, value:uint):uint
Parameters
| bounds:Array |
|
| count:int |
|
| value:uint |
Returns
public function Commit():void
public function CreateProxy(aabb:b2AABB, userData:*):uint
Create and destroy proxies. These call Flush first.
Parameters
Returns
public function DestroyProxy(proxyId:uint):void
Parameters
public function GetProxy(proxyId:int):b2Proxy
Get a single proxy. Returns NULL if the id is invalid.
Parameters
Returns
public function InRange(aabb:b2AABB):Boolean
Use this to see if your proxy is in range. If it is not in range,
it should be destroyed. Otherwise you may get O(m^2) pairs, where m
is the number of proxies that are out of range.
Parameters
Returns
public function MoveProxy(proxyId:uint, aabb:b2AABB):void
Call MoveProxy as many times as you like, then when you are done
call Commit to finalized the proxy pairs (for your time step).
Parameters
public function QueryAABB(aabb:b2AABB, userData:int, maxCount:*):int
Query an AABB for overlapping proxies, returns the user data and
the count, up to the supplied maximum count.
Parameters
| aabb:b2AABB |
|
| userData:int |
|
| maxCount:* |
Returns
public function TestOverlap(b:b2BoundValues, p:b2Proxy):Boolean
Parameters
Returns
public function Validate():void
public static const b2_invalid:uint = 0x0000ffff
public static const b2_nullEdge:uint = 0x0000ffff