java.lang.Object
technology.sola.engine.physics.utils.QuadTreeNode
QuadTreeNode is a quad tree implementation for collidable
Entity
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
QuadTreeData holds data that can be inserted into aQuadTreeNode
. -
Constructor Summary
ConstructorsConstructorDescriptionQuadTreeNode
(Rectangle nodeBounds) Creates a QuadTreeNode with desired bounds.QuadTreeNode
(Rectangle nodeBounds, int maxDepth, int maxEntitiesPerNode) Creates a QuadTreeNode with desired bounds, maxDepth and maxEntitiesPerNode. -
Method Summary
Modifier and TypeMethodDescriptionint
void
Inserts an entry into the quad tree.List<technology.sola.ecs.view.View2Entry<ColliderComponent,
TransformComponent>> Searches an area for all collidable entities within it.void
Removes an entry from the quad tree.void
Updates an entry in the quad tree.
-
Constructor Details
-
QuadTreeNode
Creates a QuadTreeNode with desired bounds. The maxDepth is defaulted to 5 and the maxEntitiesPerNode is defaulted to 8.- Parameters:
nodeBounds
- the bounds of this node
-
QuadTreeNode
Creates a QuadTreeNode with desired bounds, maxDepth and maxEntitiesPerNode.- Parameters:
nodeBounds
- the bounds of this nodemaxDepth
- the max depth of the treemaxEntitiesPerNode
- the max entities per node in the tree
-
-
Method Details
-
insert
Inserts an entry into the quad tree.- Parameters:
data
- the entry to insert
-
update
Updates an entry in the quad tree.- Parameters:
data
- the entry to update
-
remove
Removes an entry from the quad tree.- Parameters:
data
- the entry to remove
-
query
public List<technology.sola.ecs.view.View2Entry<ColliderComponent,TransformComponent>> query(Rectangle area) Searches an area for all collidable entities within it.- Parameters:
area
- the area to search- Returns:
- the list of collidable entities in the area
-
getNodeBounds
- Returns:
- the bounds of this node
-
getChildren
- Returns:
- the child nodes of this node
-
getCurrentDepth
public int getCurrentDepth()- Returns:
- the current depth of this node
-