UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::FDynamicMeshOctree3 Class Reference

#include <DynamicMeshOctree3.h>

+ Inheritance diagram for UE::Geometry::FDynamicMeshOctree3:

Classes

struct  FCellReference
 
class  FTreeCutSet
 

Public Member Functions

void Initialize (const FDynamicMesh3 *MeshIn)
 
void ResetModifiedBounds ()
 
void InsertTriangle (int32 TriangleID)
 
void InsertTriangles (const TArray< int > &Triangles)
 
void InsertTriangles (const TSet< int > &Triangles)
 
bool RemoveTriangle (int32 TriangleID)
 
template<typename EnumerableType >
void RemoveTriangles (const EnumerableType &Triangles, bool bMarkModifiedBounds=true)
 
template<typename EnumerableType >
void ReinsertTriangles (const EnumerableType &Triangles)
 
void ReinsertTrianglesParallel (const TArray< int32 > &Triangles, TArray< uint32 > &TempBuffer, TArray< bool > &TempFlagBuffer)
 
void NotifyPendingModification (int TriangleID)
 
template<typename EnumerableType >
void NotifyPendingModification (const EnumerableType &Triangles)
 
int32 FindNearestHitObject (const FRay3d &Ray, double MaxDistance=TNumericLimits< double >::Max()) const
 
int32 FindNearestHitObject (const FRay3d &Ray, TFunctionRef< bool(int)> IncludeTriangleIDFunc, double MaxDistance=TNumericLimits< double >::Max()) const
 
void CheckValidity (EValidityCheckFailMode FailMode=EValidityCheckFailMode::Check, bool bVerbose=false, bool bFailOnMissingObjects=false) const
 
FTreeCutSet BuildLevelCutSet (uint32 CutLevel=5) const
 
void UpdateLevelCutSet (FTreeCutSet &CutSet, TArray< FCellReference > &NewCutCellsOut) const
 
bool TestCellIntersection (const FCellReference &CellRef, const FAxisAlignedBox3d &Bounds) const
 
void CollectTriangles (const FCellReference &CellRef, TFunctionRef< void(int)> TriangleFunc) const
 
void CollectRootTriangles (const FTreeCutSet &CutSet, TFunctionRef< void(int)> TriangleFunc) const
 
void CollectSpillTriangles (TFunctionRef< void(int)> TriangleFunc) const
 
- Public Member Functions inherited from UE::Geometry::FSparseDynamicOctree3
int GetMaxTreeDepth ()
 
void SetMaxTreeDepth (int MaxTreeDepthIn)
 
GEOMETRYCORE_API bool ContainsObject (int32 ObjectID) const
 
GEOMETRYCORE_API void InsertObject (int32 ObjectID, const FAxisAlignedBox3d &Bounds)
 
GEOMETRYCORE_API bool RemoveObject (int32 ObjectID)
 
GEOMETRYCORE_API bool ReinsertObject (int32 ObjectID, const FAxisAlignedBox3d &NewBounds, uint32 CellIDHint=InvalidCellID)
 
GEOMETRYCORE_API bool CheckIfObjectNeedsReinsert (int32 ObjectID, const FAxisAlignedBox3d &NewBounds, uint32 &CellIDOut) const
 
GEOMETRYCORE_API int32 FindNearestHitObject (const FRay3d &Ray, TFunctionRef< FAxisAlignedBox3d(int)> GetObjectBoundsFunc, TFunctionRef< double(int, const FRay3d &)> HitObjectDistFunc, double MaxDistance=TNumericLimits< double >::Max()) const
 
GEOMETRYCORE_API void ContainmentQuery (const FVector3d &Point, TFunctionRef< void(int)> ObjectIDFunc) const
 
GEOMETRYCORE_API bool ContainmentQueryCancellable (const FVector3d &Point, TFunctionRef< bool(int)> ObjectIDFunc) const
 
GEOMETRYCORE_API void RangeQuery (const FAxisAlignedBox3d &Bounds, TFunctionRef< void(int)> ObjectIDFunc) const
 
GEOMETRYCORE_API void RangeQuery (const FAxisAlignedBox3d &Bounds, TArray< int > &ObjectIDsOut) const
 
GEOMETRYCORE_API void ParallelRangeQuery (const FAxisAlignedBox3d &Bounds, TArray< int > &ObjectIDsOut) const
 
GEOMETRYCORE_API void ParallelRangeQuery (const FAxisAlignedBox3d &RangeBoundsHint, TFunctionRef< bool(const FAxisAlignedBox3d &CellBounds)> BoundsOverlapFn, TArray< int32 > &ObjectIDs) const
 
GEOMETRYCORE_API int ParallelOverlapAnyQuery (const FAxisAlignedBox3d &ShapeBounds, TFunctionRef< bool(int32)> ObjectOverlapFn, TFunctionRef< bool(const FAxisAlignedBox3d &)> BoundsOverlapFn) const
 
int ParallelOverlapAnyQuery (const FAxisAlignedBox3d &ShapeBounds, TFunctionRef< bool(int32)> ObjectOverlapFn) const
 
GEOMETRYCORE_API void CheckValidity (TFunctionRef< bool(int)> IsValidObjectIDFunc, TFunctionRef< FAxisAlignedBox3d(int)> GetObjectBoundsFunc, EValidityCheckFailMode FailMode=EValidityCheckFailMode::Check, bool bVerbose=false, bool bFailOnMissingObjects=false) const
 
GEOMETRYCORE_API void ComputeStatistics (FStatistics &StatsOut) const
 

Public Attributes

const FDynamicMesh3Mesh
 
FAxisAlignedBox3d ModifiedBounds
 
- Public Attributes inherited from UE::Geometry::FSparseDynamicOctree3
double RootDimension = 1000.0
 
double MaxExpandFactor = 0.25
 

Additional Inherited Members

- Static Public Attributes inherited from UE::Geometry::FSparseDynamicOctree3
static constexpr uint32 MaxSupportedTreeDepth = 0x1F
 
- Protected Member Functions inherited from UE::Geometry::FSparseDynamicOctree3
double GetCellWidth (uint32 Level) const
 
FAxisAlignedBox3d GetBox (uint32 Level, const FVector3i &Index, double ExpandFactor) const
 
FAxisAlignedBox3d GetCellBox (const FSparseOctreeCell &Cell, double ExpandFactor=0) const
 
FVector3d GetCellCenter (const FSparseOctreeCell &Cell) const
 
FVector3i PointToIndex (uint32 Level, const FVector3d &Position) const
 
int ToChildCellIndex (const FSparseOctreeCell &Cell, const FVector3d &Position) const
 
bool CanFit (const FSparseOctreeCell &Cell, const FAxisAlignedBox3d &Bounds) const
 
uint32 GetCellForObject (int32 ObjectID) const
 
GEOMETRYCORE_API FSparseOctreeCell FindCurrentContainingCell (const FAxisAlignedBox3d &Bounds) const
 
GEOMETRYCORE_API void Insert_Spill (int32 ObjectID, const FAxisAlignedBox3d &Bounds)
 
GEOMETRYCORE_API void Insert_NewRoot (int32 ObjectID, const FAxisAlignedBox3d &Bounds, FSparseOctreeCell NewRootCell)
 
GEOMETRYCORE_API void Insert_ToCell (int32 ObjectID, const FAxisAlignedBox3d &Bounds, const FSparseOctreeCell &ExistingCell)
 
GEOMETRYCORE_API void Insert_NewChildCell (int32 ObjectID, const FAxisAlignedBox3d &Bounds, int ParentCellID, FSparseOctreeCell NewChildCell, int ChildIdx)
 
GEOMETRYCORE_API double FindNearestRayCellIntersection (const FSparseOctreeCell &Cell, const FRay3d &Ray) const
 
GEOMETRYCORE_API void BranchRangeQuery (const FSparseOctreeCell *ParentCell, const FAxisAlignedBox3d &Bounds, TArray< int > &ObjectIDs) const
 
- Protected Attributes inherited from UE::Geometry::FSparseDynamicOctree3
int MaxTreeDepth = 10
 
FRefCountVector CellRefCounts
 
TDynamicVector< FSparseOctreeCellCells
 
FSmallListSet CellObjectLists
 
TSet< int32SpillObjectSet
 
TDynamicVector< uint32ObjectIDToCellMap
 
FDynamicFlagArray ValidObjectIDs
 
TSparseGrid3< uint32RootCells
 
- Static Protected Attributes inherited from UE::Geometry::FSparseDynamicOctree3
static constexpr uint32 InvalidCellID = FSparseOctreeCell::InvalidID
 
static constexpr uint32 SpillCellID = InvalidCellID - 1
 

Detailed Description

FDynamicMeshOctree3 is an extension of FSparseDynamicOctree3 for the triangles of a FDynamicMesh3 instance. This extension does several things: 1) provides a simplified API based on triangle IDs to various Octree functions 2) tracks ModifiedBounds box of modified areas 3) support for computing/updating/querying a "Cut" of the octree, ie a set of cells which are roots of sub-branches that partition the tree. This is useful for splitting up mesh processing/rendering into spatially-coherent chunks. (This functionality should probably be extracted into a separate class...)

Member Function Documentation

◆ BuildLevelCutSet()

FTreeCutSet UE::Geometry::FDynamicMeshOctree3::BuildLevelCutSet ( uint32  CutLevel = 5) const
inline
Returns
a cut of the tree at a fixed level

◆ CheckValidity()

void UE::Geometry::FDynamicMeshOctree3::CheckValidity ( EValidityCheckFailMode  FailMode = EValidityCheckFailMode::Check,
bool  bVerbose = false,
bool  bFailOnMissingObjects = false 
) const
inline

Check that the Octree is internally valid

◆ CollectRootTriangles()

void UE::Geometry::FDynamicMeshOctree3::CollectRootTriangles ( const FTreeCutSet CutSet,
TFunctionRef< void(int)>  TriangleFunc 
) const
inline

Call TriangleFunc for all triangles in the octree "above" the CutSet (ie at tree cells that are not children of any cut cells)

◆ CollectSpillTriangles()

void UE::Geometry::FDynamicMeshOctree3::CollectSpillTriangles ( TFunctionRef< void(int)>  TriangleFunc) const
inline

Call TriangleFunc for any triangles in the spill set (ie not contained in any Root cell)

◆ CollectTriangles()

void UE::Geometry::FDynamicMeshOctree3::CollectTriangles ( const FCellReference CellRef,
TFunctionRef< void(int)>  TriangleFunc 
) const
inline

Call TriangleFunc on any triangles in the branch of the tree starting at CellRef

◆ FindNearestHitObject() [1/2]

int32 UE::Geometry::FDynamicMeshOctree3::FindNearestHitObject ( const FRay3d Ray,
double  MaxDistance = TNumericLimits<double>::Max() 
) const
inline

Find the nearest triangle of the mesh that is hit by the ray

◆ FindNearestHitObject() [2/2]

int32 UE::Geometry::FDynamicMeshOctree3::FindNearestHitObject ( const FRay3d Ray,
TFunctionRef< bool(int)>  IncludeTriangleIDFunc,
double  MaxDistance = TNumericLimits<double>::Max() 
) const
inline

Find the nearest triangle of the mesh that is hit by the ray

Parameters
IncludeTriangleIDFuncpredicate function that must return true for given TriangleID for it to be considered

◆ Initialize()

void UE::Geometry::FDynamicMeshOctree3::Initialize ( const FDynamicMesh3 MeshIn)
inline

Add all triangles of MeshIn to the octree

◆ InsertTriangle()

void UE::Geometry::FDynamicMeshOctree3::InsertTriangle ( int32  TriangleID)
inline

Insert a triangle into the tree

◆ InsertTriangles() [1/2]

void UE::Geometry::FDynamicMeshOctree3::InsertTriangles ( const TArray< int > &  Triangles)
inline

Insert a list of triangles into the tree

◆ InsertTriangles() [2/2]

void UE::Geometry::FDynamicMeshOctree3::InsertTriangles ( const TSet< int > &  Triangles)
inline

Insert a set of triangles into the tree

◆ NotifyPendingModification() [1/2]

void UE::Geometry::FDynamicMeshOctree3::NotifyPendingModification ( const EnumerableType Triangles)
inline

Include the current bounds of a set of triangles in the ModifiedBounds box

◆ NotifyPendingModification() [2/2]

void UE::Geometry::FDynamicMeshOctree3::NotifyPendingModification ( int  TriangleID)
inline

Include the current bounds of a triangle in the ModifiedBounds box

◆ ReinsertTriangles()

void UE::Geometry::FDynamicMeshOctree3::ReinsertTriangles ( const EnumerableType Triangles)
inline

Reinsert a set of triangles into the tree

◆ ReinsertTrianglesParallel()

void UE::Geometry::FDynamicMeshOctree3::ReinsertTrianglesParallel ( const TArray< int32 > &  Triangles,
TArray< uint32 > &  TempBuffer,
TArray< bool > &  TempFlagBuffer 
)
inline

Reinsert a set of triangles into the tree. Internally precomputes which triangles need re-inserting, which can be done in parallel and generally saves time as some triangles can be skipped.

◆ RemoveTriangle()

bool UE::Geometry::FDynamicMeshOctree3::RemoveTriangle ( int32  TriangleID)
inline

Remove a triangle from the tree

◆ RemoveTriangles()

void UE::Geometry::FDynamicMeshOctree3::RemoveTriangles ( const EnumerableType Triangles,
bool  bMarkModifiedBounds = true 
)
inline

Remove a set of triangles into the tree

◆ ResetModifiedBounds()

void UE::Geometry::FDynamicMeshOctree3::ResetModifiedBounds ( )
inline

Reset the internal ModifiedBounds box that tracks modified triangle bounds

◆ TestCellIntersection()

bool UE::Geometry::FDynamicMeshOctree3::TestCellIntersection ( const FCellReference CellRef,
const FAxisAlignedBox3d Bounds 
) const
inline
Returns
true if the cell identified by CellRef intersects the Bounds box

◆ UpdateLevelCutSet()

void UE::Geometry::FDynamicMeshOctree3::UpdateLevelCutSet ( FTreeCutSet CutSet,
TArray< FCellReference > &  NewCutCellsOut 
) const
inline

For a fixed-level cut set created by BuildLevelCutSet, check that all current cells at that level are in the cut set (call this after adding/removing to the tree to make sure the CutSet is up to date)

Parameters
CutSetthe tree cut set to check/update
NewCutCellsOutlist of new cut cells added by the update

Member Data Documentation

◆ Mesh

const FDynamicMesh3* UE::Geometry::FDynamicMeshOctree3::Mesh

parent mesh

◆ ModifiedBounds

FAxisAlignedBox3d UE::Geometry::FDynamicMeshOctree3::ModifiedBounds

bounding box of triangles that have been inserted/removed since last clear


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