diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-01-04 23:16:56 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-01-04 23:16:56 +0300 |
commit | b90cbbdf48014e02331aa0d6594537444bffaf98 (patch) | |
tree | 3189828ada3ce3ea500c3d61dba9bb723f1622b1 /io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py | |
parent | 289fb2b8b89e7ded42f4655342d8359e6f1ae91f (diff) |
glTF exporter: Keep CONSTANT/STEP animation when sample animations (object only for now, not bones)
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py index 4b1ebeb1..27750a72 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py @@ -257,16 +257,29 @@ def __gather_interpolation(channels: typing.Tuple[bpy.types.FCurve], bake_bone: typing.Union[str, None], bake_channel: typing.Union[str, None] ) -> str: + # Note: channels has some None items only for SK if some SK are not animated + if gltf2_blender_gather_animation_sampler_keyframes.needs_baking(blender_object_if_armature, channels, export_settings): if bake_bone is not None: + # TODO: check if the bone was animated with CONSTANT return 'LINEAR' else: max_keyframes = max([len(ch.keyframe_points) for ch in channels if ch is not None]) # If only single keyframe revert to STEP - return 'STEP' if max_keyframes < 2 else 'LINEAR' + if max_keyframes < 2: + return 'STEP' + else: + blender_keyframe = [c for c in channels if c is not None][0].keyframe_points[0] + + # For sampled animations: CONSTANT are STEP, other are LINEAR + return { + "BEZIER": "LINEAR", + "LINEAR": "LINEAR", + "CONSTANT": "STEP" + }[blender_keyframe.interpolation] blender_keyframe = [c for c in channels if c is not None][0].keyframe_points[0] |