Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SAPBroadphase

Sweep and prune broadphase along one axis.

Hierarchy

Index

Constructors

constructor

Properties

axisIndex

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

axisList: Body[]

List of bodies currently in the broadphase.

dirty

dirty: boolean

Set to true if the objects in the world moved.

useBoundingBoxes

useBoundingBoxes: boolean

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

world

world: null | World

The world to search in.

Methods

aabbQuery

autoDetectAxis

  • autoDetectAxis(): void
  • Computes the variance of the body positions and estimates the best axis to use. Will automatically set property axisIndex.

    Returns void

collisionPairs

doBoundingBoxBroadphase

  • doBoundingBoxBroadphase(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void

doBoundingSphereBroadphase

  • doBoundingSphereBroadphase(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void

intersectionTest

  • intersectionTest(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void

makePairsUnique

  • makePairsUnique(pairs1: Body[], pairs2: Body[]): void

needBroadphaseCollision

  • needBroadphaseCollision(bodyA: Body, bodyB: Body): boolean

setWorld

  • setWorld(world: World): void

Static boundingSphereCheck

  • boundingSphereCheck(bodyA: Body, bodyB: Body): boolean

Static checkBounds

  • checkBounds(bi: Body, bj: Body, axisIndex: 0 | 1 | 2): boolean

Static insertionSortX

Static insertionSortY

Static insertionSortZ