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>2020-01-19 18:44:00 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-01-19 18:48:18 +0300
commitd1657b406ed0f3df9e1690cd445702c6178ffd15 (patch)
tree1dcf4d56ae42f42f81ef2d8fba5664dcb833d92d /source/blender/blenkernel/intern/armature.c
parent3e11c4e63b2fd1e9d25cb1190e2dda1080f5942b (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r--source/blender/blenkernel/intern/armature.c8
1 files changed, 6 insertions, 2 deletions
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. */