Package arc.math.geom
Class QuadTree<T extends QuadTree.QuadTreeObject>
java.lang.Object
arc.math.geom.QuadTree<T>
- Type Parameters:
T- The type of object this quad tree should contain. An object only requires some way of getting rough bounds.
A basic quad tree.
This class represents any node, but you will likely only interact with the root node.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents an object in a QuadTree. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanany(float x, float y, float width, float height) voidclear()Removes all objects.Tries to find any object matching the predicate in this tree.getFittingChild(Rect boundingBox) voidgetObjects(Seq<T> out) Adds all quadtree objects to the specified Seq.protected voidvoidInserts an object into this node or its child nodes.booleanProcesses objects that may intersect the given rectangle.voidProcesses objects that may intersect the given rectangle.voidFills the out parameter with any objects that may intersect the given rectangle.voidProcesses objects that may intersect the given rectangle.voidFills the out parameter with any objects that may intersect the given rectangle.booleanRemoves an object from this node or its child nodes.protected voidsplit()protected voidunsplit()
-
Field Details
-
tmp
-
maxObjectsPerNode
protected static final int maxObjectsPerNode- See Also:
-
bounds
-
objects
-
botLeft
-
botRight
-
topLeft
-
topRight
-
leaf
public boolean leaf -
totalObjects
public int totalObjects
-
-
Constructor Details
-
QuadTree
-
-
Method Details
-
split
protected void split() -
unsplit
protected void unsplit() -
insert
Inserts an object into this node or its child nodes. This will split a leaf node if it exceeds the object limit. -
remove
Removes an object from this node or its child nodes. -
clear
public void clear()Removes all objects. -
getFittingChild
-
intersect
Processes objects that may intersect the given rectangle.This will never result in false positives.
-
intersect
Processes objects that may intersect the given rectangle. Returning true will break out of the function.This will never result in false positives.
-
find
Tries to find any object matching the predicate in this tree.This will never result in false positives.
-
any
public boolean any(float x, float y, float width, float height) - Returns:
- whether an object overlaps this rectangle. This will never result in false positives.
-
intersect
Processes objects that may intersect the given rectangle.This will never result in false positives.
-
intersect
Fills the out parameter with any objects that may intersect the given rectangle.This will result in false positives, but never a false negative.
-
intersect
Fills the out parameter with any objects that may intersect the given rectangle. -
getObjects
Adds all quadtree objects to the specified Seq. -
newChild
-
hitbox
-