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.

public class QuadTree<T extends QuadTree.QuadTreeObject> extends Object
A basic quad tree.

This class represents any node, but you will likely only interact with the root node.

  • Field Details

  • Constructor Details

    • QuadTree

      public QuadTree(Rect bounds)
  • Method Details

    • split

      protected void split()
    • unsplit

      protected void unsplit()
    • insert

      public void insert(T obj)
      Inserts an object into this node or its child nodes. This will split a leaf node if it exceeds the object limit.
    • remove

      public boolean remove(T obj)
      Removes an object from this node or its child nodes.
    • clear

      public void clear()
      Removes all objects.
    • getFittingChild

      protected QuadTree<T> getFittingChild(Rect boundingBox)
    • intersect

      public void intersect(float x, float y, float width, float height, Cons<T> out)
      Processes objects that may intersect the given rectangle.

      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

      public void intersect(Rect rect, Cons<T> out)
      Processes objects that may intersect the given rectangle.

      This will never result in false positives.

    • intersect

      public void intersect(Rect toCheck, Seq<T> out)
      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

      public void intersect(float x, float y, float width, float height, Seq<T> out)
      Fills the out parameter with any objects that may intersect the given rectangle.
    • getObjects

      public void getObjects(Seq<T> out)
      Adds all quadtree objects to the specified Seq.
    • newChild

      protected QuadTree<T> newChild(Rect rect)
    • hitbox

      protected void hitbox(T t)