2
0
Эх сурвалжийг харах

Merge pull request #103332 from aaronfranke/gltf-no-orphans

GLTF: Use scene root nodes for root nodes, don't include orphan nodes
Rémi Verschelde 3 сар өмнө
parent
commit
aa0eb50d45

+ 8 - 3
modules/gltf/gltf_document.cpp

@@ -690,7 +690,9 @@ Error GLTFDocument::_parse_nodes(Ref<GLTFState> p_state) {
 }
 
 void GLTFDocument::_compute_node_heights(Ref<GLTFState> p_state) {
-	p_state->root_nodes.clear();
+	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,8 +706,11 @@ void GLTFDocument::_compute_node_heights(Ref<GLTFState> p_state) {
 			current_i = parent_i;
 		}
 
-		if (node->height == 0) {
-			p_state->root_nodes.push_back(node_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);
+			}
 		}
 	}
 }