Class: AABBTree
physics/aabb/aabbTree.AABBTree
Represents a tree data structure which contains nodes that store AABBs.
This tree is used to speed up the physics engine's broadphase.
see
Physics Broadphase - AABB Tree
Constructors
constructor
โข new AABBTree()
Properties
insertionsLastUpdate
โข insertionsLastUpdate: number
= 0
The number of nodes which had to be reinserted in the last tree update.
Defined in
src/physics/aabb/aabbTree.ts:31
leafMarginMax
โข leafMarginMax: number
= 10
Defined in
src/physics/aabb/aabbTree.ts:24
leafMarginMin
โข leafMarginMin: number
= 0.02
Defined in
src/physics/aabb/aabbTree.ts:23
leafMarginScale
โข leafMarginScale: number
= 0.2
Defined in
src/physics/aabb/aabbTree.ts:21
leafMarginSlop
โข leafMarginSlop: number
= 0.05
Defined in
src/physics/aabb/aabbTree.ts:22
margin
โข margin: number
= 0.1
Defined in
src/physics/aabb/aabbTree.ts:19
pairs
โข pairs: CollisionPair
[]
Defined in
src/physics/aabb/aabbTree.ts:26
root
โข root: AABBNode
Defined in
src/physics/aabb/aabbTree.ts:18
Methods
add
โธ add(aabb
): void
Inserts an aabb into the tree.
Parameters
Name | Type | Description |
---|---|---|
aabb | AABB | The AABB to insert |
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:245
addNode
โธ Private
addNode(node
, parent
): void
Inserts a node into the tree.
Parameters
Name | Type | Description |
---|---|---|
node | AABBNode | The AABBNode to insert |
parent | AABBNode | - |
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:285
clearChildrenCrossedFlag
โธ Private
clearChildrenCrossedFlag(): void
Sets the childrenCrossed
flag to false on all nodes in the tree.
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:126
collectPairs
โธ collectPairs(): CollisionPair
[]
Obtains all the pairs of CollisionObjects which could possibly be colliding.
Returns
An array containing the CollisionPairs
Defined in
src/physics/aabb/aabbTree.ts:113
collectPairsHelper
โธ Private
collectPairsHelper(a
, b
): void
Collects CollisionPairs.
Parameters
Name | Type | Description |
---|---|---|
a | AABBNode | An AABBNode to check for pairs |
b | AABBNode | An AABBNode to check for pairs |
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:155
crossChildren
โธ Private
crossChildren(n
): void
Parameters
Name | Type |
---|---|
n | AABBNode |
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:142
getHeight
โธ getHeight(): number
Calculates and returns the height of the root node. (the height of the tree)
Returns
number
Defined in
src/physics/aabb/aabbTree.ts:344
โธ getHeight(node
): number
Calculates the height of the given node.
Parameters
Name | Type | Description |
---|---|---|
node | AABBNode | The node to start at |
Returns
number
Defined in
src/physics/aabb/aabbTree.ts:351
pick
โธ pick(point
): AABB
[]
Picks aabbs in the tree.
Parameters
Name | Type | Description |
---|---|---|
point | vec2 | The point to pick AABBs at. |
Returns
AABB
[]
The picked aabbs
Defined in
src/physics/aabb/aabbTree.ts:195
raycast
โธ raycast(ray
): AABB
[]
Raycasts against aabbs in the tree.
Parameters
Name | Type | Description |
---|---|---|
ray | Ray | The ray to cast. |
Returns
AABB
[]
Defined in
src/physics/aabb/aabbTree.ts:219
remove
โธ remove(obj
): void
Removes the leaf node containing the AABB bounding the given CollisionObject.
Parameters
Name | Type | Description |
---|---|---|
obj | CollisionObject | The CollisionObject to remove |
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:260
removeNode
โธ Private
removeNode(node
): void
Remove the given node and replace the parent with the node's sibling
Parameters
Name | Type | Description |
---|---|---|
node | AABBNode | The node to remove |
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:323
update
โธ update(): void
Updates the tree.
Returns
void
Defined in
src/physics/aabb/aabbTree.ts:36
updateAABBMargin
โธ Private
updateAABBMargin(leaf
, force?
): number
| false
Updates a leaf node's aabb's margin based on the aabb's bound CollisionObject.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
leaf | AABBNode | undefined | The leaf node to update |
force | boolean | false | Force the margin to be updated even when there is an insufficient margin difference |
Returns
number
| false
The new margin or false if the margin wasn't updated.
Defined in
src/physics/aabb/aabbTree.ts:90