Interface for objects tracking overlap of many AABBs.

interface IBroadPhase {
    CreateProxy(aabb: b2AABB, userData: any): b2DynamicTreeNode;
    DestroyProxy(proxy: b2DynamicTreeNode): void;
    GetFatAABB(proxy: b2DynamicTreeNode): b2AABB;
    GetProxyCount(): number;
    GetUserData(proxy: b2DynamicTreeNode): any;
    MoveProxy(
        proxy: b2DynamicTreeNode,
        aabb: b2AABB,
        displacement: b2Vec2,
    ): void;
    Query(callback: (proxy: b2DynamicTreeNode) => boolean, aabb: b2AABB): void;
    RayCast(
        callback: (input: b2RayCastInput, proxy: b2DynamicTreeNode) => number,
        input: b2RayCastInput,
    ): void;
    Rebalance(iterations: number): void;
}

Implemented by

Methods

  • Query an AABB for overlapping proxies. The callback is called for each proxy that overlaps the supplied AABB. The callback should match function signature fuction callback(proxy:b2DynamicTreeNode):Boolean and should return false to trigger premature termination.

    Parameters

    • callback: (proxy: b2DynamicTreeNode) => boolean

      Called for each proxy that overlaps the supplied AABB. param proxy Proxy overlapping the supplied AABB.

    • aabb: b2AABB

      Proxies are query for overlap on this AABB.

    Returns void

  • 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: (input: b2RayCastInput, proxy: b2DynamicTreeNode) => number

      Called for each proxy that is hit by the ray. param input Ray cast input data. param proxy The proxy hit by the ray cast. param return Return value is the new value for maxFraction.

    • input: b2RayCastInput

      Ray cast input data. Query all proxies along this ray cast.

    Returns void

  • Perform some iterations to re-balance the tree.

    Parameters

    • iterations: number

      Number of rebalance iterations to perform.

    Returns void