GLTF: Allow parsing glTF files without nodes #107836
Open
+38
−29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows parsing glTF files that contain no nodes. Such files, well, have no nodes, so the best we can do is import an empty scene. However, this adds flexibility, allowing for us to support non-scene glTF files in the engine in the future, and allows users to handle such files in their own code if they wish.
I think this is best explained with a diagram:
glTF files without nodes are explicitly supported by the glTF specification:
... so this allows Godot to parse such files, even if they have no nodes so result in an empty Godot scene.
Trivial example. This imports correctly with this PR, but errors too early in the current master, which makes it fail to import, even though the file is spec-compliant. gltf_file_without_nodes_imported_as_a_mesh_instance.zip
Another trivial example. This file can now be imported:
I also renamed some variables in
GLTFDocument::generate_scene
for clarity, including a duplicatedstate
vsp_state
.