glTF exporter: better 'selection only' management
This now works when selection does not include armature or any descendant of armature. For other cases, all bones are still exported
This commit is contained in:
parent
5bffedce24
commit
e7f2213435
Notes:
blender-bot
2023-02-14 18:42:25 +01:00
Referenced by issue #87093, GLTF 2.0 export includes hidden armatures in disabled collections Referenced by issue #84506, glTF 2.0 export with "selected objects only" exports all armatures on the scene
|
@ -15,7 +15,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": (1, 7, 27),
|
||||
"version": (1, 7, 28),
|
||||
'blender': (2, 91, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -49,7 +49,7 @@ def gather_node(blender_object, library, blender_scene, dupli_object_parent, exp
|
|||
|
||||
@cached
|
||||
def __gather_node(blender_object, library, blender_scene, dupli_object_parent, export_settings):
|
||||
children = __gather_children(blender_object, blender_scene, export_settings)
|
||||
children, only_bone_children = __gather_children(blender_object, blender_scene, export_settings)
|
||||
|
||||
camera = None
|
||||
mesh = None
|
||||
|
@ -64,6 +64,12 @@ def __gather_node(blender_object, library, blender_scene, dupli_object_parent, e
|
|||
# This node should be filtered out, but has un-filtered children present.
|
||||
# So, export this node, excluding its camera, mesh, skin, and weights.
|
||||
# The transformations and animations on this node will have visible effects on children.
|
||||
|
||||
# Armature always have children node(s) (that are bone(s))
|
||||
# We have to check if children are only bones or not for armatures
|
||||
if blender_object.type == "ARMATURE" and only_bone_children is True:
|
||||
return None
|
||||
|
||||
pass
|
||||
else:
|
||||
# This node is filtered out, and has no un-filtered children or descendants.
|
||||
|
@ -158,6 +164,7 @@ def __gather_camera(blender_object, export_settings):
|
|||
|
||||
def __gather_children(blender_object, blender_scene, export_settings):
|
||||
children = []
|
||||
only_bone_children = True # True by default, will be set to False if needed
|
||||
# standard children
|
||||
for _child_object in blender_object.children:
|
||||
if _child_object.parent_bone:
|
||||
|
@ -173,6 +180,7 @@ def __gather_children(blender_object, blender_scene, export_settings):
|
|||
blender_scene, None, export_settings)
|
||||
if node is not None:
|
||||
children.append(node)
|
||||
only_bone_children = False
|
||||
# blender dupli objects
|
||||
if blender_object.instance_type == 'COLLECTION' and blender_object.instance_collection:
|
||||
for dupli_object in blender_object.instance_collection.objects:
|
||||
|
@ -185,6 +193,7 @@ def __gather_children(blender_object, blender_scene, export_settings):
|
|||
blender_scene, blender_object.name, export_settings)
|
||||
if node is not None:
|
||||
children.append(node)
|
||||
only_bone_children = False
|
||||
|
||||
# blender bones
|
||||
if blender_object.type == "ARMATURE":
|
||||
|
@ -201,6 +210,8 @@ def __gather_children(blender_object, blender_scene, export_settings):
|
|||
root_joints.append(joint)
|
||||
# handle objects directly parented to bones
|
||||
direct_bone_children = [child for child in blender_object.children if child.parent_bone]
|
||||
if len(direct_bone_children) != 0:
|
||||
only_bone_children = False
|
||||
def find_parent_joint(joints, name):
|
||||
for joint in joints:
|
||||
if joint.name == name:
|
||||
|
@ -246,7 +257,7 @@ def __gather_children(blender_object, blender_scene, export_settings):
|
|||
|
||||
parent_joint.children.append(child_node)
|
||||
|
||||
return children
|
||||
return children, only_bone_children
|
||||
|
||||
|
||||
def __gather_extensions(blender_object, export_settings):
|
||||
|
|
Loading…
Reference in New Issue