UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::TSparseGrid3< ElemType > Class Template Reference

#include <SparseGrid3.h>

Public Member Functions

 TSparseGrid3 ()
 
 ~TSparseGrid3 ()
 
 TSparseGrid3 (const TSparseGrid3 &Other)=delete
 
TSparseGrid3operator= (const TSparseGrid3 &Other)=delete
 
 TSparseGrid3 (TSparseGrid3 &&Other) noexcept
 
TSparseGrid3operator= (TSparseGrid3 &&Other) noexcept
 
bool Has (const FVector3i &Index) const
 
const ElemType * Get (const FVector3i &Index) const
 
ElemType * Get (const FVector3i &Index, bool bAllocateIfMissing)
 
bool Free (const FVector3i &Index)
 
void FreeAll ()
 
int GetCount () const
 
float GetDensity () const
 
FAxisAlignedBox3i GetBoundsInclusive () const
 
FVector3i GetDimensions () const
 
template<typename Func >
void AllocatedIteration (Func ElementFunc) const
 
template<typename Func >
void RangeIteration (FVector3i MinIndex, FVector3i MaxIndex, Func ElementFunc) const
 

Protected Member Functions

ElemType * Allocate (const FVector3i &index)
 

Protected Attributes

TMap< FVector3i, ElemType * > Elements
 
FAxisAlignedBox3i Bounds
 

Detailed Description

template<typename ElemType>
class UE::Geometry::TSparseGrid3< ElemType >

Dynamic sparse 3D grid. Useful in cases where we have grid of some type of non-trivial object and we don't want to pre-allocate full grid of them. So we allocate on-demand. This can be used to implement multi-grid schemes, eg for example the ElemType could be sub-grid of fixed dimension.

Constructor & Destructor Documentation

◆ TSparseGrid3() [1/3]

template<typename ElemType >
UE::Geometry::TSparseGrid3< ElemType >::TSparseGrid3 ( )
inline

Create empty grid

◆ ~TSparseGrid3()

template<typename ElemType >
UE::Geometry::TSparseGrid3< ElemType >::~TSparseGrid3 ( )
inline

Deletes all grid elements

◆ TSparseGrid3() [2/3]

template<typename ElemType >
UE::Geometry::TSparseGrid3< ElemType >::TSparseGrid3 ( const TSparseGrid3< ElemType > &  Other)
delete

◆ TSparseGrid3() [3/3]

template<typename ElemType >
UE::Geometry::TSparseGrid3< ElemType >::TSparseGrid3 ( TSparseGrid3< ElemType > &&  Other)
inlinenoexcept

Member Function Documentation

◆ Allocate()

template<typename ElemType >
ElemType * UE::Geometry::TSparseGrid3< ElemType >::Allocate ( const FVector3i index)
inlineprotected

◆ AllocatedIteration()

template<typename ElemType >
template<typename Func >
void UE::Geometry::TSparseGrid3< ElemType >::AllocatedIteration ( Func  ElementFunc) const
inline

Iterate over existing elements and apply ElementFunc(ElementType) to each of them

◆ Free()

template<typename ElemType >
bool UE::Geometry::TSparseGrid3< ElemType >::Free ( const FVector3i Index)
inline

Delete an element in the grid

Parameters
Indexinteger grid index
Returns
true if the element existed, false if it did not

◆ FreeAll()

template<typename ElemType >
void UE::Geometry::TSparseGrid3< ElemType >::FreeAll ( )
inline

Delete all elements in the grid

◆ Get() [1/2]

template<typename ElemType >
const ElemType * UE::Geometry::TSparseGrid3< ElemType >::Get ( const FVector3i Index) const
inline

Get the grid element at this index

Parameters
Indexinteger grid index
Returns
pointer to ElemType instance, or nullptr if element doesn't exist

◆ Get() [2/2]

template<typename ElemType >
ElemType * UE::Geometry::TSparseGrid3< ElemType >::Get ( const FVector3i Index,
bool  bAllocateIfMissing 
)
inline

Get the grid element at this index, and optionally allocate it if it doesn't exist

Parameters
Indexinteger grid index
bAllocateIfMissingif the element at this index is null, allocate a new one
Returns
pointer to ElemType instance, or nullptr if element doesn't exist

◆ GetBoundsInclusive()

template<typename ElemType >
FAxisAlignedBox3i UE::Geometry::TSparseGrid3< ElemType >::GetBoundsInclusive ( ) const
inline
Returns
integer range of valid grid indices [min,max] (inclusive)

◆ GetCount()

template<typename ElemType >
int UE::Geometry::TSparseGrid3< ElemType >::GetCount ( ) const
inline
Returns
number of allocated elements in the grid

◆ GetDensity()

template<typename ElemType >
float UE::Geometry::TSparseGrid3< ElemType >::GetDensity ( ) const
inline
Returns
ratio of allocated elements to total number of possible cells for current bounds

◆ GetDimensions()

template<typename ElemType >
FVector3i UE::Geometry::TSparseGrid3< ElemType >::GetDimensions ( ) const
inline
Returns
dimensions of grid along each axis

◆ Has()

template<typename ElemType >
bool UE::Geometry::TSparseGrid3< ElemType >::Has ( const FVector3i Index) const
inline
Parameters
Indexan integer grid index
Returns
true if there is an allocated element at this index

◆ operator=() [1/2]

template<typename ElemType >
TSparseGrid3 & UE::Geometry::TSparseGrid3< ElemType >::operator= ( const TSparseGrid3< ElemType > &  Other)
delete

◆ operator=() [2/2]

template<typename ElemType >
TSparseGrid3 & UE::Geometry::TSparseGrid3< ElemType >::operator= ( TSparseGrid3< ElemType > &&  Other)
inlinenoexcept

◆ RangeIteration()

template<typename ElemType >
template<typename Func >
void UE::Geometry::TSparseGrid3< ElemType >::RangeIteration ( FVector3i  MinIndex,
FVector3i  MaxIndex,
Func  ElementFunc 
) const
inline

Iterate over existing allocated elements within the integer bounds defined by Min and Max (inclusive), and apply ElementFunc(ElementType) to each of them

Member Data Documentation

◆ Bounds

template<typename ElemType >
FAxisAlignedBox3i UE::Geometry::TSparseGrid3< ElemType >::Bounds
protected

accumulated bounds of all indices inserted into Elements. Not currently used internally.

◆ Elements

template<typename ElemType >
TMap<FVector3i, ElemType*> UE::Geometry::TSparseGrid3< ElemType >::Elements
protected

sparse grid of allocated elements


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