-
-
Notifications
You must be signed in to change notification settings - Fork 23.8k
GLTF: Allow parsing glTF files without nodes #107836
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
Conversation
|
Why does a scene with no nodes generate an error? It should be able to import as just the root node. I understand that such a scene would not have GODOT_single_root, but without that extension, there should be no need to fail the import |
a8f9ce0 to
1a2490f
Compare
|
@lyuma That's true, we could do that, taking this PR even farther. Somehow, that did not occur to me. PR updated. Now even this glTF file can be imported: {
"asset": {
"version": "2.0"
}
} |
1a2490f to
2e2feb0
Compare
2e2feb0 to
9cce871
Compare
|
This makes sense from a design perspective, I haven't reviewed the code yet though. |
9cce871 to
54dc0d9
Compare
|
For game development, a feature like this is extremely powerful because you can use the gltf as a "3D .zip file". That data could be a bunch of different meshes from an asset pack, so that you are able to extract the resources you need without making a scene. Using scenes to export a bunch of components like this I find strange, but this PR unlocks a lot of potential by allowing developers to package assets much more efficiently for game development purposes. It changes the precedent for how gltf could be used, and I think this is very worthwhile |
lyuma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the warning. Otherwise allows using these assets
810e55f to
5d492e1
Compare
|
Thanks! |
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:
{ "asset": { "version": "2.0" } }I also renamed some variables in
GLTFDocument::generate_scenefor clarity, including a duplicatedstatevsp_state.