diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-11-26 17:57:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-11-26 18:00:14 +0300 |
commit | 9467c0dcf9bd0d91d40a63e885a565274323daef (patch) | |
tree | 60613e93416de8dd46cb125876e9c8012a6687b7 /release/scripts/modules/bpy_extras | |
parent | 2dac0c91791091f794303a4a0fc5fbad1cf5064c (diff) |
Fix T71924: Baking quaternion keyframes gives discontinuous values
Diffstat (limited to 'release/scripts/modules/bpy_extras')
-rw-r--r-- | release/scripts/modules/bpy_extras/anim_utils.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py index 1ef97b24a3f..e402c9cb53c 100644 --- a/release/scripts/modules/bpy_extras/anim_utils.py +++ b/release/scripts/modules/bpy_extras/anim_utils.py @@ -268,8 +268,9 @@ def bake_action_iter( while pbone.constraints: pbone.constraints.remove(pbone.constraints[0]) - # create compatible eulers + # Create compatible eulers, quats. euler_prev = None + quat_prev = None for (f, matrix, bbones) in pose_info: pbone.matrix_basis = matrix[name].copy() @@ -278,6 +279,14 @@ def bake_action_iter( rotation_mode = pbone.rotation_mode if rotation_mode == 'QUATERNION': + if quat_prev is not None: + quat = pbone.rotation_quaternion.copy() + quat.make_compatible(quat_prev) + pbone.rotation_quaternion = quat + quat_prev = quat + del quat + else: + quat_prev = pbone.rotation_quaternion.copy() pbone.keyframe_insert("rotation_quaternion", index=-1, frame=f, group=name, options=options) elif rotation_mode == 'AXIS_ANGLE': pbone.keyframe_insert("rotation_axis_angle", index=-1, frame=f, group=name, options=options) @@ -308,8 +317,9 @@ def bake_action_iter( while obj.constraints: obj.constraints.remove(obj.constraints[0]) - # create compatible eulers + # Create compatible eulers, quats. euler_prev = None + quat_prev = None for (f, matrix) in obj_info: name = "Action Bake" # XXX: placeholder @@ -319,6 +329,15 @@ def bake_action_iter( rotation_mode = obj.rotation_mode if rotation_mode == 'QUATERNION': + if quat_prev is not None: + quat = obj.rotation_quaternion.copy() + quat.make_compatible(quat_prev) + obj.rotation_quaternion = quat + quat_prev = quat + del quat + print ("quat_prev", quat_prev) + else: + quat_prev = obj.rotation_quaternion.copy() obj.keyframe_insert("rotation_quaternion", index=-1, frame=f, group=name, options=options) elif rotation_mode == 'AXIS_ANGLE': obj.keyframe_insert("rotation_axis_angle", index=-1, frame=f, group=name, options=options) |