gkjohnson / three-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh
MIT License
552 stars 45 forks source link

Issue with overlapping faces on subtraction #87

Closed cm-jchen closed 1 year ago

cm-jchen commented 1 year ago

Hi there,

When intersecting with 2 boxes, three-bvh-csg can't really to figure out coplanar. Not sure if this is related to #69. Any suggestion how we can handle this case?

image

cm-jchen commented 1 year ago

image I think the COPLANAR Case is just not handled. If I add this line 268, it solves this but it will create triangles on the two side of the box.

gkjohnson commented 1 year ago

but it will create triangles on the two side of the box

The two-sidedness is the reason this is only performed in the non-inverted case. It seems that floating point errors are causing issues here, though, which will need to be figured out.

cm-jchen commented 1 year ago

Not sure if this PR will solve most of the case, but comparing the normal from the planes to determine whether is should be adding a triangle or skipping a triangle. This way can avoid creating triangles on the two side of the box