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 Details

  • Method Details

    • createProxy

      int createProxy(AABB aabb, Object userData)
      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

      void moveProxy(int proxyId, AABB aabb, Vec2 displacement)
      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

      Object getUserData(int proxyId)
    • getFatAABB

      AABB getFatAABB(int proxyId)
    • testOverlap

      boolean testOverlap(int proxyIdA, int proxyIdB)
    • getProxyCount

      int getProxyCount()
      Get the number of proxies.
    • drawTree

      void drawTree(DebugDraw argDraw)
    • updatePairs

      void updatePairs(PairCallback callback)
      Update the pairs. This results in pair callbacks. This can only add pairs.
    • query

      void query(TreeCallback callback, AABB aabb)
      Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.
    • raycast

      void raycast(TreeRayCastCallback callback, RayCastInput input)
      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()