diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2012-11-22 01:42:07 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2012-11-22 01:42:07 +0400 |
commit | 031230265c979991e10abfc8ad1d70d49445fcab (patch) | |
tree | 3b1af40f625bf4e1f2671d93aab568a584be6ccd | |
parent | 1ecde9a1371a65ea34038cf14ac4e38fff7887e4 (diff) |
Fix: Normal maps and triangulate modifier will give incorrect result on
rectangular faces after applying rotation, reported by Metalliandi
This issue is caused by floating point precision error. After applying
rotation, the edge lengths change slightly and on rectangular faces the
length comparison can be flipped. Solved by giving a slight offset to
the length calculation for the diagonal during triangulation
calculation. (Same as done during uv unwrapping)
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 35213c83097..2e0471863d4 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -677,6 +677,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, floa BMLoop *l_first; const float cos_threshold = 0.9f; + const float bias = 1.0f + 1e-6f; if (f->len == 4) { BMLoop *larr[4]; @@ -691,7 +692,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, floa /* pick 0/1 based on best lenth */ /* XXX Can't only rely on such test, also must check we do not get (too much) degenerated triangles!!! */ i = (((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > - len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty); + len_squared_v3v3(larr[1]->v->co, larr[3]->v->co) * bias)) != use_beauty); i4 = (i + 3) % 4; /* Check produced tris aren’t too flat/narrow... * Probably not the best test, but is quite efficient and should at least avoid null-area faces! */ |