From 377bb55566366b65c7bd71df3fdd935f8f3b4b26 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 17 Jan 2014 20:08:08 +0100 Subject: [PATCH] Fix T36190: Rigid Body bake to keyframes bakes wrong the rotations. Make sure that quaternions are compatible. --- release/scripts/startup/bl_operators/rigidbody.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py index e28d4284b6e..c1c73ffd419 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()