Commit: d29cf49e9abea73e7e115d6164de11d1d5afd339
Author: Campbell Barton
Date:   Wed Nov 27 01:51:41 2019 +1100
Branches: master
https://developer.blender.org/rBd29cf49e9abea73e7e115d6164de11d1d5afd339

Fix quaternion compatibility function

Use closest quaternion instead of only checking w sign flipping,
which didn't catch all cases.

T

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

M       source/blender/blenlib/intern/math_rotation.c

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

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 {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to