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

#include <CachingMeshSDF.h>

Public Types

enum  EInsideModes { CrossingCount = 0 , WindingCount = 1 }
 

Public Member Functions

 TCachingMeshSDF (float CellSizeIn=10)
 
 TCachingMeshSDF (const TriangleMeshType *MeshIn, float CellSizeIn, const TMeshAABBTree3< TriangleMeshType > *SpatialIn, bool bAutoBuild)
 
bool Validate ()
 
void Initialize ()
 
void CleanupUnwanted ()
 
float GetValue (FVector3i Idx)
 
TTriLinearGridInterpolant< TCachingMeshSDFMakeInterpolant ()
 
FVector3i Dimensions ()
 
const FDenseGrid3fGetGrid () const
 
const FVector3fGetGridOrigin () const
 
const FDenseGrid3iGetClosestTriGrid () const
 
const FDenseGrid3iGetIntersectionsGrid () const
 
float At (int I, int J, int K) const
 
constexpr const float operator[] (FVector3i Idx) const
 
FVector3f CellCenter (int I, int J, int K)
 

Static Public Member Functions

static int Orientation (double X1, double Y1, double X2, double Y2, double &TwiceSignedArea)
 
static bool PointInTriangle2d (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3, double &A, double &B, double &C)
 

Public Attributes

const TriangleMeshTypeMesh
 
const TMeshAABBTree3< TriangleMeshType > * Spatial
 
float CellSize
 
FVector3d ExpandBounds = FVector3d::Zero()
 
float MaxOffsetDistance = 0
 
bool bUseParallel = true
 
bool bComputeSigns = true
 
int ApproxMaxCellsPerDimension = 4096
 
EInsideModes InsideMode = EInsideModes::WindingCount
 
bool bWantClosestTriGrid = false
 
bool bWantIntersectionsGrid = false
 
TFunction< bool(void)> CancelF = []() { return false; }
 
FVector3f GridOrigin
 
FDenseGrid3f Grid
 
FDenseGrid3i ClosestTriGrid
 
FDenseGrid3i IntersectionsGrid
 

Protected Attributes

float UpperBoundDistance
 
double MaxDistQueryDist
 

Detailed Description

template<class TriangleMeshType>
class UE::Geometry::TCachingMeshSDF< TriangleMeshType >

This is variant of TSweepingMeshSDF that does lazy evaluation of actual Distances, using mesh spatial data structure. This is much faster if we are doing continuation-method marching cubes as only values on surface will be computed!

Compute discretely-sampled (I.e. gridded) signed distance field for a mesh only within a narrow band of the surface (within MaxDistQueryDist = MaxOffsetDistance + (2 * CellSize * FMathf::Sqrt2))

This code is based on the implementation found at https://github.com/christopherbatty/SDFGen

Member Enumeration Documentation

◆ EInsideModes

Enumerator
CrossingCount 
WindingCount 

Constructor & Destructor Documentation

◆ TCachingMeshSDF() [1/2]

template<class TriangleMeshType >
UE::Geometry::TCachingMeshSDF< TriangleMeshType >::TCachingMeshSDF ( float  CellSizeIn = 10)
inline

◆ TCachingMeshSDF() [2/2]

template<class TriangleMeshType >
UE::Geometry::TCachingMeshSDF< TriangleMeshType >::TCachingMeshSDF ( const TriangleMeshType MeshIn,
float  CellSizeIn,
const TMeshAABBTree3< TriangleMeshType > *  SpatialIn,
bool  bAutoBuild 
)
inline

Member Function Documentation

◆ At()

template<class TriangleMeshType >
float UE::Geometry::TCachingMeshSDF< TriangleMeshType >::At ( int  I,
int  J,
int  K 
) const
inline

◆ CellCenter()

template<class TriangleMeshType >
FVector3f UE::Geometry::TCachingMeshSDF< TriangleMeshType >::CellCenter ( int  I,
int  J,
int  K 
)
inline

◆ CleanupUnwanted()

template<class TriangleMeshType >
void UE::Geometry::TCachingMeshSDF< TriangleMeshType >::CleanupUnwanted ( )
inline

◆ Dimensions()

template<class TriangleMeshType >
FVector3i UE::Geometry::TCachingMeshSDF< TriangleMeshType >::Dimensions ( )
inline

◆ GetClosestTriGrid()

template<class TriangleMeshType >
const FDenseGrid3i & UE::Geometry::TCachingMeshSDF< TriangleMeshType >::GetClosestTriGrid ( ) const
inline

◆ GetGrid()

template<class TriangleMeshType >
const FDenseGrid3f & UE::Geometry::TCachingMeshSDF< TriangleMeshType >::GetGrid ( ) const
inline

SDF Grid available after calling Compute()

◆ GetGridOrigin()

template<class TriangleMeshType >
const FVector3f & UE::Geometry::TCachingMeshSDF< TriangleMeshType >::GetGridOrigin ( ) const
inline

Origin of the SDF Grid, in same coordinates as mesh

◆ GetIntersectionsGrid()

template<class TriangleMeshType >
const FDenseGrid3i & UE::Geometry::TCachingMeshSDF< TriangleMeshType >::GetIntersectionsGrid ( ) const
inline

◆ GetValue()

template<class TriangleMeshType >
float UE::Geometry::TCachingMeshSDF< TriangleMeshType >::GetValue ( FVector3i  Idx)
inline

◆ Initialize()

template<class TriangleMeshType >
void UE::Geometry::TCachingMeshSDF< TriangleMeshType >::Initialize ( )
inline

◆ MakeInterpolant()

◆ operator[]()

template<class TriangleMeshType >
constexpr const float UE::Geometry::TCachingMeshSDF< TriangleMeshType >::operator[] ( FVector3i  Idx) const
inlineconstexpr

◆ Orientation()

template<class TriangleMeshType >
static int UE::Geometry::TCachingMeshSDF< TriangleMeshType >::Orientation ( double  X1,
double  Y1,
double  X2,
double  Y2,
double TwiceSignedArea 
)
inlinestatic

◆ PointInTriangle2d()

template<class TriangleMeshType >
static bool UE::Geometry::TCachingMeshSDF< TriangleMeshType >::PointInTriangle2d ( double  X0,
double  Y0,
double  X1,
double  Y1,
double  X2,
double  Y2,
double  X3,
double  Y3,
double A,
double B,
double C 
)
inlinestatic

◆ Validate()

template<class TriangleMeshType >
bool UE::Geometry::TCachingMeshSDF< TriangleMeshType >::Validate ( )
inline

Member Data Documentation

◆ ApproxMaxCellsPerDimension

template<class TriangleMeshType >
int UE::Geometry::TCachingMeshSDF< TriangleMeshType >::ApproxMaxCellsPerDimension = 4096

◆ bComputeSigns

◆ bUseParallel

◆ bWantClosestTriGrid

template<class TriangleMeshType >
bool UE::Geometry::TCachingMeshSDF< TriangleMeshType >::bWantClosestTriGrid = false

◆ bWantIntersectionsGrid

template<class TriangleMeshType >
bool UE::Geometry::TCachingMeshSDF< TriangleMeshType >::bWantIntersectionsGrid = false

◆ CancelF

template<class TriangleMeshType >
TFunction<bool(void)> UE::Geometry::TCachingMeshSDF< TriangleMeshType >::CancelF = []() { return false; }

if this function returns true, we should abort calculation

◆ CellSize

◆ ClosestTriGrid

◆ ExpandBounds

◆ Grid

◆ GridOrigin

◆ InsideMode

◆ IntersectionsGrid

◆ MaxDistQueryDist

template<class TriangleMeshType >
double UE::Geometry::TCachingMeshSDF< TriangleMeshType >::MaxDistQueryDist
protected

◆ MaxOffsetDistance

template<class TriangleMeshType >
float UE::Geometry::TCachingMeshSDF< TriangleMeshType >::MaxOffsetDistance = 0

◆ Mesh

◆ Spatial

◆ UpperBoundDistance

template<class TriangleMeshType >
float UE::Geometry::TCachingMeshSDF< TriangleMeshType >::UpperBoundDistance
protected

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