[Bf-extensions-cvs] [18a0f95a] blender-v2.83-release: glTF exporter: fix bug export sampled animation with non 'classical' (constant/linear/bezier) interpolation

Julien Duroure noreply at git.blender.org
Sat Apr 18 09:13:43 CEST 2020


Commit: 18a0f95a848247fce2143903b520f4433ecd7163
Author: Julien Duroure
Date:   Sat Apr 18 09:12:47 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBA18a0f95a848247fce2143903b520f4433ecd7163

glTF exporter: fix bug export sampled animation with non 'classical' (constant/linear/bezier) interpolation

===================================================================

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 47e90dca..4a7b9f3c 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, 2, 64),
+    "version": (1, 2, 65),
     'blender': (2, 83, 9),
     '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 b95b576a..f2375bb1 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
@@ -271,19 +271,19 @@ def __gather_interpolation(channels: typing.Tuple[bpy.types.FCurve],
             # If only single keyframe revert to STEP
             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]
+            # If all keyframes are CONSTANT, we can use STEP.
+            if all(all(k.interpolation == 'CONSTANT' for k in c.keyframe_points) for c in channels if c is not None):
+                return 'STEP'
+
+            # Otherwise, sampled keyframes use LINEAR interpolation.
+            return 'LINEAR'
 
+    # Non-sampled keyframes implies that all keys are of the same type, and that the
+    # type is supported by glTF (because we checked in needs_baking).
     blender_keyframe = [c for c in channels if c is not None][0].keyframe_points[0]
 
-    # Select the interpolation method. Any unsupported method will fallback to STEP
+    # Select the interpolation method.
     return {
         "BEZIER": "CUBICSPLINE",
         "LINEAR": "LINEAR",



More information about the Bf-extensions-cvs mailing list