[Bf-blender-cvs] [1b6130533f3] blender-v2.79a-release: Beauty fill was skipping small faces

Campbell Barton noreply at git.blender.org
Wed Jan 3 12:48:22 CET 2018


Commit: 1b6130533f38c1293e0b65204df0aa64b4b0b1d9
Author: Campbell Barton
Date:   Tue Sep 26 12:59:23 2017 +1000
Branches: blender-v2.79a-release
https://developer.blender.org/rB1b6130533f38c1293e0b65204df0aa64b4b0b1d9

Beauty fill was skipping small faces

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

M	source/blender/blenlib/intern/polyfill2d_beautify.c
M	source/blender/bmesh/tools/bmesh_beautify.c

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

diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c
index b563e286a48..5f6fb8e6cd4 100644
--- a/source/blender/blenlib/intern/polyfill2d_beautify.c
+++ b/source/blender/blenlib/intern/polyfill2d_beautify.c
@@ -133,6 +133,8 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(
 {
 	/* not a loop (only to be able to break out) */
 	do {
+		/* Allow very small faces to be considered non-zero. */
+		const float eps_zero_area = 1e-12f;
 		const float area_2x_234 = cross_tri_v2(v2, v3, v4);
 		const float area_2x_241 = cross_tri_v2(v2, v4, v1);
 
@@ -143,7 +145,6 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(
 		           (ELEM(v2, v1, v3, v4) == false) &&
 		           (ELEM(v3, v1, v2, v4) == false) &&
 		           (ELEM(v4, v1, v2, v3) == false));
-
 		/*
 		 * Test for unusable (1-3) state.
 		 * - Area sign flipping to check faces aren't going to point in opposite directions.
@@ -152,7 +153,7 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(
 		if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
 			break;
 		}
-		else if ((fabsf(area_2x_123) <= FLT_EPSILON) || (fabsf(area_2x_134) <= FLT_EPSILON)) {
+		else if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
 			break;
 		}
 
@@ -165,7 +166,7 @@ float BLI_polyfill_beautify_quad_rotate_calc_ex(
 				return -FLT_MAX;  /* always rotate */
 			}
 		}
-		else if ((fabsf(area_2x_234) <= FLT_EPSILON) || (fabsf(area_2x_241) <= FLT_EPSILON)) {
+		else if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
 			return -FLT_MAX;  /* always rotate */
 		}
 
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index 78e3e66b70a..6e6242fc9f9 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -150,7 +150,7 @@ static float bm_edge_calc_rotate_beauty__area(
 			           (ELEM(v4, v1, v2, v3) == false));
 
 			add_v3_v3v3(no, no_a, no_b);
-			if (UNLIKELY((no_scale = normalize_v3(no)) <= FLT_EPSILON)) {
+			if (UNLIKELY((no_scale = normalize_v3(no)) == 0.0f)) {
 				break;
 			}



More information about the Bf-blender-cvs mailing list