Class DefaultBroadPhaseBuffer

java.lang.Object
org.jbox2d.collision.broadphase.DefaultBroadPhaseBuffer
All Implemented Interfaces:
TreeCallback, BroadPhase

public class DefaultBroadPhaseBuffer extends Object implements 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
  • Constructor Details

  • Method Details

    • createProxy

      public final int createProxy(AABB aabb, Object userData)
      Description copied from interface: BroadPhase
      Create a proxy with an initial AABB. Pairs are not reported until updatePairs is called.
      Specified by:
      createProxy in interface BroadPhase
    • destroyProxy

      public final void destroyProxy(int proxyId)
      Description copied from interface: BroadPhase
      Destroy a proxy. It is up to the client to remove any pairs.
      Specified by:
      destroyProxy in interface BroadPhase
    • moveProxy

      public final void moveProxy(int proxyId, AABB aabb, Vec2 displacement)
      Description copied from interface: BroadPhase
      Call 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:
      moveProxy in interface BroadPhase
    • touchProxy

      public void touchProxy(int proxyId)
      Description copied from interface: BroadPhase
      Call to trigger a re-processing of its pairs on the next call to UpdatePairs.
      Specified by:
      touchProxy in interface BroadPhase
    • getUserData

      public Object getUserData(int proxyId)
      Specified by:
      getUserData in interface BroadPhase
    • getFatAABB

      public AABB getFatAABB(int proxyId)
      Specified by:
      getFatAABB in interface BroadPhase
    • testOverlap

      public boolean testOverlap(int proxyIdA, int proxyIdB)
      Specified by:
      testOverlap in interface BroadPhase
    • getProxyCount

      public final int getProxyCount()
      Description copied from interface: BroadPhase
      Get the number of proxies.
      Specified by:
      getProxyCount in interface BroadPhase
    • drawTree

      public void drawTree(DebugDraw argDraw)
      Specified by:
      drawTree in interface BroadPhase
    • updatePairs

      public final void updatePairs(PairCallback callback)
      Description copied from interface: BroadPhase
      Update the pairs. This results in pair callbacks. This can only add pairs.
      Specified by:
      updatePairs in interface BroadPhase
    • query

      public final void query(TreeCallback callback, AABB aabb)
      Description copied from interface: BroadPhase
      Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.
      Specified by:
      query in interface BroadPhase
    • raycast

      public final void raycast(TreeRayCastCallback callback, RayCastInput input)
      Description copied from interface: BroadPhase
      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.
      Specified by:
      raycast in interface BroadPhase
      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: BroadPhase
      Get the height of the embedded tree.
      Specified by:
      getTreeHeight in interface BroadPhase
    • getTreeBalance

      public int getTreeBalance()
      Specified by:
      getTreeBalance in interface BroadPhase
    • getTreeQuality

      public float getTreeQuality()
      Specified by:
      getTreeQuality in interface BroadPhase
    • 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:
      treeCallback in interface TreeCallback
      Parameters:
      proxyId - The id of the proxy.
      Returns:
      if the query should be continued.