[Bf-blender-cvs] [d7926e9] BendyBones: Bendy Bones: Code Cleanup - Simplify float conversions here to be easier to follow

Joshua Leung noreply at git.blender.org
Tue May 17 16:40:42 CEST 2016


Commit: d7926e9893596d2459a9b4be9c5b451c3c95314e
Author: Joshua Leung
Date:   Sun May 15 19:06:50 2016 +1200
Branches: BendyBones
https://developer.blender.org/rBd7926e9893596d2459a9b4be9c5b451c3c95314e

Bendy Bones: Code Cleanup - Simplify float conversions here to be easier to follow

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

M	source/blender/blenkernel/intern/armature.c
M	source/blender/editors/space_view3d/drawarmature.c

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

diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 048b861..dec7d3e 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -649,27 +649,26 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
 		}
 		
 		if (!rest) {
-			float scaleFactorIn = 1.0;
+			float scaleFactorIn = 1.0f;
 			if (a <= bone->segments - 1) {
 				const float scaleIn = bone->scaleIn * pchan->scaleIn;
-				scaleFactorIn = 1.0f + (scaleIn - 1.0f)  * ((1.0f * (bone->segments - a - 1)) / (1.0f * (bone->segments - 1)));
+				scaleFactorIn = 1.0f + (scaleIn - 1.0f)  * ((float)(bone->segments - a - 1) / (float)(bone->segments - 1));
 			}
 			
 			float scaleFactorOut = 1.0f;
 			if (a >= 0) {
 				const float scaleOut = bone->scaleOut * pchan->scaleOut;
-				scaleFactorOut = 1.0 + (scaleOut - 1.0f) * ((1.0f * (a + 1))                  / (1.0f * (bone->segments - 1)));
+				scaleFactorOut = 1.0 + (scaleOut - 1.0f) * ((float)(a + 1)                  / (float)(bone->segments - 1));
 			}
 			
-			float bscalemat[4][4], ibscalemat[4][4];
-			float bscale[3];
+			float scalefac = scaleFactorIn * scaleFactorOut;
+			float bscalemat[4][4], bscale[3];
 			
-			bscale[0] = 1.0f * scaleFactorIn * scaleFactorOut;
+			bscale[0] = scalefac;
 			bscale[1] = 1.0f;
-			bscale[2] = 1.0f * scaleFactorIn * scaleFactorOut;
+			bscale[2] = scalefac;
 			
 			size_to_mat4(bscalemat, bscale);
-			invert_m4_m4(ibscalemat, bscalemat);
 			
 			/* Note: don't multiply by inverse scale mat here, as it causes problems with scaling shearing and breaking segment chains */
 			/*mul_m4_series(result_array[a].mat, ibscalemat, result_array[a].mat, bscalemat);*/
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 4f0d277..5d3d301 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1152,28 +1152,26 @@ static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SU
 		
 		/* "extra" scale facs... */
 		{
-			float scaleFactorIn = 1.0;
+			float scaleFactorIn = 1.0f;
 			if (a <= ebone->segments - 1) {
-				scaleFactorIn = 1.0f + (ebone->scaleIn - 1.0f)  * ((1.0f * (ebone->segments - a - 1)) / (1.0f * (ebone->segments - 1)));
+				scaleFactorIn = 1.0f + (ebone->scaleIn - 1.0f)  * ((float)(ebone->segments - a - 1) / (float)(ebone->segments - 1));
 			}
 			
 			float scaleFactorOut = 1.0f;
 			if (a >= 0) {
-				scaleFactorOut = 1.0 + (ebone->scaleOut - 1.0f) * ((1.0f * (a + 1))                  / (1.0f * (ebone->segments - 1)));
+				scaleFactorOut = 1.0 + (ebone->scaleOut - 1.0f) * ((float)(a + 1)                  / (float)(ebone->segments - 1));
 			}
 			
-			float bscalemat[4][4], ibscalemat[4][4];
-			float bscale[3];
+			float scalefac = scaleFactorIn * scaleFactorOut;
+			float bscalemat[4][4], bscale[3];
 			
-			bscale[0] = 1.0f * scaleFactorIn * scaleFactorOut;
+			bscale[0] = scalefac;
 			bscale[1] = 1.0f;
-			bscale[2] = 1.0f * scaleFactorIn * scaleFactorOut;
+			bscale[2] = scalefac;
 			
 			size_to_mat4(bscalemat, bscale);
-			invert_m4_m4(ibscalemat, bscalemat);
 			
 			/* Note: don't multiply by inverse scale mat here, as it causes problems with scaling shearing and breaking segment chains */
-			/*mul_m4_series(result_array[a].mat, ibscalemat, result_array[a].mat, bscalemat);*/
 			mul_m4_series(result_array[a].mat, result_array[a].mat, bscalemat);
 		}
 	}




More information about the Bf-blender-cvs mailing list