Class Octree
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
Spatial partitioning structure for efficient scene node culling and queries.
public class Octree : ISpatialSetInheritance
Implements
Constructors
Octree(float)
Initializes a new octree with the specified size.
public Octree(float size)Parameters
size float
Total size of the octree region (centered at origin).
Octree(AABB)
Initializes a new octree with the specified bounding box as the largest region.
public Octree(AABB size)Parameters
size AABB
Properties
DebugRenderer
Gets or sets an optional debug renderer that visualizes this octree.
public OctreeDebugRenderer? DebugRenderer { get; set; }Property Value
Dirty
Gets or sets whether this octree needs to be rebuilt.
public bool Dirty { get; set; }Property Value
Root
Gets the root node of the octree.
public Octree.Node Root { get; }Property Value
Methods
Clear()
Clears all nodes and elements from the octree.
public void Clear()Clear(AABB)
Clears all nodes and roughly sizes root to the specified bounds.
public void Clear(AABB rootBounds)Parameters
rootBounds AABB
GetBounds()
Returns the bounds covering every node in the tree.
public AABB GetBounds()Returns
Insert(SceneNode)
Inserts a scene node into the octree.
public void Insert(SceneNode node)Parameters
node SceneNode
Scene node to insert.
Exceptions
Thrown if node is null.
Query(Frustum, List<SceneNode>)
Appends every node whose bounds intersect the frustum.
public void Query(Frustum frustum, List<SceneNode> results)Parameters
frustum Frustum
Query(in AABB, List<SceneNode>)
Appends every node whose bounds intersect the box.
public void Query(in AABB bounds, List<SceneNode> results)Parameters
bounds AABB
Remove(SceneNode)
Removes a scene node from the octree.
public void Remove(SceneNode obj)Parameters
obj SceneNode
Scene node to remove.
Exceptions
Thrown if obj is null.
Update(SceneNode)
Marks the tree dirty; relocating a node without its old bounds takes a rebuild.
public void Update(SceneNode node)Parameters
node SceneNode
Update(SceneNode, in AABB)
Updates a scene node's position in the octree after its bounds have changed.
public void Update(SceneNode obj, in AABB oldBounds)Parameters
obj SceneNode
Scene node to update.
oldBounds AABB
Previous bounding box of the scene node.
Remarks
Relocates the node to the appropriate octree node based on its new bounds. May push the node down to child nodes or up to ancestor nodes as needed.
Exceptions
Thrown if obj is null.

