Navigation
API > API/Runtime > API/Runtime/GeometryCore
Compute discretely-sampled (ie gridded) signed distance field for a mesh within a specified narrow band.
The basic approach is, first compute exact Distances in a narrow band, and then The resulting unsigned Grid is then signed using ray-intersection counting, which is also computed on the Grid, so no BVH is necessary
The underlying grid data structures are blocked grids where spatial blocks are allocated as needed, so the memory footprint will generally be much lower than the TSweepingMeshSDF, or TCachingMeshSDF. But if distances in the full grid domain are desired (not just a narrow band), then the TSweepingMeshSDF should be used.
You can optionally provide a spatial data structure to allow faster computation of narrow-band Distances; this is most beneficial if we want a wider band
Caveats:
- the "narrow band" is based on triangle bounding boxes, so it is not necessarily that "narrow" if you have large triangles on a diagonal to Grid axes
This code is based on the implementation found at https://github.com/christopherbatty/SDFGen
| Name | TSparseNarrowBandMeshSDF |
| Type | class |
| Header File | /Engine/Source/Runtime/GeometryCore/Public/Implicit/SparseNarrowBandMeshSDF.h |
| Include Path | #include "Implicit/SparseNarrowBandMeshSDF.h" |
Syntax
template<class TriangleMeshType>
class TSparseNarrowBandMeshSDF
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSparseNarrowBandMeshSDF
(
const TriangleMeshType* Mesh, |
Implicit/SparseNarrowBandMeshSDF.h |
Structs
| Name | Remarks |
|---|---|
| FScatterCounter | Grid that holds one atomic |
| FTriBBox | |
| FTriIDBlockGrid | Sparse grid that stores array of TriIDs each blocks. |
Enums
Public
| Name | Remarks |
|---|---|
| EComputeModes | The narrow band is always computed exactly, and the full Grid will be signed if bComputeSigns is true. |
| 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/SparseNarrowBandMeshSDF.h | |
| bComputeSigns | bool | If true, sign of full grid will be computed using either IsInsideFunction (if provided) or crossing as controlled by the InsideMode. | Implicit/SparseNarrowBandMeshSDF.h | |
| bUseParallel | bool | Most of this parallelizes very well, makes a huge speed difference. | Implicit/SparseNarrowBandMeshSDF.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/SparseNarrowBandMeshSDF.h | |
| bWantIntersectionsGrid | bool | Grid of per-cell crossing or parity counts. | Implicit/SparseNarrowBandMeshSDF.h | |
| CancelF | TFunction< bool()> | If this function returns true, the calculation will abort | Implicit/SparseNarrowBandMeshSDF.h | |
| CellSize | float | Relates the grids index space, to mesh distance units. | Implicit/SparseNarrowBandMeshSDF.h | |
| ComputeMode | EComputeModes | Implicit/SparseNarrowBandMeshSDF.h | ||
| ExactBandWidth | int | Width of the band around triangles for which exact Distances are computed (In fact this is conservative, the band is often larger locally) | Implicit/SparseNarrowBandMeshSDF.h | |
| ExpandBounds | FVector3d | Bounds of Grid will be expanded this much in positive and negative directions. | Implicit/SparseNarrowBandMeshSDF.h | |
| Grid | FBlockedGrid3f | Implicit/SparseNarrowBandMeshSDF.h | ||
| GridOrigin | FVector3f | Implicit/SparseNarrowBandMeshSDF.h | ||
| InsideMode | EInsideModes | Implicit/SparseNarrowBandMeshSDF.h | ||
| IsInsideFunction | TUniqueFunction< bool(const FVector3d &)> | Implicit/SparseNarrowBandMeshSDF.h | ||
| Mesh | const TriangleMeshType * | Implicit/SparseNarrowBandMeshSDF.h | ||
| NarrowBandMaxDistance | double | How wide of narrow band should we compute. | Implicit/SparseNarrowBandMeshSDF.h | |
| Spatial | TMeshAABBTree3< TriangleMeshType > * | Implicit/SparseNarrowBandMeshSDF.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
float At
(
int32 I, |
Implicit/SparseNarrowBandMeshSDF.h | ||
FVector3f CellCenter
(
int32 I, |
Implicit/SparseNarrowBandMeshSDF.h | ||
bool Compute
(
FAxisAlignedBox3d Bounds |
Compute the SDF | Implicit/SparseNarrowBandMeshSDF.h | |
FVector3i Dimensions() |
Implicit/SparseNarrowBandMeshSDF.h | ||
const FBlockedGrid3i & GetClosestTriGrid() |
Implicit/SparseNarrowBandMeshSDF.h | ||
const FBlockedGrid3i & GetIntersectionsGrid() |
Implicit/SparseNarrowBandMeshSDF.h | ||
float GetValue
(
const FVector3i& ijk |
Implicit/SparseNarrowBandMeshSDF.h | ||
TTriLinearGridInterpolant< TSparseNarrowBandMeshSDF > MakeInterpolant() |
Implicit/SparseNarrowBandMeshSDF.h | ||
bool Validate
(
const FAxisAlignedBox3d& Bounds |
Implicit/SparseNarrowBandMeshSDF.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static bool ShouldUseSpatial
(
int32 ExactCells, |
Encodes heuristic for deciding whether it will be faster to use | Implicit/SparseNarrowBandMeshSDF.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
float operator[]
(
const FVector3i& ijk |
Implicit/SparseNarrowBandMeshSDF.h |