Class SAPBroadphase

Sweep and prune broadphase along one axis.

Hierarchy (view full)

Constructors

Properties

axisIndex: 0 | 1 | 2

Axis to sort the bodies along. Set to 0 for x axis, and 1 for y axis. For best performance, pick the axis where bodies are most distributed.

axisList: Body[]

List of bodies currently in the broadphase.

dirty: boolean

Set to true if the objects in the world moved.

useBoundingBoxes: boolean

If set to true, the broadphase uses bounding boxes for intersection tests, else it uses bounding spheres.

world: World

The world to search in.

Methods

  • Returns all the bodies within an AABB.

    Parameters

    • world: World
    • aabb: AABB
    • Optional result: Body[]

      An array to store resulting bodies in.

    Returns Body[]

  • Computes the variance of the body positions and estimates the best axis to use. Will automatically set property axisIndex.

    Returns void

  • Check if the bounding spheres of two bodies are intersecting.

    Parameters

    • bodyA: Body
    • bodyB: Body
    • pairs1: Body[]

      bodyA is appended to this array if intersection

    • pairs2: Body[]

      bodyB is appended to this array if intersection

    Returns void

  • Check if the bounding volumes of two bodies intersect.

    Parameters

    Returns void

  • Removes duplicate pairs from the pair arrays.

    Parameters

    Returns void

  • Returns void

  • Check if the bounding spheres of two bodies overlap.

    Parameters

    Returns boolean

  • Check if the bounds of two bodies overlap, along the given SAP axis.

    Parameters

    Returns boolean

  • insertionSortX

    Parameters

    Returns Body[]

  • insertionSortY

    Parameters

    Returns Body[]

  • insertionSortZ

    Parameters

    Returns Body[]