diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-06-01 20:56:28 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-06-01 20:57:00 +0300 |
commit | c7aa80f40ae438618498bc678409a4260f4356ab (patch) | |
tree | 0d7a960ed391fd66d3792b99aabd64695893b050 /io_scene_gltf2/blender | |
parent | 8751250b919d1c0955cf2a24fcacbdd3e408fba6 (diff) |
glTF exporter: add some NLA checks (readonly action / track)
Diffstat (limited to 'io_scene_gltf2/blender')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py index 6473f5de..7a4f1213 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py @@ -44,7 +44,19 @@ def gather_animations(blender_object: bpy.types.Object, export_settings) -> typi # Set action as active, to be able to bake if needed if blender_object.animation_data: # Not for shapekeys! - blender_object.animation_data.action = blender_action + if blender_object.animation_data.action is None \ + or (blender_object.animation_data.action.name != blender_action.name): + if blender_object.animation_data.is_property_readonly('action'): + # NLA stuff: some track are on readonly mode, we can't change action + error = "Action is readonly. Please check NLA editor" + print_console("WARNING", "Animation '{}' could not be exported. Cause: {}".format(blender_action.name, error)) + continue + try: + blender_object.animation_data.action = blender_action + except: + error = "Action is readonly. Please check NLA editor" + print_console("WARNING", "Animation '{}' could not be exported. Cause: {}".format(blender_action.name, error)) + continue animation = __gather_animation(blender_action, blender_object, export_settings) if animation is not None: @@ -52,7 +64,8 @@ def gather_animations(blender_object: bpy.types.Object, export_settings) -> typi # Restore current action if blender_object.animation_data: - blender_object.animation_data.action = current_action + if blender_object.animation_data.action is not None and current_action is not None and blender_object.animation_data.action.name != current_action.name: + blender_object.animation_data.action = current_action return animations |