[Bf-blender-cvs] [377bb55] master: Fix T36190: Rigid Body bake to keyframes bakes wrong the rotations.

Sergej Reich noreply at git.blender.org
Fri Jan 17 20:10:57 CET 2014


Commit: 377bb55566366b65c7bd71df3fdd935f8f3b4b26
Author: Sergej Reich
Date:   Fri Jan 17 20:08:08 2014 +0100
https://developer.blender.org/rB377bb55566366b65c7bd71df3fdd935f8f3b4b26

Fix T36190: Rigid Body bake to keyframes bakes wrong the rotations.

Make sure that quaternions are compatible.

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

M	release/scripts/startup/bl_operators/rigidbody.py

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

diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py
index e28d428..c1c73ff 100644
--- a/release/scripts/startup/bl_operators/rigidbody.py
+++ b/release/scripts/startup/bl_operators/rigidbody.py
@@ -145,7 +145,13 @@ class BakeToKeyframes(Operator):
 
                     rot_mode = obj.rotation_mode
                     if rot_mode == 'QUATERNION':
-                        obj.rotation_quaternion = mat.to_quaternion()
+                        q1 = obj.rotation_quaternion
+                        q2 = mat.to_quaternion()
+                        # make quaternion compatible with the previous one
+                        if (q1.dot(q2) < 0):
+                            obj.rotation_quaternion = -q2
+                        else:
+                            obj.rotation_quaternion = q2
                     elif rot_mode == 'AXIS_ANGLE':
                         # this is a little roundabout but there's no better way right now
                         aa = mat.to_quaternion().to_axis_angle()




More information about the Bf-blender-cvs mailing list