manifold icon indicating copy to clipboard operation
manifold copied to clipboard

Visual debug

Open elalish opened this issue 2 years ago • 2 comments

One of the most powerful features of OpenSCAD is its visual debug, where you put # in front of a line to see that object rendered in the final output and so view its position even if it's a "negative" object. This is key to learning the language of CAD, especially since it is easy to transform something wrong and especially in the case of a difference, for it to simply not affect the output at all and so be effectively lost.

I would like to enable this feature in our editor, but I believe it needs to be implemented within our library itself. I think this is a good idea anyway, since this feature will likely be useful to any users of our library that have a UX. @pca006132, I think this would fit most naturally into the csg_tree class, so I'd like your opinion on it.

As far as API, I'm thinking add two methods to the Manifold class: void Mark() and std::vector<Mesh> GetMarkedMeshes() const. The idea is that any manifold that you Mark saves that marked condition in the csg_node. Then when you call GetMarkedMeshes on a downstream product, it walks the CSG tree doing only operations upstream of the marked nodes. It applies all downstream transformations and outputs all the marked meshes (there may be several copies). Then an editor displays those meshes in a different color (say, red, semi-transparent) on top of the regular output mesh for script debugging purposes.

elalish avatar Sep 25 '22 06:09 elalish

Sounds good, but I'm not sure how this will interact with operations such as smooth and warp, which skipping downstream boolean operations may not produce the same output.

pca006132 avatar Sep 25 '22 06:09 pca006132

True, since warp is generally nonlinear, inserting an intersection will effectively change the interpolation. I doubt that's a huge deal in practice; warp is only going to be useful if the mesh is already sufficiently refined to make the interpolation fairly accurate. Smooth is no problem because it's basically only available as the first operation; we don't have a good way to push tangents through operations yet.

The nice thing is it's just for debug, so it really doesn't need to be perfect so long as it's useful.

elalish avatar Sep 27 '22 06:09 elalish