KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.49k stars 317 forks source link

Export failure when enabling "Always Sample Animations" #683

Closed williamAlhant closed 5 years ago

williamAlhant commented 5 years ago

Describe the bug I get the following stack trace when trying to export as gltf.

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\__init__.py", line 420, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 40, in save
    json, buffer = __export(export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 54, in __export
    __gather_gltf(exporter, export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 69, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 38, in gather_gltf2
    animations += __gather_animations(blender_scene, export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 70, in __gather_animations
    animations_, merged_tracks = gltf2_blender_gather_animations.gather_animations(blender_object, merged_tracks, len(animations), export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animations.py", line 64, in gather_animations
    animation = __gather_animation(blender_action, blender_object, export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animations.py", line 94, in __gather_animation
    channels=__gather_channels(blender_action, blender_object, export_settings),
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animations.py", line 128, in __gather_channels
    blender_action, blender_object, export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_channels.py", line 66, in gather_animation_channels
    blender_action.name)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_channels.py", line 115, in __gather_animation_channel
    sampler=__gather_sampler(channels, blender_object, export_settings, bake_bone, bake_channel, bake_range_start, bake_range_end, action_name),
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_channels.py", line 160, in __gather_sampler
    export_settings
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_samplers.py", line 62, in gather_animation_sampler
    bake_bone, bake_channel, bake_range_start, bake_range_end, action_name, export_settings),
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_samplers.py", line 184, in __gather_input
    export_settings)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_sampler_keyframes.py", line 195, in gather_keyframes
    while frame <= end_frame:
TypeError: '<=' not supported between instances of 'NoneType' and 'NoneType'

To Reproduce

.blend file/ .gltf anim1.zip

Version

Additional context Just for information, this is originally a blender file I got from some website, with an already skinned model. The animation is from me though.

julienduroure commented 5 years ago

Root cause : An action has no channels. This case is handle when using fcruve keyframes, but not when sampling animation. Will add a check

williamAlhant commented 5 years ago

Thanks