[Bf-blender-cvs] [1e0eac5] BendyBones: Bendy Bones: Code Cleanup - More steps to simplify + clarify the scaling code

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


Commit: 1e0eac56d70095d2a53c0f8c9623e2e2110f9b03
Author: Joshua Leung
Date:   Sun May 15 19:22:16 2016 +1200
Branches: BendyBones
https://developer.blender.org/rB1e0eac56d70095d2a53c0f8c9623e2e2110f9b03

Bendy Bones: Code Cleanup - More steps to simplify + clarify the scaling code

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

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 dec7d3e..904e267 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -649,16 +649,18 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
 		}
 		
 		if (!rest) {
+			const int num_segments = bone->segments - 1; // XXX: why n - 1, and not n?
+			
 			float scaleFactorIn = 1.0f;
-			if (a <= bone->segments - 1) {
+			if (a <= num_segments) {
 				const float scaleIn = bone->scaleIn * pchan->scaleIn;
-				scaleFactorIn = 1.0f + (scaleIn - 1.0f)  * ((float)(bone->segments - a - 1) / (float)(bone->segments - 1));
+				scaleFactorIn  = 1.0f + (scaleIn  - 1.0f) * ((float)(num_segments - a) / (float)num_segments);
 			}
 			
 			float scaleFactorOut = 1.0f;
 			if (a >= 0) {
 				const float scaleOut = bone->scaleOut * pchan->scaleOut;
-				scaleFactorOut = 1.0 + (scaleOut - 1.0f) * ((float)(a + 1)                  / (float)(bone->segments - 1));
+				scaleFactorOut = 1.0f + (scaleOut - 1.0f) * ((float)(a + 1)            / (float)num_segments);
 			}
 			
 			float scalefac = scaleFactorIn * scaleFactorOut;
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 5d3d301..db9ae7a 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1152,14 +1152,16 @@ static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SU
 		
 		/* "extra" scale facs... */
 		{
+			const int num_segments = ebone->segments - 1; // XXX: why n - 1, and not n?
+			
 			float scaleFactorIn = 1.0f;
-			if (a <= ebone->segments - 1) {
-				scaleFactorIn = 1.0f + (ebone->scaleIn - 1.0f)  * ((float)(ebone->segments - a - 1) / (float)(ebone->segments - 1));
+			if (a <= num_segments) {
+				scaleFactorIn  = 1.0f + (ebone->scaleIn  - 1.0f) * ((float)(num_segments - a) / (float)num_segments);
 			}
 			
 			float scaleFactorOut = 1.0f;
 			if (a >= 0) {
-				scaleFactorOut = 1.0 + (ebone->scaleOut - 1.0f) * ((float)(a + 1)                  / (float)(ebone->segments - 1));
+				scaleFactorOut = 1.0f + (ebone->scaleOut - 1.0f) * ((float)(a + 1)            / (float)num_segments);
 			}
 			
 			float scalefac = scaleFactorIn * scaleFactorOut;




More information about the Bf-blender-cvs mailing list