GLTF: Use scene root nodes for root nodes, don't include orphan nodes

This commit is contained in:
Aaron Franke
2025-02-26 13:05:04 -08:00
parent fc523ec5f6
commit 0972db7b40

View File

@@ -690,7 +690,9 @@ Error GLTFDocument::_parse_nodes(Ref<GLTFState> p_state) {
}
void GLTFDocument::_compute_node_heights(Ref<GLTFState> p_state) {
if (_naming_version < 2) {
p_state->root_nodes.clear();
}
for (GLTFNodeIndex node_i = 0; node_i < p_state->nodes.size(); ++node_i) {
Ref<GLTFNode> node = p_state->nodes[node_i];
node->height = 0;
@@ -704,11 +706,14 @@ void GLTFDocument::_compute_node_heights(Ref<GLTFState> p_state) {
current_i = parent_i;
}
if (_naming_version < 2) {
// This is incorrect, but required for compatibility with previous Godot versions.
if (node->height == 0) {
p_state->root_nodes.push_back(node_i);
}
}
}
}
static Vector<uint8_t> _parse_base64_uri(const String &p_uri) {
int start = p_uri.find_char(',');