Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-12-25 13:14:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2014-12-26 00:46:48 +0300
commit445e50fd1e7d41306ea475bd79bb89bc2d7fc3b1 (patch)
treeeb5c1f2b6494a0cb8094fa5a64b5a374564fa935 /source/blender/blenlib
parentcd095aae139ecbcfdf2103f635eae8d5bc5f3b8e (diff)
cleanup: use cross_tri_v2 when area isn't needed.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_geom.c14
-rw-r--r--source/blender/blenlib/intern/polyfill2d_beautify.c17
2 files changed, 15 insertions, 16 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;
}