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.
pull/620/head
ruevs 2020-05-13 00:36:26 +03:00 committed by phkahler
parent 23dfd97285
commit 70ec7cc257
1 changed files with 5 additions and 1 deletions

View File

@ -482,7 +482,11 @@ void SPolygon::UvGridTriangulateInto(SMesh *mesh, SSurface *srf) {
if (this_flag) {
// Add the quad to our mesh
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 = {};
tr.a = a;
tr.b = b;