[Bf-extensions-cvs] [b90cbbdf] master: glTF exporter: Keep CONSTANT/STEP animation when sample animations (object only for now, not bones)
Julien Duroure
noreply at git.blender.org
Sat Jan 4 21:17:39 CET 2020
Commit: b90cbbdf48014e02331aa0d6594537444bffaf98
Author: Julien Duroure
Date: Sat Jan 4 21:16:56 2020 +0100
Branches: master
https://developer.blender.org/rBAb90cbbdf48014e02331aa0d6594537444bffaf98
glTF exporter: Keep CONSTANT/STEP animation when sample animations (object only for now, not bones)
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index c8067771..7f82b657 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (1, 1, 31),
+ "version": (1, 1, 32),
'blender': (2, 81, 6),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
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]
More information about the Bf-extensions-cvs
mailing list