From 1d0bcae019f20ae1e78186563c2f7e3e97109f05 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 4 Aug 2024 02:23:01 -0700 Subject: [PATCH] GLTF: Propagate owner for root node children (cherry picked from commit 246cc7e86de951c8eb8475397bb07dc6631142a3) --- modules/gltf/gltf_document.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index dff1e62e824..ec4b240ff89 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5658,6 +5658,15 @@ void GLTFDocument::_generate_scene_node(Ref p_state, const GLTFNodeIn if (p_scene_root == nullptr) { // If the root node argument is null, this is the root node. p_scene_root = current_node; + // If multiple nodes were generated under the root node, ensure they have the owner set. + if (unlikely(current_node->get_child_count() > 0)) { + Array args; + args.append(p_scene_root); + for (int i = 0; i < current_node->get_child_count(); i++) { + Node *child = current_node->get_child(i); + child->propagate_call(StringName("set_owner"), args); + } + } } else { // Add the node we generated and set the owner to the scene root. p_scene_parent->add_child(current_node, true);