[Bf-extensions-cvs] [9818afc8] master: glTF exporter: Armature extports all actions
Julien Duroure
noreply at git.blender.org
Tue Mar 29 17:54:23 CEST 2022
Commit: 9818afc829a06185440c431e520016f1d4286d06
Author: Julien Duroure
Date: Tue Mar 29 17:54:13 2022 +0200
Branches: master
https://developer.blender.org/rBA9818afc829a06185440c431e520016f1d4286d06
glTF exporter: Armature extports all actions
When scene contains only 1 armature, it will export all actions, not only active + NLA
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index d08c39dd..9bb1939f 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,7 +4,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": (3, 2, 20),
+ "version": (3, 2, 21),
'blender': (3, 1, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
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 c56517fb..0a513521 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
@@ -9,6 +9,7 @@ from io_scene_gltf2.blender.exp import gltf2_blender_gather_animation_channels
from io_scene_gltf2.io.com.gltf2_io_debug import print_console
from ..com.gltf2_blender_extras import generate_extras
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions
+from io_scene_gltf2.blender.exp.gltf2_blender_gather_tree import VExportNode
def __gather_channels_baked(obj_uuid, export_settings):
@@ -307,6 +308,15 @@ def __get_blender_actions(blender_object: bpy.types.Object,
blender_tracks[strip.action.name] = track.name # Always set after possible active action -> None will be overwrite
action_on_type[strip.action.name] = "SHAPEKEY"
+ # If there are only 1 armature, include all animations, even if not in NLA
+ if blender_object.type == "ARMATURE":
+ if len(export_settings['vtree'].get_all_node_of_type(VExportNode.ARMATURE)) == 1:
+ # Keep all actions on objects (no keyframe animation)
+ # Some other object animation can be added here, and will affect armature object itself :-/
+ for act in [a for a in bpy.data.actions if a.id_root == "OBJECT"]:
+ blender_actions.append(act)
+ blender_tracks[act.name] = None
+
export_user_extensions('gather_actions_hook', export_settings, blender_object, blender_actions, blender_tracks, action_on_type)
# Remove duplicate actions.
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
index 3a7b0fa5..cf4983e1 100644
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
@@ -244,6 +244,9 @@ class VExportTree:
else:
return []
+ def get_all_node_of_type(self, node_type):
+ return [n.uuid for n in self.nodes.values() if n.blender_type == node_type]
+
def display(self, mode):
if mode == "simple":
for n in self.roots:
More information about the Bf-extensions-cvs
mailing list