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

#include <MarchingCubes.h>

+ Inheritance diagram for UE::Geometry::FMarchingCubes:

Classes

struct  FGridCell
 
struct  FIndexedVertex
 

Public Member Functions

 FMarchingCubes ()
 
virtual ~FMarchingCubes ()
 
bool Validate ()
 
FMeshShapeGeneratorGenerate () override
 
FMeshShapeGeneratorGenerateContinuation (TArrayView< const FVector3d > Seeds)
 
- Public Member Functions inherited from UE::Geometry::FMeshShapeGenerator
virtual ~FMeshShapeGenerator ()
 
bool HasAttributes () const
 
void ResetAttributes (bool bResetPolygonIDs=false)
 
void Reset ()
 
void SetBufferSizes (int NumVertices, int NumTriangles, int NumUVs, int NumNormals)
 
void ExtendBufferSizes (int AddVertices, int AddTriangles, int AddUVs, int AddNormals)
 
void SetVertex (int Index, const FVector3d &Position)
 
int AppendVertex (const FVector3d &Position)
 
void SetUV (int Index, const FVector2f &UV, int ParentVertex)
 
int AppendUV (const FVector2f &UV, int ParentVertex)
 
void SetNormal (int Index, const FVector3f &Normal, int ParentVertex)
 
int AppendNormal (const FVector3f &Normal, int ParentVertex)
 
void SetTriangle (int Index, const FIndex3i &Tri)
 
void SetTriangle (int Index, int A, int B, int C)
 
void SetTriangle (int Index, int A, int B, int C, bool bClockwiseOverride)
 
int AppendTriangle (int A, int B, int C)
 
void SetTriangleUVs (int Index, const FIndex3i &Tri)
 
void SetTriangleUVs (int Index, int A, int B, int C)
 
void SetTriangleUVs (int Index, int A, int B, int C, bool bClockwiseOverride)
 
void SetTriangleNormals (int Index, const FIndex3i &Tri)
 
void SetTriangleNormals (int Index, int A, int B, int C)
 
void SetTriangleNormals (int Index, int A, int B, int C, bool bClockwiseOverride)
 
void SetTrianglePolygon (int Index, int PolygonID)
 
void SetTriangleWithMatchedUVNormal (int Index, int A, int B, int C)
 

Public Attributes

TFunction< double(TVector< double >)> Implicit
 
double IsoValue = 0
 
TAxisAlignedBox3< doubleBounds
 
double CubeSize = 0.1
 
bool bParallelCompute = true
 
bool bEnableValueCaching = true
 
int SafetyMaxDimension = 4096
 
ERootfindingModes RootMode = ERootfindingModes::SingleLerp
 
int RootModeSteps = 5
 
TFunction< bool(void)> CancelF = []() { return false; }
 
FVector3i CellDimensions
 
- Public Attributes inherited from UE::Geometry::FMeshShapeGenerator
TArray< FVector3dVertices
 
TArray< FVector2fUVs
 
TArray< int > UVParentVertex
 
TArray< FVector3fNormals
 
TArray< int > NormalParentVertex
 
TArray< FIndex3iTriangles
 
TArray< FIndex3iTriangleUVs
 
TArray< FIndex3iTriangleNormals
 
TArray< int > TrianglePolygonIDs
 
bool bReverseOrientation = false
 

Protected Member Functions

void SetDimensions ()
 
void corner_pos (const FVector3i &IJK, TVector< double > &Pos)
 
TVector< doublecorner_pos (const FVector3i &IJK)
 
FVector3i cell_index (const TVector< double > &Pos)
 
int64 corner_hash (const FVector3i &Idx)
 
int64 corner_hash (int X, int Y, int Z)
 
int64 edge_hash (const FVector3i &Idx1, const FVector3i &Idx2)
 
int FindVertexID (int64 hash)
 
int AppendOrFindVertexID (int64 hash, TVector< double > Pos)
 
int edge_vertex_id (const FVector3i &Idx1, const FVector3i &Idx2, double F1, double F2)
 
double corner_value_grid_parallel (const FVector3i &Idx)
 
double corner_value_grid (const FVector3i &Idx)
 
void initialize_cell_values_grid (FGridCell &Cell, bool Shift)
 
double corner_value_nohash (const FVector3i &Idx)
 
void initialize_cell_values_nohash (FGridCell &Cell, bool Shift)
 
void initialize_cell (FGridCell &Cell, const FVector3i &Idx)
 
void shift_cell_x (FGridCell &Cell, int XIdx)
 
void InitHashTables ()
 
void generate_parallel ()
 
void generate_basic ()
 
void generate_continuation (TArrayView< const FVector3d > Seeds)
 
void generate_continuation_parallel (TArrayView< const FVector3d > Seeds)
 
bool set_cell_if_not_done (const FVector3i &Idx)
 
bool polygonize_cell (FGridCell &Cell, int VertIndexArray[])
 
int GetVertexSectionIndex (int64 hash)
 
int append_vertex (TVector< double > V, int64 CellHash)
 
int GetTriangleSectionIndex (int64 hash)
 
void append_triangle (int A, int B, int C, int64 CellHash)
 
void ResetMesh ()
 
void BuildMesh ()
 
void find_iso (const TVector< double > &P1, const TVector< double > &P2, double ValP1, double ValP2, TVector< double > &PIso)
 

Protected Attributes

FAxisAlignedBox3i GridBounds
 
FAxisAlignedBox3i LastGridBounds
 
const int64 EDGE_X = int64(1) << 60
 
const int64 EDGE_Y = int64(1) << 61
 
const int64 EDGE_Z = int64(1) << 62
 
const int64 NumEdgeVertexSections = 64
 
TArray< TMap< int64, int > > EdgeVertexSections
 
TArray< FCriticalSectionEdgeVertexSectionLocks
 
FBlockedDenseGrid3f BlockedCornerValuesGrid
 
bool parallel_mesh_access = false
 
FBlockedDenseGrid3i BlockedDoneCells
 
std::atomic< int32VertexCounter
 
int64 NumVertexSections = 64
 
TArray< FCriticalSectionVertexSectionLocks
 
TArray< TArray< FIndexedVertex > > VertexSectionLists
 
int64 NumTriangleSections = 64
 
TArray< FCriticalSectionTriangleSectionLocks
 
TArray< TArray< FIndex3i > > TriangleSectionLists
 

Static Protected Attributes

static GEOMETRYCORE_API const uint8 EdgeIndices [12][2]
 
static GEOMETRYCORE_API const uint16 EdgeTable [256]
 
static GEOMETRYCORE_API const uint64 TriTable [256]
 

Additional Inherited Members

- Static Public Member Functions inherited from UE::Geometry::FMeshShapeGenerator
static FVector3d BilinearInterp (const FVector3d &v00, const FVector3d &v10, const FVector3d &v11, const FVector3d &v01, double tx, double ty)
 
static FVector2d BilinearInterp (const FVector2d &v00, const FVector2d &v10, const FVector2d &v11, const FVector2d &v01, double tx, double ty)
 
static FVector2f BilinearInterp (const FVector2f &v00, const FVector2f &v10, const FVector2f &v11, const FVector2f &v01, float tx, float ty)
 
static FVector3i LinearInterp (const FVector3i &a, const FVector3i &b, double t)
 

Constructor & Destructor Documentation

◆ FMarchingCubes()

UE::Geometry::FMarchingCubes::FMarchingCubes ( )
inline

◆ ~FMarchingCubes()

virtual UE::Geometry::FMarchingCubes::~FMarchingCubes ( )
inlinevirtual

Member Function Documentation

◆ append_triangle()

void UE::Geometry::FMarchingCubes::append_triangle ( int  A,
int  B,
int  C,
int64  CellHash 
)
inlineprotected

add triangle to mesh, with locking if we are computing in parallel

◆ append_vertex()

int UE::Geometry::FMarchingCubes::append_vertex ( TVector< double V,
int64  CellHash 
)
inlineprotected

add vertex to mesh, with locking if we are computing in parallel

◆ AppendOrFindVertexID()

int UE::Geometry::FMarchingCubes::AppendOrFindVertexID ( int64  hash,
TVector< double Pos 
)
inlineprotected

◆ BuildMesh()

void UE::Geometry::FMarchingCubes::BuildMesh ( )
inlineprotected

Populate FMeshShapeGenerator data structures from accumulated vertex/triangle sets

◆ cell_index()

FVector3i UE::Geometry::FMarchingCubes::cell_index ( const TVector< double > &  Pos)
inlineprotected

◆ corner_hash() [1/2]

int64 UE::Geometry::FMarchingCubes::corner_hash ( const FVector3i Idx)
inlineprotected

◆ corner_hash() [2/2]

int64 UE::Geometry::FMarchingCubes::corner_hash ( int  X,
int  Y,
int  Z 
)
inlineprotected

◆ corner_pos() [1/2]

TVector< double > UE::Geometry::FMarchingCubes::corner_pos ( const FVector3i IJK)
inlineprotected

◆ corner_pos() [2/2]

void UE::Geometry::FMarchingCubes::corner_pos ( const FVector3i IJK,
TVector< double > &  Pos 
)
inlineprotected

◆ corner_value_grid()

double UE::Geometry::FMarchingCubes::corner_value_grid ( const FVector3i Idx)
inlineprotected

◆ corner_value_grid_parallel()

double UE::Geometry::FMarchingCubes::corner_value_grid_parallel ( const FVector3i Idx)
inlineprotected

◆ corner_value_nohash()

double UE::Geometry::FMarchingCubes::corner_value_nohash ( const FVector3i Idx)
inlineprotected

◆ edge_hash()

int64 UE::Geometry::FMarchingCubes::edge_hash ( const FVector3i Idx1,
const FVector3i Idx2 
)
inlineprotected

◆ edge_vertex_id()

int UE::Geometry::FMarchingCubes::edge_vertex_id ( const FVector3i Idx1,
const FVector3i Idx2,
double  F1,
double  F2 
)
inlineprotected

◆ find_iso()

void UE::Geometry::FMarchingCubes::find_iso ( const TVector< double > &  P1,
const TVector< double > &  P2,
double  ValP1,
double  ValP2,
TVector< double > &  PIso 
)
inlineprotected

root-find the intersection along edge from f(P1)=ValP1 to f(P2)=ValP2

◆ FindVertexID()

int UE::Geometry::FMarchingCubes::FindVertexID ( int64  hash)
inlineprotected

◆ Generate()

FMeshShapeGenerator & UE::Geometry::FMarchingCubes::Generate ( )
inlineoverridevirtual

Run MC algorithm and generate Output mesh

Implements UE::Geometry::FMeshShapeGenerator.

◆ generate_basic()

void UE::Geometry::FMarchingCubes::generate_basic ( )
inlineprotected

fully sequential version, no threading

◆ generate_continuation()

void UE::Geometry::FMarchingCubes::generate_continuation ( TArrayView< const FVector3d Seeds)
inlineprotected

fully sequential version, no threading

◆ generate_continuation_parallel()

void UE::Geometry::FMarchingCubes::generate_continuation_parallel ( TArrayView< const FVector3d Seeds)
inlineprotected

parallel seed evaluation

◆ generate_parallel()

void UE::Geometry::FMarchingCubes::generate_parallel ( )
inlineprotected

processing z-slabs of cells in parallel

◆ GenerateContinuation()

FMeshShapeGenerator & UE::Geometry::FMarchingCubes::GenerateContinuation ( TArrayView< const FVector3d Seeds)
inline

◆ GetTriangleSectionIndex()

int UE::Geometry::FMarchingCubes::GetTriangleSectionIndex ( int64  hash)
inlineprotected

◆ GetVertexSectionIndex()

int UE::Geometry::FMarchingCubes::GetVertexSectionIndex ( int64  hash)
inlineprotected

◆ InitHashTables()

void UE::Geometry::FMarchingCubes::InitHashTables ( )
inlineprotected

◆ initialize_cell()

void UE::Geometry::FMarchingCubes::initialize_cell ( FGridCell Cell,
const FVector3i Idx 
)
inlineprotected

compute 3D corner-positions and field values for cell at index

◆ initialize_cell_values_grid()

void UE::Geometry::FMarchingCubes::initialize_cell_values_grid ( FGridCell Cell,
bool  Shift 
)
inlineprotected

◆ initialize_cell_values_nohash()

void UE::Geometry::FMarchingCubes::initialize_cell_values_nohash ( FGridCell Cell,
bool  Shift 
)
inlineprotected

◆ polygonize_cell()

bool UE::Geometry::FMarchingCubes::polygonize_cell ( FGridCell Cell,
int  VertIndexArray[] 
)
inlineprotected

find edge crossings and generate triangles for this cell

◆ ResetMesh()

void UE::Geometry::FMarchingCubes::ResetMesh ( )
inlineprotected

Reset internal mesh-assembly data structures

◆ set_cell_if_not_done()

bool UE::Geometry::FMarchingCubes::set_cell_if_not_done ( const FVector3i Idx)
inlineprotected

◆ SetDimensions()

void UE::Geometry::FMarchingCubes::SetDimensions ( )
inlineprotected

◆ shift_cell_x()

void UE::Geometry::FMarchingCubes::shift_cell_x ( FGridCell Cell,
int  XIdx 
)
inlineprotected

◆ Validate()

bool UE::Geometry::FMarchingCubes::Validate ( )
inline

Member Data Documentation

◆ bEnableValueCaching

bool UE::Geometry::FMarchingCubes::bEnableValueCaching = true

If true, code will assume that Implicit() is expensive enough that it is worth it to cache evaluations when possible. For something simple like evaluation of an SDF defined by a discrete grid, this is generally not worth the overhead.

◆ BlockedCornerValuesGrid

FBlockedDenseGrid3f UE::Geometry::FMarchingCubes::BlockedCornerValuesGrid
protected

◆ BlockedDoneCells

FBlockedDenseGrid3i UE::Geometry::FMarchingCubes::BlockedDoneCells
protected

◆ Bounds

TAxisAlignedBox3<double> UE::Geometry::FMarchingCubes::Bounds

bounding-box we will mesh inside of. We use the min-corner and the width/height/depth, but do not clamp vertices to stay within max-corner, we may spill one cell over

◆ bParallelCompute

bool UE::Geometry::FMarchingCubes::bParallelCompute = true

Use multi-threading? Generally a good idea unless problem is very small or you are multi-threading at a higher level (which may be more efficient)

◆ CancelF

TFunction<bool(void)> UE::Geometry::FMarchingCubes::CancelF = []() { return false; }

if this function returns true, we should abort calculation

◆ CellDimensions

FVector3i UE::Geometry::FMarchingCubes::CellDimensions

◆ CubeSize

double UE::Geometry::FMarchingCubes::CubeSize = 0.1

Length of edges of cubes that are marching. currently, # of cells along axis = (int)(bounds_dimension / CellSize) + 1

◆ EDGE_X

const int64 UE::Geometry::FMarchingCubes::EDGE_X = int64(1) << 60
protected

◆ EDGE_Y

const int64 UE::Geometry::FMarchingCubes::EDGE_Y = int64(1) << 61
protected

◆ EDGE_Z

const int64 UE::Geometry::FMarchingCubes::EDGE_Z = int64(1) << 62
protected

◆ EdgeIndices

const uint8 FMarchingCubes::EdgeIndices
staticprotected
Initial value:
=
{
{0,1}, {1,2}, {2,3}, {3,0}, {4,5}, {5,6}, {6,7}, {7,4}, {0,4}, {1,5}, {2,6}, {3,7}
}

◆ EdgeTable

const uint16 FMarchingCubes::EdgeTable
staticprotected

◆ EdgeVertexSectionLocks

TArray<FCriticalSection> UE::Geometry::FMarchingCubes::EdgeVertexSectionLocks
protected

◆ EdgeVertexSections

TArray<TMap<int64, int> > UE::Geometry::FMarchingCubes::EdgeVertexSections
protected

◆ GridBounds

FAxisAlignedBox3i UE::Geometry::FMarchingCubes::GridBounds
protected

◆ Implicit

TFunction<double(TVector<double>)> UE::Geometry::FMarchingCubes::Implicit

this is the function we will evaluate

◆ IsoValue

double UE::Geometry::FMarchingCubes::IsoValue = 0

mesh surface will be at this isovalue. Normally 0 unless you want offset surface or field is not a distance-field.

◆ LastGridBounds

FAxisAlignedBox3i UE::Geometry::FMarchingCubes::LastGridBounds
protected

◆ NumEdgeVertexSections

const int64 UE::Geometry::FMarchingCubes::NumEdgeVertexSections = 64
protected

◆ NumTriangleSections

int64 UE::Geometry::FMarchingCubes::NumTriangleSections = 64
protected

◆ NumVertexSections

int64 UE::Geometry::FMarchingCubes::NumVertexSections = 64
protected

◆ parallel_mesh_access

bool UE::Geometry::FMarchingCubes::parallel_mesh_access = false
protected

◆ RootMode

ERootfindingModes UE::Geometry::FMarchingCubes::RootMode = ERootfindingModes::SingleLerp

Which rootfinding method will be used to converge on surface along edges

◆ RootModeSteps

int UE::Geometry::FMarchingCubes::RootModeSteps = 5

number of iterations of rootfinding method (ignored for SingleLerp)

◆ SafetyMaxDimension

int UE::Geometry::FMarchingCubes::SafetyMaxDimension = 4096

Max number of cells on any dimension; if exceeded, CubeSize will be automatically increased to fix

◆ TriangleSectionLists

TArray<TArray<FIndex3i> > UE::Geometry::FMarchingCubes::TriangleSectionLists
protected

◆ TriangleSectionLocks

TArray<FCriticalSection> UE::Geometry::FMarchingCubes::TriangleSectionLocks
protected

◆ TriTable

const uint64 FMarchingCubes::TriTable
staticprotected

◆ VertexCounter

std::atomic<int32> UE::Geometry::FMarchingCubes::VertexCounter
protected

◆ VertexSectionLists

TArray<TArray<FIndexedVertex> > UE::Geometry::FMarchingCubes::VertexSectionLists
protected

◆ VertexSectionLocks

TArray<FCriticalSection> UE::Geometry::FMarchingCubes::VertexSectionLocks
protected

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