Fix T71924: Baking quaternion keyframes gives discontinuous values
This commit is contained in:
parent
2dac0c9179
commit
9467c0dcf9
Notes:
blender-bot
2023-02-14 00:06:52 +01:00
Referenced by issue #71924, Baking euler rotation to quaternions error
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue