Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-05-15 10:22:16 +0300
committerJoshua Leung <aligorith@gmail.com>2016-05-17 17:28:58 +0300
commit1e0eac56d70095d2a53c0f8c9623e2e2110f9b03 (patch)
treeffd7c0b4ec97515df2c1048a58f74e050ca12a51
parentd7926e9893596d2459a9b4be9c5b451c3c95314e (diff)
Bendy Bones: Code Cleanup - More steps to simplify + clarify the scaling code
-rw-r--r--source/blender/blenkernel/intern/armature.c8
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c8
2 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index dec7d3ece2c..904e267304b 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 5d3d301d6fe..db9ae7ad42d 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;