Cleanup: magic numbers
authorCampbell Barton <ideasman42@gmail.com>
Tue, 12 Aug 2014 05:58:53 +0000 (15:58 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 12 Aug 2014 05:58:53 +0000 (15:58 +1000)
source/blender/blenlib/intern/math_matrix.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/editors/space_view3d/drawarmature.c

index 152b31754bb5ce7f4bf8ba34b71e9b00de143166..09c581a589b2e16d6b6bf629274ad3da9c856548 100644 (file)
@@ -1360,7 +1360,7 @@ float mat3_to_scale(float mat[3][3])
 {
        /* unit length vector */
        float unit_vec[3];
-       copy_v3_fl(unit_vec, 0.577350269189626f);
+       copy_v3_fl(unit_vec, (float)(1.0 / M_SQRT3));
        mul_m3_v3(mat, unit_vec);
        return len_v3(unit_vec);
 }
@@ -1369,7 +1369,7 @@ float mat4_to_scale(float mat[4][4])
 {
        /* unit length vector */
        float unit_vec[3];
-       copy_v3_fl(unit_vec, 0.577350269189626f);
+       copy_v3_fl(unit_vec, (float)(1.0 / M_SQRT3));
        mul_mat3_m4_v3(mat, unit_vec);
        return len_v3(unit_vec);
 }
index aedc551b5a6e817362eb9db3bbf984754526242a..4a9fb677257a5edf55193b179e56017ebc324766 100644 (file)
@@ -1869,7 +1869,7 @@ static float sabin_gamma(int n)
                k2 = k * k;
                k4 = k2 * k2;
                k6 = k4 * k2;
-               y = pow(1.73205080756888 * sqrt(64.0 * k6 - 144.0 * k4 + 135.0 * k2 - 27.0) + 9.0 * k,
+               y = pow(M_SQRT3 * sqrt(64.0 * k6 - 144.0 * k4 + 135.0 * k2 - 27.0) + 9.0 * k,
                        1.0 / 3.0);
                x = 0.480749856769136 * y - (0.231120424783545 * (12.0 * k2 - 9.0)) / y;
                ans = (k * x + 2.0 * k2 - 1.0) / (x * x * (k * x + 1.0));
@@ -2262,7 +2262,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
                bndv = bndv->next;
        }
        /* center vertex */
-       w = 0.57735027f;  /* 1/sqrt(3) */
+       w = (float)(1.0 / M_SQRT3);
        co[0] = w;
        co[1] = w;
        co[2] = w;
index e01a9d4b470967904bdb5046744c7ce60d0d5917..dfa373f111fd70cc87c3864b4bd20e8dd0f3987d 100644 (file)
@@ -467,10 +467,10 @@ static const unsigned int bone_octahedral_solid_tris[8][3] = {
 
 /* aligned with bone_octahedral_solid_tris */
 static const float bone_octahedral_solid_normals[8][3] = {
-       { 0.70710683f, -0.70710683f,  0.00000000f},
-       {-0.00000000f, -0.70710683f, -0.70710683f},
-       {-0.70710683f, -0.70710683f,  0.00000000f},
-       { 0.00000000f, -0.70710683f,  0.70710683f},
+       { M_SQRT1_2,   -M_SQRT1_2,    0.00000000f},
+       {-0.00000000f, -M_SQRT1_2,   -M_SQRT1_2},
+       {-M_SQRT1_2,   -M_SQRT1_2,    0.00000000f},
+       { 0.00000000f, -M_SQRT1_2,    M_SQRT1_2},
        { 0.99388373f,  0.11043154f, -0.00000000f},
        { 0.00000000f,  0.11043154f, -0.99388373f},
        {-0.99388373f,  0.11043154f,  0.00000000f},