[Bf-blender-cvs] [eadfddd] master: Cleanup: magic numbers

Campbell Barton noreply at git.blender.org
Tue Aug 12 07:59:56 CEST 2014


Commit: eadfddd02a528f1c5450d3795905dbdf669a0062
Author: Campbell Barton
Date:   Tue Aug 12 15:58:53 2014 +1000
Branches: master
https://developer.blender.org/rBeadfddd02a528f1c5450d3795905dbdf669a0062

Cleanup: magic numbers

===================================================================

M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/editors/space_view3d/drawarmature.c

===================================================================

diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 152b317..09c581a 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -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);
 }
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index aedc551..4a9fb67 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -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;
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index e01a9d4..dfa373f 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -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},




More information about the Bf-blender-cvs mailing list