Fix FBX and glTF when root nodes are skeleton bones

Set p_scene_parent to the skeleton to guarantee BoneAttachment3D nodes are added as a child of the active skeleton.
Use get_owner() to go all the way up when calculating the root node in generate_scene
This commit is contained in:
Lyuma 2024-04-17 04:11:16 -07:00
parent 3b1806182a
commit d3706488d9
2 changed files with 11 additions and 2 deletions

View file

@ -5685,6 +5685,9 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> p_state, const GL
active_skeleton = skeleton;
current_node = active_skeleton;
if (active_skeleton) {
p_scene_parent = active_skeleton;
}
if (requires_extra_node) {
current_node = nullptr;
@ -7104,6 +7107,9 @@ Node *GLTFDocument::_generate_scene_node_tree(Ref<GLTFState> p_state) {
if (p_state->extensions_used.has("GODOT_single_root")) {
_generate_scene_node(p_state, 0, nullptr, nullptr);
single_root = p_state->scene_nodes[0];
if (single_root && single_root->get_owner() && single_root->get_owner() != single_root) {
single_root = single_root->get_owner();
}
} else {
single_root = memnew(Node3D);
for (int32_t root_i = 0; root_i < p_state->root_nodes.size(); root_i++) {