Open aaronfranke opened 1 year ago
My work would benefit immensely from this for importing scenes. I have hundreds of unnecessary Node3D
s in even small levels because of the extra scene root that's created when a GLTF scene is imported.
What is left to do to finish implementing this?
@and-rad Points 1 to 4 are done, exporting from Godot will save a flag that tells Godot about the root node. The last part of this proposal is the optional idea of overriding this for files without this flag, which I am not sure is needed (but from your comment it sounds like you would find that useful).
For the multi-root option, I wonder if it would be possible to export as multiple separate scene files for each node & child (maybe linked together in a full scene). This way you still maintain edit-ability and can derive the individual scenes while still having it update from file.
This would help a lot for things like rigid bodies and prop libraries, since it would import as multiple reusable scenes for each prop (and for rigid bodies, allow you to derive the sub-tree you need with collision shapes)
@Aman-Anas I just recently made something very similar: glTFX support for Godot. It allows you to export a scene containing multiple scenes as multiple glTF files linked together in a glTFX representing the full scene.
Describe the project you are working on
I am working on glTF support in Godot.
Describe the problem or limitation you are having in your project
Currently, when you import a glTF file in Godot, the glTF root nodes will be added as a child of the "real" root node. This is done because glTF supports multiple root nodes in a scene, but Godot only has one root node per scene. This means that on import an extra root node will be created, and there is no way for the glTF file to customize this extra "real" root node. One possible solution would be to treat the glTF root as the Godot scene root if there is just one, but due to the possibility of there being multiple root nodes, this is not sensible to do automatically.
Currently, when you export a glTF file in Godot, the root node of the Godot scene will always be placed as the root node of the glTF scene. This means that if you round-trip a scene out of Godot and back in, there will be an extra root node. There is no way to export a glTF file in a way that indicates an extra root node should not be created, and there is no way to export a glTF file from Godot in a way that has multiple root nodes.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The proposal is to do the following things:
GODOT_single_root
which specifies that a glTF file's root node is expected to be treated as the real single root node of the scene and imposes restrictions to ensure this works without issues.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
[x] Point 1 is about writing a spec, which is done, and does not directly need any engine changes.
[x] Points 2 and 3 are implemented in this PR: https://github.com/godotengine/godot/pull/81851
[x] Point 4 will have to wait until we have export settings in the export dialog, see https://github.com/godotengine/godot/pull/79316
[ ] Point 5 is about overriding, so it's not as important as the rest of the points which deal with the file contents and ensuring Godot reads/writes this as best as possible, and if desired it should be done after the rest is merged.
If this enhancement will not be used often, can it be worked around with a few lines of script?
This will be used often. It is possible to work around in script, but only in a hacky way.
Is there a reason why this should be core and not an add-on in the asset library?
Root nodes are a part of Godot, and glTF support is core.