mirror of
https://github.com/blender/blender-addons.git
synced 2025-08-16 15:35:05 +00:00
glTF exporter: Fix Real children of instance collection visibility check
This commit is contained in:
@ -5,7 +5,7 @@
|
|||||||
bl_info = {
|
bl_info = {
|
||||||
'name': 'glTF 2.0 format',
|
'name': 'glTF 2.0 format',
|
||||||
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
||||||
"version": (4, 0, 21),
|
"version": (4, 0, 22),
|
||||||
'blender': (4, 0, 0),
|
'blender': (4, 0, 0),
|
||||||
'location': 'File > Import-Export',
|
'location': 'File > Import-Export',
|
||||||
'description': 'Import-Export as glTF 2.0',
|
'description': 'Import-Export as glTF 2.0',
|
||||||
|
@ -31,8 +31,15 @@ class VExportNode:
|
|||||||
PARENT_BONE_BONE = 55
|
PARENT_BONE_BONE = 55
|
||||||
|
|
||||||
|
|
||||||
|
# Children type
|
||||||
|
# Is used to split instance collection into 2 categories:
|
||||||
|
CHILDREN_REAL = 90
|
||||||
|
CHILDREN_IS_IN_COLLECTION = 91
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.children = []
|
self.children = []
|
||||||
|
self.children_type = {} # Used for children of instance collection
|
||||||
self.blender_type = None
|
self.blender_type = None
|
||||||
self.matrix_world = None
|
self.matrix_world = None
|
||||||
self.parent_type = None
|
self.parent_type = None
|
||||||
@ -107,7 +114,7 @@ class VExportTree:
|
|||||||
for blender_object in [obj.original for obj in scene_eval.objects if obj.parent is None]:
|
for blender_object in [obj.original for obj in scene_eval.objects if obj.parent is None]:
|
||||||
self.recursive_node_traverse(blender_object, None, None, Matrix.Identity(4), False, blender_children)
|
self.recursive_node_traverse(blender_object, None, None, Matrix.Identity(4), False, blender_children)
|
||||||
|
|
||||||
def recursive_node_traverse(self, blender_object, blender_bone, parent_uuid, parent_coll_matrix_world, delta, blender_children, armature_uuid=None, dupli_world_matrix=None):
|
def recursive_node_traverse(self, blender_object, blender_bone, parent_uuid, parent_coll_matrix_world, delta, blender_children, armature_uuid=None, dupli_world_matrix=None, is_children_in_collection=False):
|
||||||
node = VExportNode()
|
node = VExportNode()
|
||||||
node.uuid = str(uuid.uuid4())
|
node.uuid = str(uuid.uuid4())
|
||||||
node.parent_uuid = parent_uuid
|
node.parent_uuid = parent_uuid
|
||||||
@ -116,6 +123,8 @@ class VExportTree:
|
|||||||
# add to parent if needed
|
# add to parent if needed
|
||||||
if parent_uuid is not None:
|
if parent_uuid is not None:
|
||||||
self.add_children(parent_uuid, node.uuid)
|
self.add_children(parent_uuid, node.uuid)
|
||||||
|
if self.nodes[parent_uuid].blender_type == VExportNode.COLLECTION:
|
||||||
|
self.nodes[parent_uuid].children_type[node.uuid] = VExportNode.CHILDREN_IS_IN_COLLECTION if is_children_in_collection is True else VExportNode.CHILDREN_REAL
|
||||||
else:
|
else:
|
||||||
self.roots.append(node.uuid)
|
self.roots.append(node.uuid)
|
||||||
|
|
||||||
@ -242,7 +251,7 @@ class VExportTree:
|
|||||||
for dupli_object in blender_object.instance_collection.all_objects:
|
for dupli_object in blender_object.instance_collection.all_objects:
|
||||||
if dupli_object.parent is not None:
|
if dupli_object.parent is not None:
|
||||||
continue
|
continue
|
||||||
self.recursive_node_traverse(dupli_object, None, node.uuid, node.matrix_world, new_delta or delta, blender_children)
|
self.recursive_node_traverse(dupli_object, None, node.uuid, node.matrix_world, new_delta or delta, blender_children, is_children_in_collection=True)
|
||||||
|
|
||||||
# Armature : children are bones with no parent
|
# Armature : children are bones with no parent
|
||||||
if blender_object.type == "ARMATURE" and blender_bone is None:
|
if blender_object.type == "ARMATURE" and blender_bone is None:
|
||||||
@ -330,7 +339,11 @@ class VExportTree:
|
|||||||
|
|
||||||
for child in self.nodes[uuid].children:
|
for child in self.nodes[uuid].children:
|
||||||
if self.nodes[uuid].blender_type == VExportNode.COLLECTION:
|
if self.nodes[uuid].blender_type == VExportNode.COLLECTION:
|
||||||
self.recursive_filter_tag(child, self.nodes[uuid].keep_tag)
|
# We need to split children into 2 categories: real children, and objects inside the collection
|
||||||
|
if self.nodes[uuid].children_type[child] == VExportNode.CHILDREN_IS_IN_COLLECTION:
|
||||||
|
self.recursive_filter_tag(child, self.nodes[uuid].keep_tag)
|
||||||
|
else:
|
||||||
|
self.recursive_filter_tag(child, parent_keep_tag)
|
||||||
else:
|
else:
|
||||||
self.recursive_filter_tag(child, parent_keep_tag)
|
self.recursive_filter_tag(child, parent_keep_tag)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user