diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-06 17:48:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-18 09:40:55 +0300 |
commit | f1422c40af7527141ab348ad2522d7d2435ccb1c (patch) | |
tree | f874fc2d80506ebff69439984165c28e9e0bb82d | |
parent | 2eb50d450c9ea5092049a8d0458b87ca9c838e5f (diff) |
Use squared length where possible
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_utils.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 2aba4fcde27..ed2e609ae53 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -447,7 +447,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ copy_v3_v3(plane, tmat[1]); cross_v3_v3v3(mat[0], normal, plane); - if (len_v3(mat[0]) < 1e-3f) { + if (len_squared_v3(mat[0]) < SQUARE(1e-3f)) { copy_v3_v3(plane, tmat[0]); cross_v3_v3v3(mat[0], normal, plane); } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 5f039e89e89..575710e8d75 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1631,7 +1631,7 @@ void mat4_to_dquat(DualQuat *dq, float basemat[4][4], float mat[4][4]) copy_m3_m4(mat3, mat); - if (!is_orthonormal_m3(mat3) || (determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4f) { + if (!is_orthonormal_m3(mat3) || (determinant_m4(mat) < 0.0f) || len_squared_v3(dscale) > SQUARE(1e-4f)) { /* extract R and S */ float tmp[4][4]; diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 635297c088a..61ed7fdc41b 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -565,9 +565,9 @@ void ED_armature_from_edit(bArmature *arm) /* remove zero sized bones, this gives unstable restposes */ for (eBone = arm->edbo->first; eBone; eBone = neBone) { - float len = len_v3v3(eBone->head, eBone->tail); + float len_sq = len_squared_v3v3(eBone->head, eBone->tail); neBone = eBone->next; - if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ + if (len_sq <= SQUARE(0.000001f)) { /* FLT_EPSILON is too large? */ EditBone *fBone; /* Find any bones that refer to this bone */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index f6040732983..7061b8e7603 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -981,7 +981,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) break; } - new_dist = len_v3v3(last_p, vec); + new_dist = len_squared_v3v3(last_p, vec); if (new_dist < max_dist) { copy_v3_v3(p, vec); |