![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <SweepingMeshSDF.h>
Public Types | |
| enum | EComputeModes { FullGrid = 0 , NarrowBandOnly = 1 , NarrowBand_SpatialFloodFill = 2 } |
| enum | EInsideModes { CrossingCount = 0 , WindingCount = 1 } |
| using | CellSizeType = std::conditional_t< bScalarCellSize, float, FVector3f > |
| using | CellSizeTyped = std::conditional_t< bScalarCellSize, double, FVector3d > |
Public Member Functions | |
| void | SetCellSize (float InCellSize) |
| TSweepingMeshSDF (const TriangleMeshType *Mesh=nullptr, CellSizeType InCellSize=UnitCellSize(), TMeshAABBTree3< TriangleMeshType > *Spatial=nullptr) | |
| void | Empty () |
| template<typename InterpolantRealType = double> | |
| TTriLinearGridInterpolant< FDenseGrid3f, InterpolantRealType, bScalarCellSize > | MakeInterpolant () |
| bool | Validate (const FAxisAlignedBox3d &Bounds) |
| bool | Compute (FAxisAlignedBox3d Bounds) |
| bool | Compute (FVector3f InGridOrigin, FVector3i InDimensions) |
| FVector3i | Dimensions () const |
| const FDenseGrid3i & | GetClosestTriGrid () const |
| const FDenseGrid3i & | GetIntersectionsGrid () const |
| float | At (int I, int J, int K) const |
| float | operator[] (const FVector3i &Idx) const |
| FVector3f | CellCenter (int I, int J, int K) const |
| float | GetValue (FVector3i Idx) const |
Public Attributes | |
| const TriangleMeshType * | Mesh |
| TMeshAABBTree3< TriangleMeshType > * | Spatial |
| CellSizeType | CellSize |
| int | ExactBandWidth = 1 |
| FVector3d | ExpandBounds = FVector3d::Zero() |
| bool | bUseParallel = true |
| int | ApproxMaxCellsPerDimension = 4096 |
| EComputeModes | ComputeMode = EComputeModes::NarrowBandOnly |
| double | NarrowBandMaxDistance = 0 |
| bool | bComputeSigns = true |
| EInsideModes | InsideMode = EInsideModes::WindingCount |
| bool | bWantClosestTriGrid = false |
| bool | bWantIntersectionsGrid = false |
| TFunction< bool()> | CancelF |
| FVector3f | GridOrigin |
| FDenseGrid3f | Grid |
Protected Attributes | |
| FDenseGrid3i | ClosestTriGrid |
| FDenseGrid3i | IntersectionsGrid |
Compute discretely-sampled (ie gridded) signed distance field for a mesh The basic approach is, first compute exact Distances in a narrow band, and then extend out to rest of Grid using fast "sweeping" (ie like a distance transform). The resulting unsigned Grid is then signed using ray-intersection counting, which is also computed on the Grid, so no BVH is necessary
If you set ComputeMode to NarrowBandOnly, result is a narrow-band signed distance field. This is quite a bit faster as the sweeping is the most computationally-intensive step.
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:
TODO: a number of utility function could & should be shared between this and CachingMeshSDF!
This code is based on the implementation found at https://github.com/christopherbatty/SDFGen
| using UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::CellSizeType = std::conditional_t<bScalarCellSize, float, FVector3f> |
| using UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::CellSizeTyped = std::conditional_t<bScalarCellSize, double, FVector3d> |
| enum UE::Geometry::TSweepingMeshSDF::EComputeModes |
| enum UE::Geometry::TSweepingMeshSDF::EInsideModes |
|
inline |
| Mesh | Triangle mesh to build an SDF around |
| InCellSize | Spacing between Grid points |
| Spatial | Optional AABB tree; note it must be provided if ComputeMode is set to NarrowBand_SpatialFloodFill |
|
inline |
|
inline |
|
inline |
Compute the SDF enclosing the given bounds, with a 'safe' buffer zone
| Bounds | Bounding box for the mesh data (passed as param it is usually already available, depending on TriangleMeshType and whether an AABB tree was provided) |
|
inline |
Compute the SDF with exactly specified grid origin and dimensions
| InGridOrigin | Origin of the output grid |
| InDimensions | Dimensions of the output grid |
|
inline |
|
inline |
Empty out all computed result data (leaves input data alone)
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inlinestatic |
Encodes heuristic for deciding whether it will be faster to use
|
inlinestatic |
|
inline |
| int UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::ApproxMaxCellsPerDimension = 4096 |
| bool UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::bComputeSigns = true |
| bool UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::bUseParallel = true |
| bool UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::bWantClosestTriGrid = false |
| bool UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::bWantIntersectionsGrid = false |
| TFunction<bool()> UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::CancelF |
if this function returns true, we should abort calculation
| CellSizeType UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::CellSize |
|
protected |
| EComputeModes UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::ComputeMode = EComputeModes::NarrowBandOnly |
| int UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::ExactBandWidth = 1 |
| FVector3d UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::ExpandBounds = FVector3d::Zero() |
| FDenseGrid3f UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::Grid |
| FVector3f UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::GridOrigin |
| EInsideModes UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::InsideMode = EInsideModes::WindingCount |
|
protected |
| const TriangleMeshType* UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::Mesh |
| double UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::NarrowBandMaxDistance = 0 |
| TMeshAABBTree3<TriangleMeshType>* UE::Geometry::TSweepingMeshSDF< TriangleMeshType, bScalarCellSize >::Spatial |