-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example that reproduces problems with missing triangles (for subtraction), and a possible fix #95
Comments
found one issue with cones -- in ConeGeometry there are some degenerate triangles (because of the way it's build out of CylinderGeometry). |
Hey @coolvision! Thanks for taking a deeper look at this this stuff. As you can tell - the implementation for triangle clipping and CSG isn't perfect (yet?) but I'd like to put some more time into it at some point. To your change about handling COPLANAR triangles that change looks good given the current implementation. It's likely we need the same kind of change in the Regarding the degenerate triangles in the cone geometry - can you elaborate a bit more on why cones get a degenerate triangle and where it shows up? Is this an issue with three.js' cone generation? Handling these degenerate triangle cases is a little odd because the apparent "degeneracy" of a triangle changes depending on what frame you measure in. I'll have to think about how to handle this a bit better in the future. Also if CSG is something you're interested in the project could always use more help! Happy to talk about some of the next steps I'd take on the project if you want to contribute more. |
I see now - yes this will result in problematic triangles with ambiguous half edge connectivity. I'm tempted to suggest that this is an invalid mesh that needs to be fixed in order to be used with the project. And perhaps there can be a utility to detect and/or fix these issues. One of the strategies for keeping performance up, for example, is retaining a 1:1 half-edge connectivity graph of the model which lets us quickly discover fully connected sets of faces. If a degenerate triangle sits on another triangle edge this will potentially disrupt the fidelity of the half edge structure resulting in an invalid / less performant structure. To that end I'd like to eventually guarantee that the result of a CSG operation is a fully connected half-edge structure, as well (see #27, #51, #77). It's possible we'll still need handling of these types of corner cases but it doesn't seem as simple as just ignoring them during processing. At some point it's possible the project should throw an error if a non-connected mesh is encountered. This is a good case to be aware of that I didn't know about, though.
Coplanar triangles are a complicated case, at the moment, that's susceptible to floating point error when checking for the coplanar case. Ultimately these cases need more robust (and probably different) handling to be resilient to these kinds of problems. |
@coolvision Are you able to test this on the latest version of then project and latest three-mesh-bvh? |
I made a demo that allows to interactively "cut off" pieces of a mesh:
https://github.com/coolvision/three-bvh-csg/blob/iterative-dev/examples/iterative.js
demo video:
It does subtraction, and the mesh is iteratively updated to the CSG result each time, so that subtractions accumulate.
In this case, lots of coplanar triangles are created, and when testing with current three-bvh-csg version, lots of triangles are missing:
I've added a fix for adding coplanar triangles, and in this case it works fine:
7188689#diff-172f17787715fc8aa7225b6a6716874d91c005133ed9670a86c84ab2081ca063
When I use a cone for the brush instead of a box. there are still missing and non-clipped triangles, albeit less than without the fix, so there is still work to do:
Would some of this be useful? I can add a PR for the fix, and for the demo/example as well, I think it's a useful testcase for improving bunch of corner cases.
The text was updated successfully, but these errors were encountered: