diff options
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py | 15 |
1 files changed, 15 insertions, 0 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 65335534..6473f5de 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py @@ -33,12 +33,27 @@ def gather_animations(blender_object: bpy.types.Object, export_settings) -> typi # Collect all 'actions' affecting this object. There is a direct mapping between blender actions and glTF animations blender_actions = __get_blender_actions(blender_object) + # save the current active action of the object, if any + # We will restore it after export + current_action = None + if blender_object.animation_data and blender_object.animation_data.action: + current_action = blender_object.animation_data.action + # Export all collected actions. for blender_action in blender_actions: + + # 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 + animation = __gather_animation(blender_action, blender_object, export_settings) if animation is not None: animations.append(animation) + # Restore current action + if blender_object.animation_data: + blender_object.animation_data.action = current_action + return animations |