diff options
author | Germano <germano.costa@ig.com.br> | 2017-09-23 18:59:02 +0300 |
---|---|---|
committer | Germano <germano.costa@ig.com.br> | 2017-09-23 18:59:02 +0300 |
commit | a8f11f5422afa01608817755eea310e987f896be (patch) | |
tree | 523291ab900ee3935eaa2048acd4ff4df020a5ed | |
parent | c0480bc972534adcb29ffa63ecdd6be84bd66188 (diff) |
Fix T52871: `BLI_polyfill_beautify_quad_rotate_calc_ex` was mistakenly considering the state as degenerated
-rw-r--r-- | source/blender/blenlib/intern/polyfill2d_beautify.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c index 287fe3c817e..c727a2a9c45 100644 --- a/source/blender/blenlib/intern/polyfill2d_beautify.c +++ b/source/blender/blenlib/intern/polyfill2d_beautify.c @@ -133,12 +133,21 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex( { /* not a loop (only to be able to break out) */ do { - const float area_2x_234 = cross_tri_v2(v2, v3, v4); - const float area_2x_241 = cross_tri_v2(v2, v4, v1); + bool is_zero_a, is_zero_b; const float area_2x_123 = cross_tri_v2(v1, v2, v3); const float area_2x_134 = cross_tri_v2(v1, v3, v4); + is_zero_a = (fabsf(area_2x_123) <= FLT_EPSILON); + is_zero_b = (fabsf(area_2x_134) <= FLT_EPSILON); + + if (lock_degenerate && is_zero_a && is_zero_b) { + break; + } + + const float area_2x_234 = cross_tri_v2(v2, v3, v4); + const float area_2x_241 = cross_tri_v2(v2, v4, v1); + BLI_assert((ELEM(v1, v2, v3, v4) == false) && (ELEM(v2, v1, v3, v4) == false) && (ELEM(v3, v1, v2, v4) == false) && @@ -149,9 +158,7 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex( * - Area sign flipping to check faces aren't going to point in opposite directions. * - Area epsilon check that the one of the faces won't be zero area. */ - if (((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) || - (fabsf(area_2x_123) <= FLT_EPSILON) || (fabsf(area_2x_134) <= FLT_EPSILON)) - { + if (is_zero_a || is_zero_b || ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f))) { break; } @@ -159,12 +166,7 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex( if (((area_2x_234 >= 0.0f) != (area_2x_241 >= 0.0f)) || ((fabsf(area_2x_234) <= FLT_EPSILON) || (fabsf(area_2x_241) <= FLT_EPSILON))) { - if (lock_degenerate) { - break; - } - else { - return -FLT_MAX; /* always rotate */ - } + return -FLT_MAX; /* always rotate */ } { |