Package org.jbox2d.collision.broadphase
Class DefaultBroadPhaseBuffer
java.lang.Object
org.jbox2d.collision.broadphase.DefaultBroadPhaseBuffer
- All Implemented Interfaces:
TreeCallback,BroadPhase
The broad-phase is used for computing pairs and performing volume queries and
ray casts. This broad-phase does not persist pairs. Instead, this reports
potentially new pairs. It is up to the client to consume the new pairs and to
track subsequent overlap.
- Author:
- Daniel Murphy
-
Field Summary
Fields inherited from interface org.jbox2d.collision.broadphase.BroadPhase
NULL_PROXY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidbufferMove(int proxyId) final intcreateProxy(AABB aabb, Object userData) Create a proxy with an initial AABB.final voiddestroyProxy(int proxyId) Destroy a proxy.voidgetFatAABB(int proxyId) final intGet the number of proxies.intfinal intGet the height of the embedded tree.floatgetUserData(int proxyId) final voidCall MoveProxy as many times as you like, then when you are done call UpdatePairs to finalize the proxy pairs (for your time step).final voidquery(TreeCallback callback, AABB aabb) Query an AABB for overlapping proxies.final voidraycast(TreeRayCastCallback callback, RayCastInput input) Ray-cast against the proxies in the tree.booleantestOverlap(int proxyIdA, int proxyIdB) voidtouchProxy(int proxyId) Call to trigger a re-processing of its pairs on the next call to UpdatePairs.final booleantreeCallback(int proxyId) This is called from DynamicTree::query when we are gathering pairs.protected final voidunbufferMove(int proxyId) final voidupdatePairs(PairCallback callback) Update the pairs.
-
Constructor Details
-
DefaultBroadPhaseBuffer
-
-
Method Details
-
createProxy
Description copied from interface:BroadPhaseCreate a proxy with an initial AABB. Pairs are not reported until updatePairs is called.- Specified by:
createProxyin interfaceBroadPhase
-
destroyProxy
public final void destroyProxy(int proxyId) Description copied from interface:BroadPhaseDestroy a proxy. It is up to the client to remove any pairs.- Specified by:
destroyProxyin interfaceBroadPhase
-
moveProxy
Description copied from interface:BroadPhaseCall MoveProxy as many times as you like, then when you are done call UpdatePairs to finalize the proxy pairs (for your time step).- Specified by:
moveProxyin interfaceBroadPhase
-
touchProxy
public void touchProxy(int proxyId) Description copied from interface:BroadPhaseCall to trigger a re-processing of its pairs on the next call to UpdatePairs.- Specified by:
touchProxyin interfaceBroadPhase
-
getUserData
- Specified by:
getUserDatain interfaceBroadPhase
-
getFatAABB
- Specified by:
getFatAABBin interfaceBroadPhase
-
testOverlap
public boolean testOverlap(int proxyIdA, int proxyIdB) - Specified by:
testOverlapin interfaceBroadPhase
-
getProxyCount
public final int getProxyCount()Description copied from interface:BroadPhaseGet the number of proxies.- Specified by:
getProxyCountin interfaceBroadPhase
-
drawTree
- Specified by:
drawTreein interfaceBroadPhase
-
updatePairs
Description copied from interface:BroadPhaseUpdate the pairs. This results in pair callbacks. This can only add pairs.- Specified by:
updatePairsin interfaceBroadPhase
-
query
Description copied from interface:BroadPhaseQuery an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.- Specified by:
queryin interfaceBroadPhase
-
raycast
Description copied from interface:BroadPhaseRay-cast against the proxies in the tree. This relies on the callback to perform an exact ray-cast in the case were the proxy contains a shape. The callback also performs any collision filtering. This has performance roughly equal to k * log(n), where k is the number of collisions and n is the number of proxies in the tree.- Specified by:
raycastin interfaceBroadPhase- Parameters:
callback- A callback class that is called for each proxy that is hit by the ray.input- The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
-
getTreeHeight
public final int getTreeHeight()Description copied from interface:BroadPhaseGet the height of the embedded tree.- Specified by:
getTreeHeightin interfaceBroadPhase
-
getTreeBalance
public int getTreeBalance()- Specified by:
getTreeBalancein interfaceBroadPhase
-
getTreeQuality
public float getTreeQuality()- Specified by:
getTreeQualityin interfaceBroadPhase
-
bufferMove
protected final void bufferMove(int proxyId) -
unbufferMove
protected final void unbufferMove(int proxyId) -
treeCallback
public final boolean treeCallback(int proxyId) This is called from DynamicTree::query when we are gathering pairs.- Specified by:
treeCallbackin interfaceTreeCallback- Parameters:
proxyId- The id of the proxy.- Returns:
- if the query should be continued.
-