manifold icon indicating copy to clipboard operation
manifold copied to clipboard

Adding SDF class

Open elalish opened this issue 2 years ago • 2 comments

Fixes #129

I've implemented my own take on Marching Cubes for making manifold meshes from signed-distance functions. It's a form of Marching Tetrahedra on a body-centered cubic grid, which ensures all tetrahedra are identical, maximum quality, and symmetric. It also ensures all output is manifold without needing to deal with edge cases.

I've implemented this for the GPU (of course it works on the CPU as well) because the computation can get pretty intense. The interface is intended to mimic Thrust with its use of functors, but I think I'm doing something wrong, because the type system isn't managing to infer as much as it should. For instance, I'd like to write const SDF sdf(Gyroid());, but instead I seem to need this:

const Gyroid gyroid;
const SDF<Gyroid> sdf(gyroid);

I've still got some optimizations to do too.

elalish avatar Aug 18 '22 20:08 elalish

So if I have a random glb I may be possible to test this?

Do I need to generate sdfs in some form? What form is that?

fire avatar Aug 18 '22 20:08 fire

So if I have a random glb I may be possible to test this?

Do I need to generate sdfs in some form? What form is that?

There's documentation in sdf.h for the SDF class. Any function that takes a vec3 and returns a float will do. Turning an arbitrary GLB into an SDF is pretty non-trivial - that's not really what it's for. It's about creating complex surfaces from mathematical functions. Try out the sample.

elalish avatar Aug 19 '22 05:08 elalish

Codecov Report

Merging #187 (94a3c69) into master (08598c0) will increase coverage by 0.02%. The diff coverage is 97.35%.

@@            Coverage Diff             @@
##           master     #187      +/-   ##
==========================================
+ Coverage   98.15%   98.18%   +0.02%     
==========================================
  Files          30       33       +3     
  Lines        2602     2919     +317     
==========================================
+ Hits         2554     2866     +312     
- Misses         48       53       +5     
Impacted Files Coverage Δ
src/collider/src/collider.cpp 100.00% <ø> (ø)
src/manifold/src/impl.cpp 100.00% <ø> (ø)
src/utilities/include/structs.h 100.00% <ø> (ø)
src/utilities/include/utils.h 100.00% <ø> (ø)
src/sdf/include/sdf.h 96.10% <96.10%> (ø)
samples/src/gyroid_module.cpp 100.00% <100.00%> (ø)
src/manifold/src/boolean3.cpp 100.00% <100.00%> (ø)
src/manifold/src/boolean_result.cpp 99.57% <100.00%> (+0.06%) :arrow_up:
src/sdf/src/sdf.cpp 100.00% <100.00%> (ø)
src/utilities/include/par.h 100.00% <100.00%> (ø)
... and 17 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Aug 27 '22 17:08 codecov-commenter

I've simplified the API; I think this is pretty much ready to merge.

elalish avatar Aug 30 '22 20:08 elalish