Skip to content

Commit

Permalink
Fix #254 fix some antipodal quaternion issue for bones
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduroure committed Feb 1, 2019
1 parent 2924ab3 commit d02a6b5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions addons/io_scene_gltf2/blender/imp/gltf2_blender_animation_bone.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,20 @@ def parse_rotation_channel(gltf, node, obj, bone, channel, animation):

if animation.samplers[channel.sampler].interpolation == "CUBICSPLINE":
# TODO manage tangent?
quat_keyframes = (
quat_keyframes = [
quaternion_gltf_to_blender(values[idx * 3 + 1])
for idx in range(0, len(keys))
)
]
else:
quat_keyframes = (quaternion_gltf_to_blender(vals) for vals in values)
quat_keyframes = [quaternion_gltf_to_blender(vals) for vals in values]

# Manage antipodal quaternions
# (but is not suffisant, we also convert quaternion --> euler --> quaternion)
for i in range(1, len(quat_keyframes)):
if quat_keyframes[i].dot(quat_keyframes[i-1]) < 0:
quat_keyframes[i] = -quat_keyframes[i]


if not node.parent:
if bpy.app.version < (2, 80, 0):
final_rots = [
Expand Down

0 comments on commit d02a6b5

Please sign in to comment.