[Bf-blender-cvs] [d1657b406ed] blender-v2.82-release: Fix T73117: B-Bone twist weirdness in chains with sharp bends.

Alexander Gavrilov noreply at git.blender.org
Sun Jan 19 16:49:51 CET 2020


Commit: d1657b406ed0f3df9e1690cd445702c6178ffd15
Author: Alexander Gavrilov
Date:   Sun Jan 19 18:44:00 2020 +0300
Branches: blender-v2.82-release
https://developer.blender.org/rBd1657b406ed0f3df9e1690cd445702c6178ffd15

Fix T73117: B-Bone twist weirdness in chains with sharp bends.

When computing the roll value coming from the handle bone, the code
was using some strange unexplained math. It probably works fine when
the difference with the 'zero roll' orientation is pure twist, like
is the case when called from mat3_to_vec_roll. However, it appears
to break when significant swing is involved.

The issue is fixed by using the proper Swing+Twist decomposition
utility function that was added in a recent version for drivers.

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

M	source/blender/blenkernel/intern/armature.c

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

diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index c588ee80c78..e4da10797ff 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2293,13 +2293,17 @@ void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll)
  * If vec is the Y vector from purely rotational mat, result should be exact. */
 void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll)
 {
-  float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
+  float vecmat[3][3], vecmatinv[3][3], rollmat[3][3], q[4];
 
+  /* Compute the orientation relative to the vector with zero roll. */
   vec_roll_to_mat3(vec, 0.0f, vecmat);
   invert_m3_m3(vecmatinv, vecmat);
   mul_m3_m3m3(rollmat, vecmatinv, mat);
 
-  *r_roll = atan2f(rollmat[2][0], rollmat[2][2]);
+  /* Extract the twist angle as the roll value. */
+  mat3_to_quat(q, rollmat);
+
+  *r_roll = quat_split_swing_and_twist(q, 1, NULL, NULL);
 }
 
 /* Calculates the rest matrix of a bone based on its vector and a roll around that vector. */



More information about the Bf-blender-cvs mailing list