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:
authorCampbell Barton <ideasman42@gmail.com>2019-11-26 17:51:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-11-26 18:00:14 +0300
commitd29cf49e9abea73e7e115d6164de11d1d5afd339 (patch)
treedcd64e071d7cd47794eb0a1bf9a3ee798a7479f4 /source/blender/blenlib/intern/math_rotation.c
parent97dff0ca764042c97feceb5d33a4766098090d2e (diff)
Fix quaternion compatibility function
Use closest quaternion instead of only checking w sign flipping, which didn't catch all cases. T
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 94f0f523c6e..2a6652fa424 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -212,11 +212,13 @@ void quat_to_compatible_quat(float q[4], const float a[4], const float old[4])
float old_unit[4];
/* Skips `!finite_v4(old)` case too. */
if (normalize_qt_qt(old_unit, old) > eps) {
+ float q_negate[4];
float delta[4];
rotation_between_quats_to_quat(delta, old_unit, a);
mul_qt_qtqt(q, old, delta);
- if ((q[0] < 0.0f) != (old[0] < 0.0f)) {
- negate_v4(q);
+ negate_v4_v4(q_negate, q);
+ if (len_squared_v4v4(q_negate, old) < len_squared_v4v4(q, old)) {
+ copy_qt_qt(q, q_negate);
}
}
else {