Skip to content
Snippets Groups Projects
Commit 09d752e8 authored by Julien Duroure's avatar Julien Duroure
Browse files

glTF exporter: export all actions of a single armature is now under an export option

parent 4bf15a06
No related branches found
No related tags found
No related merge requests found
......@@ -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, 3, 11),
"version": (3, 3, 12),
'blender': (3, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
......@@ -395,6 +395,15 @@ class ExportGLTF2_Base:
default=False
)
export_anim_single_armature: BoolProperty(
name='Export all Armature Actions',
description=(
"Export all actions of a single armature. "
"WARNING: works only if you exports a single armature"
),
default=True
)
export_current_frame: BoolProperty(
name='Use Current Frame',
description='Export the scene in the current animation frame',
......@@ -577,11 +586,13 @@ class ExportGLTF2_Base:
export_settings['gltf_nla_strips'] = self.export_nla_strips
export_settings['gltf_nla_strips_merged_animation_name'] = self.export_nla_strips_merged_animation_name
export_settings['gltf_optimize_animation'] = self.optimize_animation_size
export_settings['gltf_export_anim_single_armature'] = self.export_anim_single_armature
else:
export_settings['gltf_frame_range'] = False
export_settings['gltf_move_keyframes'] = False
export_settings['gltf_force_sampling'] = False
export_settings['gltf_optimize_animation'] = False
export_settings['gltf_export_anim_single_armature'] = False
export_settings['gltf_skins'] = self.export_skins
if self.export_skins:
export_settings['gltf_all_vertex_influences'] = self.export_all_influences
......@@ -874,6 +885,7 @@ class GLTF_PT_export_animation_export(bpy.types.Panel):
if operator.export_nla_strips is False:
layout.prop(operator, 'export_nla_strips_merged_animation_name')
layout.prop(operator, 'optimize_animation_size')
layout.prop(operator, 'export_anim_single_armature')
class GLTF_PT_export_animation_shapekeys(bpy.types.Panel):
......
......@@ -319,20 +319,21 @@ def __get_blender_actions(blender_object: bpy.types.Object,
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 Shapekey animation)
for act in [a for a in bpy.data.actions if a.id_root == "OBJECT"]:
# We need to check this is an armature action
# Checking that at least 1 bone is animated
if not __is_armature_action(act):
continue
# Check if this action is already taken into account
if act.name in blender_tracks.keys():
continue
blender_actions.append(act)
blender_tracks[act.name] = None
action_on_type[act.name] = "OBJECT"
if export_settings['gltf_export_anim_single_armature'] is True:
if blender_object.type == "ARMATURE":
if len(export_settings['vtree'].get_all_node_of_type(VExportNode.ARMATURE)) == 1:
# Keep all actions on objects (no Shapekey animation)
for act in [a for a in bpy.data.actions if a.id_root == "OBJECT"]:
# We need to check this is an armature action
# Checking that at least 1 bone is animated
if not __is_armature_action(act):
continue
# Check if this action is already taken into account
if act.name in blender_tracks.keys():
continue
blender_actions.append(act)
blender_tracks[act.name] = None
action_on_type[act.name] = "OBJECT"
export_user_extensions('gather_actions_hook', export_settings, blender_object, blender_actions, blender_tracks, action_on_type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment