Use squared length where possible
authorCampbell Barton <ideasman42@gmail.com>
Sun, 6 Sep 2015 14:48:26 +0000 (00:48 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 18 Sep 2015 06:40:55 +0000 (16:40 +1000)
source/blender/blenkernel/intern/constraint.c
source/blender/blenlib/intern/math_rotation.c
source/blender/editors/armature/armature_utils.c
source/blender/editors/transform/transform_snap.c

index 2aba4fcde27be830636e58c808eb1ca5ea94d31e..ed2e609ae53a2a29f89260b792d83feb3825df25 100644 (file)
@@ -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);
                        }
index 5f039e89e893dbf88bb1087ade3cf2bffb01f6ee..575710e8d75db114f405ea9f508602e13b0385db 100644 (file)
@@ -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];
 
index 635297c088a6fe3633e9ebb913357aebd7578bc3..61ed7fdc41b983098464fbf2734b76116ff07efb 100644 (file)
@@ -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  */
index f604073298366f62f88f3823812022e24ce908dd..7061b8e7603474829ef790df7db7984417b7019a 100644 (file)
@@ -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);