diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-26 03:04:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-26 03:04:33 +0400 |
commit | e5a31eff37508a9c97ac55cf522c1493a8e2715a (patch) | |
tree | 9507658314ddba2bf7322a6ce1fccbae6101125b /source/blender/modifiers | |
parent | b32bf2c462970912c2e8013fcf6f0ee5e3eaadd5 (diff) |
code cleanup: use squared length for comparisons and is_zero_v# rather then checking length == 0.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_skin.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index ee0922d388b..5cc38ff0489 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -144,6 +144,7 @@ static int is_quad_symmetric(BMVert *quad[4], const SkinModifierData *smd) { const float threshold = 0.0001f; + const float threshold_squared = threshold * threshold; int axis; for (axis = 0; axis < 3; axis++) { @@ -153,16 +154,16 @@ static int is_quad_symmetric(BMVert *quad[4], copy_v3_v3(a, quad[0]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[1]->co) < threshold) { + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[3]->co) < threshold) + if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) return 1; } - else if (len_v3v3(a, quad[3]->co) < threshold) { + else if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[1]->co) < threshold) + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) return 1; } } @@ -179,13 +180,13 @@ static int quad_crosses_symmetry_plane(BMVert *quad[4], for (axis = 0; axis < 3; axis++) { if (smd->symmetry_axes & (1 << axis)) { - int i, left = 0, right = 0; + int i, left = FALSE, right = FALSE; for (i = 0; i < 4; i++) { - if (quad[i]->co[axis] < 0) - left = 1; - else if (quad[i]->co[axis] > 0) - right = 1; + if (quad[i]->co[axis] < 0.0f) + left = TRUE; + else if (quad[i]->co[axis] > 0.0f) + right = TRUE; if (left && right) return TRUE; @@ -1545,23 +1546,23 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, if (sn->flag & CAP_START) { if (sn->flag & ROOT) { add_poly(so, - sn->frames[0].verts[0], - sn->frames[0].verts[1], - sn->frames[0].verts[2], - sn->frames[0].verts[3]); + sn->frames[0].verts[0], + sn->frames[0].verts[1], + sn->frames[0].verts[2], + sn->frames[0].verts[3]); } else { add_poly(so, - sn->frames[0].verts[3], - sn->frames[0].verts[2], - sn->frames[0].verts[1], - sn->frames[0].verts[0]); + sn->frames[0].verts[3], + sn->frames[0].verts[2], + sn->frames[0].verts[1], + sn->frames[0].verts[0]); } } if (sn->flag & CAP_END) { add_poly(so, sn->frames[1].verts[0], - sn->frames[1].verts[1], + sn->frames[1].verts[1], sn->frames[1].verts[2], sn->frames[1].verts[3]); } |