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

Fix FBX and glTF when root nodes are skeleton bones #90789

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions modules/fbx/fbx_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,9 @@ void FBXDocument::_generate_skeleton_bone_node(Ref<FBXState> p_state, const GLTF

active_skeleton = skeleton;
current_node = active_skeleton;
if (active_skeleton) {
p_scene_parent = active_skeleton;
}

if (requires_extra_node) {
current_node = nullptr;
Expand Down Expand Up @@ -2019,8 +2022,8 @@ Node *FBXDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, bool
GLTFNodeIndex fbx_root = state->root_nodes.write[0];
Node *fbx_root_node = state->get_scene_node(fbx_root);
Node *root = fbx_root_node;
if (fbx_root_node && fbx_root_node->get_parent()) {
root = fbx_root_node->get_parent();
if (root && root->get_owner() && root->get_owner() != root) {
root = root->get_owner();
}
ERR_FAIL_NULL_V(root, nullptr);
_process_mesh_instances(state, root);
Expand Down
6 changes: 6 additions & 0 deletions modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down
Loading