From 064d3a5730c7c7e7199fdd862f6a72efa9dc0a17 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Tue, 17 Jun 2025 12:00:31 +0200 Subject: [PATCH] glTF importer: Fix importing some file Where special nvode creation is mandatory. --- scripts/addons_core/io_scene_gltf2/__init__.py | 2 +- .../addons_core/io_scene_gltf2/blender/imp/vnode.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index 51e8cc2b3ef..b510d53b8a2 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, 5, 34), + "version": (4, 5, 35), 'blender': (4, 4, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/scripts/addons_core/io_scene_gltf2/blender/imp/vnode.py b/scripts/addons_core/io_scene_gltf2/blender/imp/vnode.py index fce1850cc45..4b36793a2ee 100644 --- a/scripts/addons_core/io_scene_gltf2/blender/imp/vnode.py +++ b/scripts/addons_core/io_scene_gltf2/blender/imp/vnode.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 import bpy +from itertools import chain from mathutils import Vector, Quaternion, Matrix from ...io.imp.gltf2_io_binary import BinaryData from ..com.gltf2_blender_math import scale_rot_swap_matrix, nearby_signed_perm_matrix @@ -242,6 +243,7 @@ def manage_gpu_instancing(gltf, vnode, i, ext, mesh_id): inst_vnode.children = [] inst_vnode.base_trs = get_inst_trs(gltf, trans_list[inst], rot_list[inst], scale_list[inst]) inst_vnode.mesh_idx = mesh_id + # Do not set scenes here, this will be handle later by recursive add_nodes_to_scene vnode.children.append(inst_id) @@ -283,6 +285,13 @@ def mark_bones_and_armas(gltf): gltf.vnodes[arma_id].type = VNode.Object gltf.vnodes[arma_id].is_arma = True gltf.vnodes[arma_id].arma_name = skin.name or 'Armature' + # Because the dummy root node is no more an dummy node, but a real armature object, + # We need to set the scenes on the vnode + gltf.vnodes[arma_id].scenes = list( + set(chain.from_iterable( + gltf.vnodes[joint].scenes for joint in skin.joints + )) + ) for joint in skin.joints: while joint != arma_id: @@ -434,6 +443,7 @@ def fixup_multitype_nodes(gltf): gltf.vnodes[new_id] = VNode() gltf.vnodes[new_id].mesh_node_idx = vnode.mesh_node_idx gltf.vnodes[new_id].parent = id + gltf.vnodes[new_id].scenes = vnode.scenes vnode.children.append(new_id) vnode.mesh_node_idx = None needs_move = True @@ -444,6 +454,7 @@ def fixup_multitype_nodes(gltf): gltf.vnodes[new_id] = VNode() gltf.vnodes[new_id].camera_node_idx = vnode.camera_node_idx gltf.vnodes[new_id].parent = id + gltf.vnodes[new_id].scenes = vnode.scenes vnode.children.append(new_id) vnode.camera_node_idx = None needs_move = True @@ -454,6 +465,7 @@ def fixup_multitype_nodes(gltf): gltf.vnodes[new_id] = VNode() gltf.vnodes[new_id].light_node_idx = vnode.light_node_idx gltf.vnodes[new_id].parent = id + gltf.vnodes[new_id].scenes = vnode.scenes vnode.children.append(new_id) vnode.light_node_idx = None needs_move = True