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:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-04-15 20:25:41 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-04-16 18:41:57 +0300
commitad9275ed4e60b7ca4874bbb2c80fef6e2606eb39 (patch)
tree901785b1d79494754a4d96450ce13a093a74ab95 /source/blender/blenkernel/intern/armature_update.c
parent752edc0a155a3cd9ff6b0152cd7c96cecd542c9b (diff)
Spline IK: support changing individual bone length via Y scaling.
Previously Spline IK provided only two choices: either scale the length of the bone chain to fit the length of the curve, or don't scale the bone in the Y dimension at all (ignoring effects of actually fitting to the curve due to curvature and curve object scale). This patch adds a new option to use the pre-IK Y scale of the bones to adjust their length when fitted to the curve, allowing individual posing control over the length of the segments. Reviewers: brecht Differential Revision: https://developer.blender.org/D4687
Diffstat (limited to 'source/blender/blenkernel/intern/armature_update.c')
-rw-r--r--source/blender/blenkernel/intern/armature_update.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index c76bf663b72..51333251b8e 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -230,7 +230,7 @@ static bool splineik_evaluate_init(tSplineIK_Tree *tree, tSplineIk_EvalState *st
unit_m4(state->locrot_offset);
/* Apply corrections for sensitivity to scaling. */
- if ((ikData->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) && (tree->totlength != 0.0f)) {
+ if ((ikData->yScaleMode != CONSTRAINT_SPLINEIK_YS_FIT_CURVE) && (tree->totlength != 0.0f)) {
/* get the current length of the curve */
/* NOTE: this is assumed to be correct even after the curve was resized */
float splineLen = cache->path->totdist;
@@ -262,6 +262,12 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Object *ob, bPoseChanne
float curveLen = tree->points[index] - tree->points[index + 1];
float pointStart = state->curve_position;
float baseScale = 1.0f;
+
+ if (ikData->yScaleMode == CONSTRAINT_SPLINEIK_YS_ORIGINAL) {
+ /* Carry over the bone Y scale to the curve range. */
+ baseScale = len_v3v3(poseHead, poseTail) / pchan->bone->length;
+ }
+
float pointEnd = pointStart + curveLen * baseScale * state->curve_scale;
state->curve_position = pointEnd;