Package org.jbox2d.collision.broadphase
Interface BroadPhase
- All Known Implementing Classes:
DefaultBroadPhaseBuffer
public interface 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.
Collision processing in a physics step can be divided into narrow-phase and broad-phase. In the narrow-phase we compute contact points between pairs of shapes. Imagine we have N shapes. Using brute force, we would need to perform the narrow-phase for N*N/2 pairs.
The b2BroadPhase class reduces this load by using a dynamic tree for pair management. This greatly reduces the number of narrow-phase calls.
Normally you do not interact with the broad-phase directly. Instead, Box2D creates and manages a broad-phase internally. Also, b2BroadPhase is designed with Box2D's simulation loop in mind, so it is likely not suited for other use cases.
https://box2d.org/documentation/md__d_1__git_hub_box2d_docs_collision.html- Author:
- Daniel Murphy
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionintcreateProxy(AABB aabb, Object userData) Create a proxy with an initial AABB.voiddestroyProxy(int proxyId) Destroy a proxy.voidgetFatAABB(int proxyId) intGet the number of proxies.intintGet the height of the embedded tree.floatgetUserData(int proxyId) voidCall MoveProxy as many times as you like, then when you are done call UpdatePairs to finalize the proxy pairs (for your time step).voidquery(TreeCallback callback, AABB aabb) Query an AABB for overlapping proxies.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.voidupdatePairs(PairCallback callback) Update the pairs.
-
Field Details
-
NULL_PROXY
static final int NULL_PROXY- See Also:
-
-
Method Details
-
createProxy
Create a proxy with an initial AABB. Pairs are not reported until updatePairs is called. -
destroyProxy
void destroyProxy(int proxyId) Destroy a proxy. It is up to the client to remove any pairs. -
moveProxy
Call MoveProxy as many times as you like, then when you are done call UpdatePairs to finalize the proxy pairs (for your time step). -
touchProxy
void touchProxy(int proxyId) Call to trigger a re-processing of its pairs on the next call to UpdatePairs. -
getUserData
-
getFatAABB
-
testOverlap
boolean testOverlap(int proxyIdA, int proxyIdB) -
getProxyCount
int getProxyCount()Get the number of proxies. -
drawTree
-
updatePairs
Update the pairs. This results in pair callbacks. This can only add pairs. -
query
Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB. -
raycast
Ray-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.- Parameters:
input- The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).callback- A callback class that is called for each proxy that is hit by the ray.
-
getTreeHeight
int getTreeHeight()Get the height of the embedded tree. -
getTreeBalance
int getTreeBalance() -
getTreeQuality
float getTreeQuality()
-