Navigation
API > API/Runtime > API/Runtime/GeometryCore
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
| Name | TCachingMeshSDF |
| Type | class |
| Header File | /Engine/Source/Runtime/GeometryCore/Public/Implicit/CachingMeshSDF.h |
| Include Path | #include "Implicit/CachingMeshSDF.h" |
Syntax
template<class TriangleMeshType>
class TCachingMeshSDF
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TCachingMeshSDF
(
float CellSizeIn |
Implicit/CachingMeshSDF.h | ||
TCachingMeshSDF
(
const TriangleMeshType* MeshIn, |
Implicit/CachingMeshSDF.h |
Enums
Public
| Name | Remarks |
|---|---|
| EInsideModes | What counts as "inside" the mesh. |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ApproxMaxCellsPerDimension | int | If the number of cells in any dimension may exceed this, CellSize will be automatically increased to keep cell count reasonable. | Implicit/CachingMeshSDF.h | |
| bComputeSigns | bool | Should we try to compute signs? if not, Grid remains unsigned | Implicit/CachingMeshSDF.h | |
| bUseParallel | bool | Most of this parallelizes very well, makes a huge speed difference. | Implicit/CachingMeshSDF.h | |
| bWantClosestTriGrid | bool | Implementation computes the triangle closest to each Grid cell, can return this Grid if desired (only reason not to is avoid hanging onto memory) | Implicit/CachingMeshSDF.h | |
| bWantIntersectionsGrid | bool | Grid of per-cell crossing or parity counts. | Implicit/CachingMeshSDF.h | |
| CancelF | TFunction< bool(void)> | If this function returns true, we should abort calculation | Implicit/CachingMeshSDF.h | |
| CellSize | float | Implicit/CachingMeshSDF.h | ||
| ClosestTriGrid | FDenseGrid3i | Implicit/CachingMeshSDF.h | ||
| ExpandBounds | FVector3d | Bounds of Grid will be expanded this much in positive and negative directions. | Implicit/CachingMeshSDF.h | |
| Grid | FDenseGrid3f | Implicit/CachingMeshSDF.h | ||
| GridOrigin | FVector3f | Implicit/CachingMeshSDF.h | ||
| InsideMode | EInsideModes | Implicit/CachingMeshSDF.h | ||
| IntersectionsGrid | FDenseGrid3i | Implicit/CachingMeshSDF.h | ||
| MaxOffsetDistance | float | Max distance away from surface that we might need to evaluate | Implicit/CachingMeshSDF.h | |
| Mesh | const TriangleMeshType * | Implicit/CachingMeshSDF.h | ||
| Spatial | const TMeshAABBTree3< TriangleMeshType > * | Implicit/CachingMeshSDF.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
float At
(
int I, |
Implicit/CachingMeshSDF.h | ||
FVector3f CellCenter
(
int I, |
Implicit/CachingMeshSDF.h | ||
void CleanupUnwanted() |
Implicit/CachingMeshSDF.h | ||
FVector3i Dimensions() |
Implicit/CachingMeshSDF.h | ||
const FDenseGrid3i & GetClosestTriGrid() |
Implicit/CachingMeshSDF.h | ||
const FDenseGrid3f & GetGrid() |
SDF Grid available after calling Compute() | Implicit/CachingMeshSDF.h | |
const FVector3f & GetGridOrigin() |
Origin of the SDF Grid, in same coordinates as mesh | Implicit/CachingMeshSDF.h | |
const FDenseGrid3i & GetIntersectionsGrid() |
Implicit/CachingMeshSDF.h | ||
float GetValue
(
FVector3i Idx |
Implicit/CachingMeshSDF.h | ||
void Initialize() |
Implicit/CachingMeshSDF.h | ||
TTriLinearGridInterpolant< TCachingMeshSDF > MakeInterpolant() |
Implicit/CachingMeshSDF.h | ||
bool Validate() |
Implicit/CachingMeshSDF.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static int Orientation
(
double X1, |
Calculate twice signed area of triangle (0,0)-(X1,Y1)-(X2,Y2) return an SOS-determined sign (-1, +1, or 0 only if it's a truly degenerate triangle) | Implicit/CachingMeshSDF.h | |
static bool PointInTriangle2d
(
double X0, |
Robust test of (X0,Y0) in the triangle (X1,Y1)-(X2,Y2)-(X3,Y3) if true is returned, the barycentric coordinates are set in A,B,C. | Implicit/CachingMeshSDF.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
const float operator[]
(
FVector3i Idx |
Implicit/CachingMeshSDF.h |