diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-11-06 17:11:32 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-11-07 19:03:03 +0300 |
commit | aadc90d0fc6734ac335f5ae488767ddb4dac307c (patch) | |
tree | 29e990b2b9f9e92170c3a21a7b6f23db16181656 /source/blender/blenkernel/intern/constraint.c | |
parent | 4e5768b2a7863fb2fc85eb774c281ec535e515b8 (diff) |
Stretch To: implement a mode similar to Damped Track for rotation.
Most of the time Stretch To is used in actual rigs, like BlenRig
or Rigify, in combination with Damped Track to handle rotation
before the stretch, because it produces rotations more appropriate
for organic deformation, and doesn't flip because of internal
gimbal lock.
The prevalence of this pattern suggests that Stretch To should
support that kind of rotation directly as an option.
Differential Revision: https://developer.blender.org/D6134
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index bee2e05f8d9..c397fbcf115 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3242,6 +3242,12 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t float size[3], scale[3], vec[3], xx[3], zz[3], orth[3]; float dist, bulge; + /* Remove shear if using the Damped Track mode; the other modes + * do it as a side effect, which is relied on by rigs. */ + if (data->plane == SWING_Y) { + orthogonalize_m4_stable(cob->matrix, 1, false); + } + /* store scaling before destroying obmat */ normalize_m4_ex(cob->matrix, size); @@ -3329,6 +3335,10 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t mul_v3_v3(size, scale); switch (data->plane) { + case SWING_Y: + /* Point the Y axis using Damped Track math. */ + damptrack_do_transform(cob->matrix, vec, TRACK_Y); + break; case PLANE_X: /* new Y aligns object target connection*/ copy_v3_v3(cob->matrix[1], vec); |