PackageBox2D.Collision
Classpublic class b2BroadPhase

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.



Public Properties
 PropertyDefined by
  s_validate : Boolean = false
[static]
b2BroadPhase
Public Methods
 MethodDefined by
  
b2BroadPhase(worldAABB:b2AABB, callback:b2PairCallback)
b2BroadPhase
  
BinarySearch(bounds:Array, count:int, value:uint):uint
[static]
b2BroadPhase
  
Commit():void
b2BroadPhase
  
CreateProxy(aabb:b2AABB, userData:*):uint
Create and destroy proxies.
b2BroadPhase
  
DestroyProxy(proxyId:uint):void
b2BroadPhase
  
GetProxy(proxyId:int):b2Proxy
Get a single proxy.
b2BroadPhase
  
InRange(aabb:b2AABB):Boolean
Use this to see if your proxy is in range.
b2BroadPhase
  
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).
b2BroadPhase
  
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.
b2BroadPhase
  
b2BroadPhase
  
Validate():void
b2BroadPhase
Public Constants
 ConstantDefined by
  b2_invalid : uint = 0x0000ffff
[static]
b2BroadPhase
  b2_nullEdge : uint = 0x0000ffff
[static]
b2BroadPhase
Property detail
m_boundsproperty
b2internal var m_bounds:Array
m_pairManagerproperty 
b2internal var m_pairManager:b2PairManager
m_proxyCountproperty 
b2internal var m_proxyCount:int
m_proxyPoolproperty 
b2internal var m_proxyPool:Array
m_quantizationFactorproperty 
b2internal var m_quantizationFactor:b2Vec2
m_worldAABBproperty 
b2internal var m_worldAABB:b2AABB
s_validateproperty 
public static var s_validate:Boolean = false
Constructor detail
b2BroadPhase()constructor
public function b2BroadPhase(worldAABB:b2AABB, callback:b2PairCallback)Parameters
worldAABB:b2AABB
 
callback:b2PairCallback
Method detail
BinarySearch()method
public static function BinarySearch(bounds:Array, count:int, value:uint):uintParameters
bounds:Array
 
count:int
 
value:uint

Returns
uint
Commit()method 
public function Commit():void
CreateProxy()method 
public function CreateProxy(aabb:b2AABB, userData:*):uint

Create and destroy proxies. These call Flush first.

Parameters
aabb:b2AABB
 
userData:*

Returns
uint
DestroyProxy()method 
public function DestroyProxy(proxyId:uint):voidParameters
proxyId:uint
GetProxy()method 
public function GetProxy(proxyId:int):b2Proxy

Get a single proxy. Returns NULL if the id is invalid.

Parameters
proxyId:int

Returns
b2Proxy
InRange()method 
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
aabb:b2AABB

Returns
Boolean
MoveProxy()method 
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
proxyId:uint
 
aabb:b2AABB
QueryAABB()method 
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
int
TestOverlap()method 
public function TestOverlap(b:b2BoundValues, p:b2Proxy):BooleanParameters
b:b2BoundValues
 
p:b2Proxy

Returns
Boolean
Validate()method 
public function Validate():void
Constant detail
b2_invalidconstant
public static const b2_invalid:uint = 0x0000ffff
b2_nullEdgeconstant 
public static const b2_nullEdge:uint = 0x0000ffff