# Class BroadPhase

java.lang.Object
com.codename1.gaming.physics.box2d.collision.broadphase.BroadPhase

All Implemented Interfaces:
  `TreeCallback`

public class BroadPhase extends Object implements TreeCallback
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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `NULL_PROXY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BroadPhase(BroadPhaseStrategy strategy)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected final void`
  `bufferMove(int proxyId)`
  `final int`
  `createProxy(AABB aabb, Object userData)`
  Create a proxy with an initial AABB.
  `final void`
  `destroyProxy(int proxyId)`
  Destroy a proxy.
  `void`
  `drawTree(DebugDraw argDraw)`
  `AABB`
  `getFatAABB(int proxyId)`
  `final int`
  `getProxyCount()`
  Get the number of proxies.
  `int`
  `getTreeBalance()`
  `final int`
  `getTreeHeight()`
  Get the height of the embedded tree.
  `float`
  `getTreeQuality()`
  `Object`
  `getUserData(int proxyId)`
  `final void`
  `moveProxy(int proxyId, AABB aabb, Vec2 displacement)`
  Call MoveProxy as many times as you like, then when you are done call UpdatePairs to finalized the proxy pairs (for your time step).
  `final void`
  `query(TreeCallback callback, AABB aabb)`
  Query an AABB for overlapping proxies.
  `final void`
  `raycast(TreeRayCastCallback callback, RayCastInput input)`
  Ray-cast against the proxies in the tree.
  `boolean`
  `testOverlap(int proxyIdA, int proxyIdB)`
  `void`
  `touchProxy(int proxyId)`
  `final boolean`
  `treeCallback(int proxyId)`
  This is called from DynamicTree::query when we are gathering pairs.
  `protected final void`
  `unbufferMove(int proxyId)`
  `final void`
  `updatePairs(PairCallback callback)`
  Update the pairs.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### NULL_PROXY

    public static final int NULL_PROXY
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### BroadPhase

    public BroadPhase(BroadPhaseStrategy strategy)

- ## Method Details

  - ### createProxy

    public final int createProxy(AABB aabb, Object userData)
    Create a proxy with an initial AABB. Pairs are not reported until updatePairs is called.
    Parameters:
      `aabb` -
      `userData` -
    Returns:

  - ### destroyProxy

    public final void destroyProxy(int proxyId)
    Destroy a proxy. It is up to the client to remove any pairs.
    Parameters:
      `proxyId` -

  - ### moveProxy

    public final void moveProxy(int proxyId, AABB aabb, Vec2 displacement)
    Call MoveProxy as many times as you like, then when you are done call UpdatePairs to finalized the proxy pairs (for your time step).

  - ### touchProxy

    public void touchProxy(int proxyId)

  - ### getUserData

    public Object getUserData(int proxyId)

  - ### getFatAABB

    public AABB getFatAABB(int proxyId)

  - ### testOverlap

    public boolean testOverlap(int proxyIdA, int proxyIdB)

  - ### getProxyCount

    public final int getProxyCount()
    Get the number of proxies.
    Returns:

  - ### drawTree

    public void drawTree(DebugDraw argDraw)

  - ### updatePairs

    public final void updatePairs(PairCallback callback)
    Update the pairs. This results in pair callbacks. This can only add pairs.
    Parameters:
      `callback` -

  - ### query

    public final 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.
    Parameters:
      `callback` -
      `aabb` -

  - ### raycast

    public final void raycast(TreeRayCastCallback callback, RayCastInput input)
    Ray-cast against the proxies in the tree. This relies on the callback to perform a exact ray-cast in the case were the proxy contains a shape. The callback also performs the 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:
      `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()
    Get the height of the embedded tree.
    Returns:

  - ### getTreeBalance

    public int getTreeBalance()

  - ### getTreeQuality

    public float getTreeQuality()

  - ### 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