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 | |
parent | b32bf2c462970912c2e8013fcf6f0ee5e3eaadd5 (diff) |
code cleanup: use squared length for comparisons and is_zero_v# rather then checking length == 0.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/implicit.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_interp.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_skin.c | 37 |
4 files changed, 23 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 9201ac463e3..39dcd73e0e5 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1730,7 +1730,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo for (i=0; i<cloth->numverts; i++, cv++) { copy_v3_v3(cos[i], cv->tx); - if (cv->goal == 1.0f || len_v3v3(initial_cos[i], cv->tx) != 0.0) { + if (cv->goal == 1.0f || len_squared_v3v3(initial_cos[i], cv->tx) != 0.0) { masses[i] = 1e+10; } else { diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 00c44bdc008..d75339252d9 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -1134,7 +1134,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* Add default gravity to scenes */ for (sce = main->scene.first; sce; sce = sce->id.next) { if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && - len_v3(sce->physics_settings.gravity) == 0.0f) + is_zero_v3(sce->physics_settings.gravity)) { sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f; sce->physics_settings.gravity[2] = -9.81f; diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 7ca43d9ba80..ffe79923730 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -345,9 +345,9 @@ static int mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, float float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3]; float eps = FLT_EPSILON * 4000; - if (len_v3(l->v->no) == 0.0f) + if (is_zero_v3(l->v->no)) BM_vert_normal_update_all(l->v); - if (len_v3(tl->v->no) == 0.0f) + if (is_zero_v3(tl->v->no)) BM_vert_normal_update_all(tl->v); compute_mdisp_quad(tl, v1, v2, v3, v4, e1, e2); 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]); } |