diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c index c727a2a9c45..287fe3c817e 100644 --- a/source/blender/blenlib/intern/polyfill2d_beautify.c +++ b/source/blender/blenlib/intern/polyfill2d_beautify.c @@ -133,21 +133,12 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex( { /* not a loop (only to be able to break out) */ do { - bool is_zero_a, is_zero_b; + const float area_2x_234 = cross_tri_v2(v2, v3, v4); + const float area_2x_241 = cross_tri_v2(v2, v4, v1); 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) && @@ -158,7 +149,9 @@ 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 (is_zero_a || is_zero_b || ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f))) { + if (((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) || + (fabsf(area_2x_123) <= FLT_EPSILON) || (fabsf(area_2x_134) <= FLT_EPSILON)) + { break; } @@ -166,7 +159,12 @@ 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))) { - return -FLT_MAX; /* always rotate */ + if (lock_degenerate) { + break; + } + else { + return -FLT_MAX; /* always rotate */ + } } {