From 77a382ba2ffb214d9f5bd690df492ffd212f39b6 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Sat, 29 Jun 2024 09:16:02 +0200 Subject: [PATCH] glTF exporter: call hook for each action, including the active one --- .../addons_core/io_scene_gltf2/__init__.py | 2 +- .../animation/gltf2_blender_gather_action.py | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index 4292d61775a..19b50e983f8 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -5,7 +5,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (4, 2, 53), + "version": (4, 2, 54), 'blender': (4, 2, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/scripts/addons_core/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py b/scripts/addons_core/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py index 0591bb8ddcf..a2fff418f0c 100644 --- a/scripts/addons_core/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py +++ b/scripts/addons_core/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py @@ -337,6 +337,22 @@ def gather_action_animations(obj_uuid: int, "Animation '{}' could not be exported. Cause: {}".format( blender_action.name, error)) continue + else: + # No need to switch action, but we call the hook anyway, in case of user extension + export_user_extensions( + 'pre_animation_switch_hook', + export_settings, + blender_object, + blender_action, + track_name, + on_type) + export_user_extensions( + 'post_animation_switch_hook', + export_settings, + blender_object, + blender_action, + track_name, + on_type) if on_type == "SHAPEKEY": if blender_object.data.shape_keys.animation_data.action is None \ @@ -359,6 +375,22 @@ def gather_action_animations(obj_uuid: int, blender_action, track_name, on_type) + else: + # No need to switch action, but we call the hook anyway, in case of user extension + export_user_extensions( + 'pre_animation_switch_hook', + export_settings, + blender_object, + blender_action, + track_name, + on_type) + export_user_extensions( + 'post_animation_switch_hook', + export_settings, + blender_object, + blender_action, + track_name, + on_type) if export_settings['gltf_force_sampling'] is True: if export_settings['vtree'].nodes[obj_uuid].blender_object.type == "ARMATURE":