diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-12-25 13:14:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-12-26 00:46:48 +0300 |
commit | 445e50fd1e7d41306ea475bd79bb89bc2d7fc3b1 (patch) | |
tree | eb5c1f2b6494a0cb8094fa5a64b5a374564fa935 /source/blender | |
parent | cd095aae139ecbcfdf2103f635eae8d5bc5f3b8e (diff) |
cleanup: use cross_tri_v2 when area isn't needed.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 14 | ||||
-rw-r--r-- | source/blender/blenlib/intern/polyfill2d_beautify.c | 17 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_beautify.c | 17 |
3 files changed, 25 insertions, 23 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 42aa24d284d..bcf2147fd84 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2350,15 +2350,15 @@ bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[ } /** - * \note: using #area_tri_signed_v2 means locations outside the triangle are correctly weighted + * \note: using #cross_tri_v2 means locations outside the triangle are correctly weighted */ void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]) { float wtot; - w[0] = area_tri_signed_v2(v2, v3, co); - w[1] = area_tri_signed_v2(v3, v1, co); - w[2] = area_tri_signed_v2(v1, v2, co); + w[0] = cross_tri_v2(v2, v3, co); + w[1] = cross_tri_v2(v3, v1, co); + w[2] = cross_tri_v2(v1, v2, co); wtot = w[0] + w[1] + w[2]; if (wtot != 0.0f) { @@ -2377,9 +2377,9 @@ void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const fl { float wtot; - w[0] = area_tri_signed_v2(v2, v3, co) / v1[3]; - w[1] = area_tri_signed_v2(v3, v1, co) / v2[3]; - w[2] = area_tri_signed_v2(v1, v2, co) / v3[3]; + w[0] = cross_tri_v2(v2, v3, co) / v1[3]; + w[1] = cross_tri_v2(v3, v1, co) / v2[3]; + w[2] = cross_tri_v2(v1, v2, co) / v3[3]; wtot = w[0] + w[1] + w[2]; if (wtot != 0.0f) { diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c index c4e333d0094..b8922ef6cb2 100644 --- a/source/blender/blenlib/intern/polyfill2d_beautify.c +++ b/source/blender/blenlib/intern/polyfill2d_beautify.c @@ -179,8 +179,6 @@ static float quad_v2_rotate_beauty_calc( float len_12, len_23, len_34, len_41, len_24, len_13; -#define AREA_FROM_CROSS(val) (fabsf(val) / 2.0f) - /* edges around the quad */ len_12 = len_v2v2(v1, v2); len_23 = len_v2v2(v2, v3); @@ -190,22 +188,23 @@ static float quad_v2_rotate_beauty_calc( len_13 = len_v2v2(v1, v3); len_24 = len_v2v2(v2, v4); + /* note, area is in fact (area * 2), + * but in this case its OK, since we're comparing ratios */ + /* edge (2-4), current state */ - area_a = AREA_FROM_CROSS(area_2x_234); - area_b = AREA_FROM_CROSS(area_2x_241); + area_a = fabsf(area_2x_234); + area_b = fabsf(area_2x_241); prim_a = len_23 + len_34 + len_24; - prim_b = len_24 + len_41 + len_12; + prim_b = len_41 + len_12 + len_24; fac_24 = (area_a / prim_a) + (area_b / prim_b); /* edge (1-3), new state */ - area_a = AREA_FROM_CROSS(area_2x_123); - area_b = AREA_FROM_CROSS(area_2x_134); + area_a = fabsf(area_2x_123); + area_b = fabsf(area_2x_134); prim_a = len_12 + len_23 + len_13; prim_b = len_34 + len_41 + len_13; fac_13 = (area_a / prim_a) + (area_b / prim_b); -#undef AREA_FROM_CROSS - /* negative number if (1-3) is an improved state */ return fac_24 - fac_13; } diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c index 1c6dc6f5c0e..6fb7f7cb4be 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.c +++ b/source/blender/bmesh/tools/bmesh_beautify.c @@ -187,8 +187,8 @@ static float bm_edge_calc_rotate_beauty__area( * into a different degenerate shape or flipping the face */ float area_a, area_b; - area_a = area_tri_signed_v2(v1_xy, v2_xy, v3_xy); - area_b = area_tri_signed_v2(v1_xy, v3_xy, v4_xy); + area_a = cross_tri_v2(v1_xy, v2_xy, v3_xy); + area_b = cross_tri_v2(v1_xy, v3_xy, v4_xy); if ((fabsf(area_a) <= FLT_EPSILON) || (fabsf(area_b) <= FLT_EPSILON)) { /* one of the new rotations is degenerate */ @@ -219,16 +219,19 @@ static float bm_edge_calc_rotate_beauty__area( len_13 = len_v2v2(v1_xy, v3_xy); len_24 = len_v2v2(v2_xy, v4_xy); + /* note, area is in fact (area * 2), + * but in this case its OK, since we're comparing ratios */ + /* edge (2-4), current state */ - area_a = area_tri_v2(v2_xy, v3_xy, v4_xy); - area_b = area_tri_v2(v2_xy, v4_xy, v1_xy); + area_a = fabsf(cross_tri_v2(v2_xy, v3_xy, v4_xy)); + area_b = fabsf(cross_tri_v2(v2_xy, v4_xy, v1_xy)); prim_a = len_23 + len_34 + len_24; - prim_b = len_24 + len_41 + len_12; + prim_b = len_41 + len_12 + len_24; fac_24 = (area_a / prim_a) + (area_b / prim_b); /* edge (1-3), new state */ - area_a = area_tri_v2(v1_xy, v2_xy, v3_xy); - area_b = area_tri_v2(v1_xy, v3_xy, v4_xy); + area_a = fabsf(cross_tri_v2(v1_xy, v2_xy, v3_xy)); + area_b = fabsf(cross_tri_v2(v1_xy, v3_xy, v4_xy)); prim_a = len_12 + len_23 + len_13; prim_b = len_34 + len_41 + len_13; fac_13 = (area_a / prim_a) + (area_b / prim_b); |