Class QuadTreeNode

java.lang.Object
technology.sola.engine.physics.utils.QuadTreeNode

@NullMarked public class QuadTreeNode extends Object
QuadTreeNode is a quad tree implementation for collidable Entity.
  • Constructor Details

    • QuadTreeNode

      public QuadTreeNode(Rectangle nodeBounds)
      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

      public QuadTreeNode(Rectangle nodeBounds, int maxDepth, int maxEntitiesPerNode)
      Creates a QuadTreeNode with desired bounds, maxDepth and maxEntitiesPerNode.
      Parameters:
      nodeBounds - the bounds of this node
      maxDepth - the max depth of the tree
      maxEntitiesPerNode - the max entities per node in the tree
  • Method Details

    • insert

      public void insert(QuadTreeNode.QuadTreeData data)
      Inserts an entry into the quad tree.
      Parameters:
      data - the entry to insert
    • update

      public void update(QuadTreeNode.QuadTreeData data)
      Updates an entry in the quad tree.
      Parameters:
      data - the entry to update
    • remove

      public void remove(QuadTreeNode.QuadTreeData data)
      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

      public Rectangle getNodeBounds()
      Returns:
      the bounds of this node
    • getChildren

      public List<QuadTreeNode> getChildren()
      Returns:
      the child nodes of this node
    • getCurrentDepth

      public int getCurrentDepth()
      Returns:
      the current depth of this node