Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TOctree2< ElementType, OctreeSemantics > Class Template Reference

#include <GenericOctree.h>

+ Collaboration diagram for TOctree2< ElementType, OctreeSemantics >:

Classes

struct  COctreeSemanticsV2
 
class  FFreeList
 
struct  FNode
 

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 >
void 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)
 

Private Types

using ElementArrayType = TArray<ElementType, typename OctreeSemantics::ElementAllocator>
 

Private Member Functions

FNodeIndex AllocateEightNodes ()
 
void FreeEightNodes (FNodeIndex Index)
 
void AddElementInternal (FNodeIndex CurrentNodeIndex, const FOctreeNodeContext &NodeContext, const FBoxCenterAndExtent &ElementBounds, typename TCallTraits< ElementType >::ConstReference Element, ElementArrayType &TempElementStorage)
 
void CollapseNodesInternal (FNodeIndex CurrentNodeIndex, ElementArrayType &CollapsedNodeElements)
 
template<typename PredicateFunc , typename IterateFunc >
void FindNodesWithPredicateInternal (FNodeIndex ParentNodeIndex, FNodeIndex CurrentNodeIndex, const FOctreeNodeContext &NodeContext, const PredicateFunc &Predicate, const IterateFunc &Func) const
 
template<typename IterateFunc >
void FindElementsWithBoundsTestInternal (FNodeIndex CurrentNodeIndex, const FOctreeNodeContext &NodeContext, const FBoxCenterAndExtent &BoxBounds, const IterateFunc &Func) const
 
template<typename IterateFunc >
void FindFirstElementWithBoundsTestInternal (FNodeIndex CurrentNodeIndex, const FOctreeNodeContext &NodeContext, const FBoxCenterAndExtent &BoxBounds, const IterateFunc &Func, bool &ContinueTraversal) const
 
template<typename IterateFunc >
void FindNearbyElementsInternal (FNodeIndex CurrentNodeIndex, const FOctreeNodeContext &NodeContext, const FBoxCenterAndExtent &BoxBounds, const IterateFunc &Func) const
 
template<typename Semantics >
TEnableIf<!TModels< COctreeSemanticsV2, Semantics >::Value >::Type SetOctreeSemanticsElementId (const ElementType &Element, FOctreeElementId2 Id)
 
template<typename Semantics >
TEnableIf< TModels< COctreeSemanticsV2, Semantics >::Value >::Type SetOctreeSemanticsElementId (const ElementType &Element, FOctreeElementId2 Id)
 

Private Attributes

FOctreeNodeContext RootNodeContext
 
TArray< FNodeTreeNodes
 
TArray< FNodeIndexParentLinks
 
TArray< ElementArrayType, TAlignedHeapAllocator< alignof(ElementArrayType)> > TreeElements
 
TArray< FNodeIndexFreeList
 
FVector::FReal MinLeafExtent
 

Detailed Description

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

An octree.

Definition at line 382 of file GenericOctree.h.

Member Typedef Documentation

◆ ElementArrayType

template<typename ElementType , typename OctreeSemantics >
using TOctree2< ElementType, OctreeSemantics >::ElementArrayType = TArray<ElementType, typename OctreeSemantics::ElementAllocator>
private

Definition at line 384 of file GenericOctree.h.

◆ FNodeIndex

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

Definition at line 386 of file GenericOctree.h.

◆ FReal

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

Definition at line 387 of file GenericOctree.h.

Constructor & Destructor Documentation

◆ TOctree2() [1/2]

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

Initialization constructor.

Definition at line 1022 of file GenericOctree.h.

◆ 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.

Definition at line 1031 of file GenericOctree.h.

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.

Definition at line 809 of file GenericOctree.h.

◆ AddElementInternal()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::AddElementInternal ( FNodeIndex CurrentNodeIndex,
const FOctreeNodeContext & NodeContext,
const FBoxCenterAndExtent & ElementBounds,
typename TCallTraits< ElementType >::ConstReference Element,
ElementArrayType & TempElementStorage )
inlineprivate

Definition at line 541 of file GenericOctree.h.

◆ AllocateEightNodes()

template<typename ElementType , typename OctreeSemantics >
FNodeIndex TOctree2< ElementType, OctreeSemantics >::AllocateEightNodes ( )
inlineprivate

Definition at line 511 of file GenericOctree.h.

◆ 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

Definition at line 998 of file GenericOctree.h.

◆ CollapseNodesInternal()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::CollapseNodesInternal ( FNodeIndex CurrentNodeIndex,
ElementArrayType & CollapsedNodeElements )
inlineprivate

Definition at line 593 of file GenericOctree.h.

◆ Destroy()

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

this function resets the octree to empty.

Definition at line 881 of file GenericOctree.h.

◆ DumpStats()

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

Writes stats for the octree to the log.

Definition at line 922 of file GenericOctree.h.

◆ 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.

Definition at line 731 of file GenericOctree.h.

◆ 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.

Definition at line 776 of file GenericOctree.h.

◆ FindElementsWithBoundsTestInternal()

template<typename ElementType , typename OctreeSemantics >
template<typename IterateFunc >
void TOctree2< ElementType, OctreeSemantics >::FindElementsWithBoundsTestInternal ( FNodeIndex CurrentNodeIndex,
const FOctreeNodeContext & NodeContext,
const FBoxCenterAndExtent & BoxBounds,
const IterateFunc & Func ) const
inlineprivate

Definition at line 631 of file GenericOctree.h.

◆ 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.

Definition at line 759 of file GenericOctree.h.

◆ FindFirstElementWithBoundsTest()

template<typename ElementType , typename OctreeSemantics >
void 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.

Definition at line 787 of file GenericOctree.h.

◆ FindFirstElementWithBoundsTestInternal()

template<typename ElementType , typename OctreeSemantics >
template<typename IterateFunc >
void TOctree2< ElementType, OctreeSemantics >::FindFirstElementWithBoundsTestInternal ( FNodeIndex CurrentNodeIndex,
const FOctreeNodeContext & NodeContext,
const FBoxCenterAndExtent & BoxBounds,
const IterateFunc & Func,
bool & ContinueTraversal ) const
inlineprivate

Definition at line 659 of file GenericOctree.h.

◆ 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.

Definition at line 799 of file GenericOctree.h.

◆ FindNearbyElementsInternal()

template<typename ElementType , typename OctreeSemantics >
template<typename IterateFunc >
void TOctree2< ElementType, OctreeSemantics >::FindNearbyElementsInternal ( FNodeIndex CurrentNodeIndex,
const FOctreeNodeContext & NodeContext,
const FBoxCenterAndExtent & BoxBounds,
const IterateFunc & Func ) const
inlineprivate

Definition at line 688 of file GenericOctree.h.

◆ 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.

Definition at line 748 of file GenericOctree.h.

◆ FindNodesWithPredicateInternal()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FindNodesWithPredicateInternal ( FNodeIndex ParentNodeIndex,
FNodeIndex CurrentNodeIndex,
const FOctreeNodeContext & NodeContext,
const PredicateFunc & Predicate,
const IterateFunc & Func ) const
inlineprivate

Definition at line 610 of file GenericOctree.h.

◆ FreeEightNodes()

template<typename ElementType , typename OctreeSemantics >
void TOctree2< ElementType, OctreeSemantics >::FreeEightNodes ( FNodeIndex Index)
inlineprivate

Definition at line 528 of file GenericOctree.h.

◆ GetElementById() [1/2]

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

Accesses an octree element by ID.

Definition at line 892 of file GenericOctree.h.

◆ GetElementById() [2/2]

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

Accesses an octree element by ID.

Definition at line 898 of file GenericOctree.h.

◆ 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.

Definition at line 916 of file GenericOctree.h.

◆ GetNodeLevelExtent()

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

Definition at line 973 of file GenericOctree.h.

◆ GetNumNodes()

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

Definition at line 724 of file GenericOctree.h.

◆ GetRootBounds()

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

Definition at line 979 of file GenericOctree.h.

◆ GetSizeBytes()

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

Definition at line 965 of file GenericOctree.h.

◆ 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.

Definition at line 907 of file GenericOctree.h.

◆ 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.

Definition at line 820 of file GenericOctree.h.

◆ SetElementId()

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

Definition at line 1062 of file GenericOctree.h.

◆ SetOctreeSemanticsElementId() [1/2]

template<typename ElementType , typename OctreeSemantics >
template<typename Semantics >
TEnableIf<!TModels< COctreeSemanticsV2, Semantics >::Value >::Type TOctree2< ElementType, OctreeSemantics >::SetOctreeSemanticsElementId ( const ElementType & Element,
FOctreeElementId2 Id )
inlineprivate

Definition at line 1050 of file GenericOctree.h.

◆ SetOctreeSemanticsElementId() [2/2]

template<typename ElementType , typename OctreeSemantics >
template<typename Semantics >
TEnableIf< TModels< COctreeSemanticsV2, Semantics >::Value >::Type TOctree2< ElementType, OctreeSemantics >::SetOctreeSemanticsElementId ( const ElementType & Element,
FOctreeElementId2 Id )
inlineprivate

Definition at line 1055 of file GenericOctree.h.

◆ ShrinkElements()

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

Definition at line 984 of file GenericOctree.h.

Member Data Documentation

◆ FreeList

template<typename ElementType , typename OctreeSemantics >
TArray<FNodeIndex> TOctree2< ElementType, OctreeSemantics >::FreeList
private

Definition at line 507 of file GenericOctree.h.

◆ MinLeafExtent

template<typename ElementType , typename OctreeSemantics >
FVector::FReal TOctree2< ElementType, OctreeSemantics >::MinLeafExtent
private

The extent of a leaf at the maximum allowed depth of the tree.

Definition at line 509 of file GenericOctree.h.

◆ ParentLinks

template<typename ElementType , typename OctreeSemantics >
TArray<FNodeIndex> TOctree2< ElementType, OctreeSemantics >::ParentLinks
private

Definition at line 403 of file GenericOctree.h.

◆ RootNodeContext

template<typename ElementType , typename OctreeSemantics >
FOctreeNodeContext TOctree2< ElementType, OctreeSemantics >::RootNodeContext
private

Definition at line 401 of file GenericOctree.h.

◆ TreeElements

Definition at line 404 of file GenericOctree.h.

◆ TreeNodes

template<typename ElementType , typename OctreeSemantics >
TArray<FNode> TOctree2< ElementType, OctreeSemantics >::TreeNodes
private

Definition at line 402 of file GenericOctree.h.


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