Constructor
new QuadTreeBroadphase(bounds, maxdepthopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bounds |
Bounds | The region it operates on. | ||
maxdepth |
number |
<optional> |
3 | Maximum number of branches. |
- Source:
Extends
Classes
Methods
canCollide(a, b)
Checks to see if two bodies can proceed to have their bounding boxes checked
Parameters:
Name | Type | Description |
---|---|---|
a |
Body | |
b |
Body |
- Overrides:
- Source:
draw()
Renders a representation of a broadphase
- Overrides:
- Source:
getCollisionPairs(target) → {Array.<CollisionPair>}
Gets all possibly colliding pairs.
Parameters:
Name | Type | Description |
---|---|---|
target |
Array.<CollisionPair> | Empty array to store results. |
- Overrides:
- Source:
Returns:
- Type
- Array.<CollisionPair>
insert(obj)
Adds a body to the broadphase
Parameters:
Name | Type | Description |
---|---|---|
obj |
Body |
- Overrides:
- Source:
query(bounds, target) → {Array.<Body>}
Returns bodies that are within the given bound.
Parameters:
Name | Type | Description |
---|---|---|
bounds |
Bounds | Region to check in. |
target |
Array.<Body> | Empty array to store results. |
- Overrides:
- Source:
Returns:
- Type
- Array.<Body>
recalculateBounds(bounds)
Resizes a quadtree to a new bound size.
This method should not be used without care.
Parameters:
Name | Type | Description |
---|---|---|
bounds |
Bounds |
- Source:
remove(obj)
Removes a body from the broadphase
Parameters:
Name | Type | Description |
---|---|---|
obj |
Body |
- Overrides:
- Source:
traverse(func)
A depth first search of the quadtree that applies the given function to its nodes.
Parameters:
Name | Type | Description |
---|---|---|
func |
Traverser | The function that checks every node unless it returns true. |
- Source:
update(bodies)
Updates the internals of the broadphase if needed.
Parameters:
Name | Type | Description |
---|---|---|
bodies |
Array.<Body> |
- Overrides:
- Source: