UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TOctree2< ElementType, OctreeSemantics > Class Template Reference

#include <GenericOctree.h>

Public Types

using FNodeIndex = uint32
 
using FReal = FVector::FReal
 

Public Member Functions

int32 GetNumNodes () const
 
template<typename IterateAllElementsFunc >
void FindAllElements (const IterateAllElementsFunc &Func) const
 
template<typename PredicateFunc , typename IterateFunc >
void FindNodesWithPredicate (const PredicateFunc &Predicate, const IterateFunc &Func) const
 
template<typename PredicateFunc , typename IterateFunc >
void FindElementsWithPredicate (const PredicateFunc &Predicate, const IterateFunc &Func) const
 
template<typename IterateBoundsFunc >
void FindElementsWithBoundsTest (const FBoxCenterAndExtent &BoxBounds, const IterateBoundsFunc &Func) const
 
template<typename IterateBoundsFunc >
FOctreeElementId2 FindFirstElementWithBoundsTest (const FBoxCenterAndExtent &BoxBounds, const IterateBoundsFunc &Func) const
 
template<typename IterateBoundsFunc >
void FindNearbyElements (const FVector &Position, const IterateBoundsFunc &Func) const
 
void AddElement (typename TCallTraits< ElementType >::ConstReference Element)
 
void RemoveElement (FOctreeElementId2 ElementId)
 
void Destroy ()
 
ElementType & GetElementById (FOctreeElementId2 ElementId)
 
const ElementType & GetElementById (FOctreeElementId2 ElementId) const
 
bool IsValidElementId (FOctreeElementId2 ElementId) const
 
TArrayView< const ElementType > GetElementsForNode (FNodeIndex NodeIndex) const
 
void DumpStats () const
 
SIZE_T GetSizeBytes () const
 
FReal GetNodeLevelExtent (int32 Level) const
 
FBoxCenterAndExtent GetRootBounds () const
 
void ShrinkElements ()
 
void ApplyOffset (const FVector &InOffset, bool bGlobalOctree=false)
 
 TOctree2 (const FVector &InOrigin, FVector::FReal InExtent)
 
 TOctree2 ()
 

Protected Member Functions

void SetElementId (const ElementType &Element, FOctreeElementId2 Id)
 

Detailed Description

template<typename ElementType, typename OctreeSemantics>
class TOctree2< ElementType, OctreeSemantics >

An octree.

Member Typedef Documentation

◆ FNodeIndex

template<typename ElementType , typename OctreeSemantics >
using TOctree2< ElementType, OctreeSemantics >::FNodeIndex = uint32

◆ FReal

template<typename ElementType , typename OctreeSemantics >
using TOctree2< ElementType, OctreeSemantics >::FReal = FVector::FReal

Constructor & Destructor Documentation

◆ TOctree2() [1/2]

template<typename ElementType , typename OctreeSemantics >
TOctree2< ElementType, OctreeSemantics >::TOctree2 ( const FVector InOrigin,
FVector::FReal  InExtent 
)
inline

Initialization constructor.

◆ TOctree2() [2/2]

template<typename ElementType , typename OctreeSemantics >
TOctree2< ElementType, OctreeSemantics >::TOctree2 ( )
inline

DO NOT USE. This constructor is for internal usage only for hot-reload purposes.

Member Function Documentation

◆ AddElement()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::AddElement ( typename TCallTraits< ElementType >::ConstReference  Element)
inline

Adds an element to the octree.

Parameters
Element- The element to add.

◆ ApplyOffset()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::ApplyOffset ( const FVector InOffset,
bool  bGlobalOctree = false 
)
inline

Apply an arbitrary offset to all elements in the tree InOffset - offset to apply bGlobalOctree - hint that this octree is used as a boundless global volume, so only content will be shifted but not origin of the octree

◆ Destroy()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::Destroy ( )
inline

this function resets the octree to empty.

◆ DumpStats()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::DumpStats ( ) const
inline

Writes stats for the octree to the log.

◆ FindAllElements()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FindAllElements ( const IterateAllElementsFunc Func) const
inline

this function will call the passed in function for all elements in the Octree in node by node in no specified order.

Parameters
Func- Function to call with each Element.

◆ FindElementsWithBoundsTest()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FindElementsWithBoundsTest ( const FBoxCenterAndExtent BoxBounds,
const IterateBoundsFunc Func 
) const
inline

this function will traverse the Octree using a fast box-box intersection this should be the preferred way of traversing the tree.

Parameters
BoxBounds- the bounds to test if a node is traversed or skipped.
Func- Function to call with each Element for nodes that passed bounds test.

◆ FindElementsWithPredicate()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FindElementsWithPredicate ( const PredicateFunc Predicate,
const IterateFunc Func 
) const
inline

this function will traverse the Octree starting from the root in depth first order and the predicate can be used to implement custom culling for each node.

Parameters
Predicate- a Function when given the bounds of the currently traversed node that returns true if traversal should continue or false to skip that branch.
Func- Function to call with each Element for nodes that passed the predicate.

◆ FindFirstElementWithBoundsTest()

template<typename ElementType , typename OctreeSemantics >
FOctreeElementId2 TOctree2< ElementType, OctreeSemantics >::FindFirstElementWithBoundsTest ( const FBoxCenterAndExtent BoxBounds,
const IterateBoundsFunc Func 
) const
inline

this function will traverse the Octree using a fast box-box intersection and aborts traversal as soon as the Element function returns false.

Parameters
BoxBounds- the bounds to test if a node is traversed or skipped.
Func- Function to call with each Element for nodes that passed bounds test.
Returns
The ID of the found element. It's only valid until the next time the tree changes.

◆ FindNearbyElements()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FindNearbyElements ( const FVector Position,
const IterateBoundsFunc Func 
) const
inline

this function will traverse the Octree using a tryint to find nearby nodes that contain any elements.

Parameters
Position- the position to look nearby.
Func- Function to call with each Element for nodes that passed bounds test.

◆ FindNodesWithPredicate()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FindNodesWithPredicate ( const PredicateFunc Predicate,
const IterateFunc Func 
) const
inline

this function will traverse the Octree starting from the root in depth first order and the predicate can be used to implement custom culling for each node.

Parameters
Predicate- a Function when given the bounds of the currently traversed node that returns true if traversal should continue or false to skip that branch.
Func- Function that will receive the node ID which can be stored and later used to get the elements using GetElementsForNode for all nodes that passed the predicate.

◆ GetElementById() [1/2]

template<typename ElementType , typename OctreeSemantics >
ElementType & TOctree2< ElementType, OctreeSemantics >::GetElementById ( FOctreeElementId2  ElementId)
inline

Accesses an octree element by ID.

◆ GetElementById() [2/2]

template<typename ElementType , typename OctreeSemantics >
const ElementType & TOctree2< ElementType, OctreeSemantics >::GetElementById ( FOctreeElementId2  ElementId) const
inline

Accesses an octree element by ID.

◆ GetElementsForNode()

template<typename ElementType , typename OctreeSemantics >
TArrayView< const ElementType > TOctree2< ElementType, OctreeSemantics >::GetElementsForNode ( FNodeIndex  NodeIndex) const
inline

return all elements for a given node.

Parameters
NodeIndex- The the index of the node can be obtained using FindNodesWithPredicate.

◆ GetNodeLevelExtent()

template<typename ElementType , typename OctreeSemantics >
FReal TOctree2< ElementType, OctreeSemantics >::GetNodeLevelExtent ( int32  Level) const
inline

◆ GetNumNodes()

template<typename ElementType , typename OctreeSemantics >
int32 TOctree2< ElementType, OctreeSemantics >::GetNumNodes ( ) const
inline

◆ GetRootBounds()

template<typename ElementType , typename OctreeSemantics >
FBoxCenterAndExtent TOctree2< ElementType, OctreeSemantics >::GetRootBounds ( ) const
inline

◆ GetSizeBytes()

template<typename ElementType , typename OctreeSemantics >
SIZE_T TOctree2< ElementType, OctreeSemantics >::GetSizeBytes ( ) const
inline

◆ IsValidElementId()

template<typename ElementType , typename OctreeSemantics >
bool TOctree2< ElementType, OctreeSemantics >::IsValidElementId ( FOctreeElementId2  ElementId) const
inline

check if a FOctreeElementId2 is valid.

Parameters
ElementId- The ElementId to check.

◆ RemoveElement()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::RemoveElement ( FOctreeElementId2  ElementId)
inline

Removes an element from the octree.

Parameters
ElementId- The element to remove from the octree.

◆ SetElementId()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::SetElementId ( const ElementType &  Element,
FOctreeElementId2  Id 
)
inlineprotected

◆ ShrinkElements()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::ShrinkElements ( )
inline

The documentation for this class was generated from the following file: