From 72f00333ddcc157a1f6eb5e626bf1bfb86c4be30 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 4 Feb 2024 20:30:56 -0600 Subject: [PATCH] [4.1] Fix crash when importing a GLTF file with a skeleton as the root --- modules/gltf/gltf_document.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 5e066db8312b..dea7bde56cc7 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5836,8 +5836,13 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref p_state, Node *p_ p_scene_parent = bone_attachment; } if (skeleton->get_parent() == nullptr) { - p_scene_parent->add_child(skeleton, true); - skeleton->set_owner(p_scene_root); + if (p_scene_root) { + p_scene_parent->add_child(skeleton, true); + skeleton->set_owner(p_scene_root); + } else { + p_scene_parent = skeleton; + p_scene_root = skeleton; + } } } @@ -6442,7 +6447,7 @@ void GLTFDocument::_process_mesh_instances(Ref p_state, Node *p_scene mi->get_parent()->remove_child(mi); skeleton->add_child(mi, true); - mi->set_owner(skeleton->get_owner()); + mi->set_owner(p_scene_root); mi->set_skin(p_state->skins.write[skin_i]->godot_skin); mi->set_skeleton_path(mi->get_path_to(skeleton));