SAPBroadphase Class
Sweep and prune broadphase along one axis.
Constructor
Item Index
Methods
Properties
Methods
aabbQuery
-
world
-
aabb
-
result
Returns all the bodies within an AABB.
Returns:
autoDetectAxis
()
Computes the variance of the body positions and estimates the best axis to use. Will automatically set property .axisIndex.
boundingSphereCheck
-
bodyA
-
bodyB
Check if the bounding spheres of two bodies overlap.
Returns:
checkBounds
-
bi
-
bj
-
axisIndex
Check if the bounds of two bodies overlap, along the given SAP axis.
Returns:
collisionPairs
-
world
-
p1
-
p2
Collect all collision pairs
Parameters:
-
world
World -
p1
Array -
p2
Array
doBoundingBoxBroadphase
-
bodyA
-
bodyB
-
pairs1
-
pairs2
Check if the bounding boxes of two bodies are intersecting.
doBoundingSphereBroadphase
-
bodyA
-
bodyB
-
pairs1
-
pairs2
Check if the bounding spheres of two bodies are intersecting.
insertionSortX
-
a
Parameters:
-
a
Array
Returns:
insertionSortY
-
a
Parameters:
-
a
Array
Returns:
insertionSortZ
-
a
Parameters:
-
a
Array
Returns:
intersectionTest
-
bodyA
-
bodyB
-
pairs1
-
pairs2
Check if the bounding volumes of two bodies intersect.
makePairsUnique
-
pairs1
-
pairs2
Removes duplicate pairs from the pair arrays.
Parameters:
-
pairs1
Array -
pairs2
Array
needBroadphaseCollision
-
bodyA
-
bodyB
Check if a body pair needs to be intersection tested at all.
Returns:
Properties
axisIndex
Number
Axis to sort the bodies along. Set to 0 for x axis, and 1 for y axis. For best performance, choose an axis that the bodies are spread out more on.
axisList
Array
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 test, else it uses bounding spheres.