Beauty fill was skipping small faces
authorCampbell Barton <ideasman42@gmail.com>
Tue, 26 Sep 2017 02:59:23 +0000 (12:59 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 26 Sep 2017 02:59:23 +0000 (12:59 +1000)
source/blender/blenlib/intern/polyfill2d_beautify.c
source/blender/bmesh/tools/bmesh_beautify.c

index b563e286a48c55b40079e9f3c10c216a78758001..5f6fb8e6cd4a22382ac9d4961c37cbc0df80a748 100644 (file)
@@ -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 */
                }
 
index 78e3e66b70aa39451259b4255ff5575c3d88c856..6e6242fc9f9788ddf7908a3f5c989d36af01c9c2 100644 (file)
@@ -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;
                        }