csg.cs
csg.cs copied to clipboard
Generated mesh contains "T-junctions"
After a CSG operation, the resulting triangles do not share vertices (it's just a soup of unconnected triangles). Need to apply something equivalent to Blenders "Remove doubles" to turn it into a manifold mesh.
Also, some vertices lie along an edge of a triangle that does not involve that vertex ("T-junctions"). In these cases that triangle should be split into two, to include the vertex and make the mesh manifold. (For an example, see the Sphere subtracted from Cube in the current example scene - at the 'poles' of the sphere there is a vertex lying along an edge).
Partially fixed. The "T-junction" issue, described in the second part of this issue remains.There's a description of how to deal with these mesh features from BSP-based CSG operations here: http://www.flipcode.com/archives/Merging_Polygons_And_Sub-Pixel_Gaps.shtml