[Bf-blender-cvs] [9298d99b77f] blender-v2.79a-release: Fix T52871: `BLI_polyfill_beautify_quad_rotate_calc_ex` was mistakenly considering the state as degenerated

Germano noreply at git.blender.org
Wed Jan 3 12:48:17 CET 2018


Commit: 9298d99b77f3142e59563485253f2df909630582
Author: Germano
Date:   Sat Sep 23 12:59:02 2017 -0300
Branches: blender-v2.79a-release
https://developer.blender.org/rB9298d99b77f3142e59563485253f2df909630582

Fix T52871: `BLI_polyfill_beautify_quad_rotate_calc_ex` was mistakenly considering the state as degenerated

===================================================================

M	source/blender/blenlib/intern/polyfill2d_beautify.c

===================================================================

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 */
 		}
 
 		{



More information about the Bf-blender-cvs mailing list