Navigation
API > API/Runtime > API/Runtime/GeometryCore > API/Runtime/GeometryCore/Implicit
References
| Module | GeometryCore |
| Header | /Engine/Source/Runtime/GeometryCore/Public/Implicit/SparseNarrowBandMeshSDF.h |
| Include | #include "Implicit/SparseNarrowBandMeshSDF.h" |
Syntax
template<class TriangleMeshType>
class TSparseNarrowBandMeshSDF
Remarks
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
Variables
| Type | Name | Description | |
|---|---|---|---|
| int | ApproxMaxCellsPerDimension | If the number of cells in any dimension may exceed this, CellSize will be automatically increased to keep cell count reasonable. | |
| bool | bComputeSigns | If true, sign of full grid will be computed using either IsInsideFunction (if provided) or crossing as controlled by the InsideMode. | |
| bool | bUseParallel | Most of this parallelizes very well, makes a huge speed difference. | |
| bool | bWantClosestTriGrid | Implementation computes the triangle closest to each Grid cell, can return this Grid if desired (only reason not to is avoid hanging onto memory) | |
| bool | bWantIntersectionsGrid | Grid of per-cell crossing or parity counts. | |
| TFunction< bool()> | CancelF | If this function returns true, the calculation will abort | |
| float | CellSize | Relates the grids index space, to mesh distance units. | |
| FBlockedGrid3i | ClosestTriGrid | Grid of closest triangle indices; only available if bWantClosestTriGrid is set to true. Access via GetClosestTriGrid() | |
| EComputeModes | ComputeMode | ||
| int | ExactBandWidth | Width of the band around triangles for which exact Distances are computed (In fact this is conservative, the band is often larger locally) | |
| FVector3d | ExpandBounds | Bounds of Grid will be expanded this much in positive and negative directions. | |
| FBlockedGrid3f | Grid | ||
| FVector3f | GridOrigin | ||
| EInsideModes | InsideMode | ||
| FBlockedGrid3i | IntersectionsGrid | Grid of intersection counts; only available if bWantIntersectionsGrid is set to true. Access via GetIntersectionsGrid() | |
| TUniqueFunction< bool(const FVector3d &)> | IsInsideFunction | ||
| const TriangleMeshType * | Mesh | ||
| double | NarrowBandMaxDistance | How wide of narrow band should we compute. | |
| TMeshAABBTree3< TriangleMeshType > * | Spatial |
Constructors
| Type | Name | Description | |
|---|---|---|---|
TSparseNarrowBandMeshSDF
(
const TriangleMeshType* Mesh, |
Functions
| Type | Name | Description | |
|---|---|---|---|
| float | At
(
int32 I, |
||
| FVector3f | CellCenter
(
int32 I, |
||
| bool | Compute
(
FAxisAlignedBox3d Bounds |
Compute the SDF | |
| FVector3i | Dimensions () |
||
| const FBlockedGrid3i & | |||
| const FBlockedGrid3i & | |||
| float | |||
| TTriLinearGridInterpolant< TSparseNarrowBandMeshSDF > | |||
| bool | ShouldUseSpatial
(
int32 ExactCells, |
Encodes heuristic for deciding whether it will be faster to use | |
| bool | Validate
(
const FAxisAlignedBox3d& Bounds |
Operators
| Type | Name | Description | |
|---|---|---|---|
| float | operator[]
(
const FVector3i& ijk |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FScatterCounter | Grid that holds one atomic |
||
| FTriBBox | |||
| FTriIDBlockGrid | Sparse grid that stores array of TriIDs each blocks. |
Enums
| Type | Name | Description | |
|---|---|---|---|
| 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. |