Closed gkjohnson closed 1 year ago
Triangle planes were not being calculated correctly and coplanar triangles were not being marked as coplanar.
Still some triangles being missed by coplanar count, tho:
Commenting out these lines fixes the issue:
// skip the triangle if we don't intersect with it
if ( ! _splittingTriangle.intersectsTriangle( tri, _edge, true ) ) {
performCoplanarIncrement( tri );
continue;
}
Using these functions in place of intersectsTriangle
seems to fix the issue, but also increases the amount of triangulation. Why?
const getSide = v => Math.sign( plane.distanceToPoint( v ) );
const isOneSide = t => {
let s = getSide( t.a ) || getSide( t.b ) || getSide( t.c );
if ( s !== getSide( t.b ) ) return false;
if ( s !== getSide( t.c ) ) return false;
return true;
};
edit - we need to check if the "intersectsTriangle" function properly handles fully encapsulated triangles? Because the "coplanar" function does nothing if the triangles don't intersect at all. Could also try manually processing coplanarity on all triangles afterward.
The intersects triangle function does handle fully encapsulated triangles.
It looks like using the plane is not a great way to determine coplanarity.
TODO
Related to #177
Offsets the ray to avoid floating point error on coplanar faces - but since these are being treated as whole triangles there should be no need to test for coplanarity?
TODO