Improve triangle mesh (splitting of quads based on angle).

When checking the dot product of the tangents `tu` and `tv` to decide
in which direction to split a quad compare it to to LENGTH_EPS instead
of zero to avoid alternating triangle "orientations" when the tangents
are orthogonal (revolve, lathe etc.).
This improves the quality of the resulting triangle mesh.
This commit is contained in:
ruevs 2020-05-13 00:36:26 +03:00 committed by phkahler
parent 23dfd97285
commit 70ec7cc257

View File

@ -482,7 +482,11 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) {
if (this_flag) { if (this_flag) {
// Add the quad to our mesh // Add the quad to our mesh
srf->TangentsAt(us,vs, &tu,&tv); srf->TangentsAt(us,vs, &tu,&tv);
if (tu.Dot(tv) < 0.0) { //split the other way if angle>90 if(tu.Dot(tv) < LENGTH_EPS) {
/* Split "the other way" if angle>90
compare to LENGTH_EPS instead of zero to avoid alternating triangle
"orientations" when the tangents are orthogonal (revolve, lathe etc.)
this results in a higher quality mesh. */
STriangle tr = {}; STriangle tr = {};
tr.a = a; tr.a = a;
tr.b = b; tr.b = b;