[Bf-extensions-cvs] [72599842] master: glTF exporter: add some checks on animation data, fixing error with weird files

Julien Duroure noreply at git.blender.org
Wed Aug 7 07:03:36 CEST 2019


Commit: 72599842ab5bceaeec46623f382f3af2c3715d3b
Author: Julien Duroure
Date:   Wed Aug 7 07:02:50 2019 +0200
Branches: master
https://developer.blender.org/rBA72599842ab5bceaeec46623f382f3af2c3715d3b

glTF exporter: add some checks on animation data, fixing error with weird files

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

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py

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

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index fb2423aa..1dfd167d 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": (0, 9, 44),
+    "version": (0, 9, 45),
     'blender': (2, 80, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
index 0c931ebd..412f275b 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
@@ -148,6 +148,9 @@ def __gather_target(channels: typing.Tuple[bpy.types.FCurve],
 def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.types.Object, export_settings):
     targets = {}
     for fcurve in blender_action.fcurves:
+        # In some invalid files, channel hasn't any keyframes ... this channel need to be ignored
+        if len(fcurve.keyframe_points) == 0:
+            continue
         try:
             target_property = get_target_property_name(fcurve.data_path)
         except:
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py
index a24b2298..5d7763d0 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py
@@ -181,6 +181,8 @@ def gather_keyframes(blender_object_if_armature: typing.Optional[bpy.types.Objec
     else:
         # Just use the keyframes as they are specified in blender
         frames = [keyframe.co[0] for keyframe in channels[0].keyframe_points]
+        # some weird files have duplicate frame at same time, removed them
+        frames = sorted(set(frames))
         for i, frame in enumerate(frames):
             key = Keyframe(channels, frame, bake_channel)
             # key.value = [c.keyframe_points[i].co[0] for c in action_group.channels]



More information about the Bf-extensions-cvs mailing list