class
TSpatialTree
template<typename ElementType, typename Options, u32 Dimension>Spatial partitioning tree for 1D/2D/3D space (i.e. quadtree for 2D, octree for 3D).
Template parameters
ElementType | Type of elements to be stored in the tree. |
|---|---|
Options | Class that controls various options of the tree. It must provide the following enums:
It must also provide the following methods:
|
Public
Constructors
TSpatialTree
Constructs a spatial tree with the specified bounds.
- center
- Origin of the root node.
- extent
- Extent (half-size) of the root node in all directions;
- context
- Optional user context that will be passed along to GetBounds() and SetElementId() methods on the provided Options class.
Methods
~TSpatialTree
AddElement
Adds a new element to the tree.
RemoveElement
Removes an existing element from the tree.
Private
Methods
AddElementToNode
Adds a new element to the specified node.
If the provided node is not a leaf node, traverses the hierarchy until it finds the correct node. Potentially also subdivides the leaf node if subdivision conditions have been reached.
AddElementToLeafNode
Adds a new element to the node's element list.
This method does no additional checks so caller must ensure the node is a leaf node and does not need to be subdivided.
RemoveElementFromLeafNode
Removes the specified element from the node's element list.
FreeNode
Cleans up memory used by the provided node.
Should be called instead of the node destructor.