Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] Fix crash when importing a GLTF file with a skeleton as the root #87964

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5836,8 +5836,13 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> 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;
}
}
}

Expand Down Expand Up @@ -6442,7 +6447,7 @@ void GLTFDocument::_process_mesh_instances(Ref<GLTFState> 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));
Expand Down
Loading