MeshSDF
Reads a surface mesh and evaluates its signed distance field using all three mesh-SDF representations described in Mesh Signed Distance Function Classes:
A naive \(O(N)\) scan over all facets (
FlatMeshSDF).A
PackedBVHwith pointer-free, index-offset nodes storing references to the facets directly (MeshSDF).A SIMD-accelerated, SoA-packed triangle BVH (
TriMeshSDF).
Tip
SDF query complexity depends on both the geometry and the query point. A tessellated sphere has a “blind spot” at its center where even a BVH must visit most, if not all, primitives — this example is a good way to see that effect in practice.
The source for this example is at Examples/MeshSDF/main.cpp. See Building
for how to compile it with CMake, GNU Make, or a direct compiler invocation.
cd Examples/MeshSDF
./MeshSDF.ex # defaults to armadillo.obj
./MeshSDF.ex ../../common-3d-test-models/data/cow.obj # or pick another mesh
With no argument the example loads armadillo.obj from the common-3d-test-models
submodule, so make sure it is checked out first (see Obtaining EBGeometry).