-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Refactor GltfLoader::load_gltf
#15994
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
any updates? |
The team is focused on 0.15.1, i'm in wait until 0.16 becames the target, then i will merge and do the comments |
3469d1a
to
73970d0
Compare
there were too many changes on bevy_gltf since my last commit, will restart from main, will reopen when i commit something |
@alice-i-cecile can we get this moving now? who would be SME on this topic to do the reviews? |
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.
Overall this seems like a good PR. Having read through the GltfLoader code before, this is a significant improvement. I ran CI locally successfully and was able to confirm that examples using Gltf assets were working as expected. The only question I have is whether or not the extension traits should be public or not.
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 am not a fan of how many extension traits there are. This doesn't seem necessary, and results in a bunch of tiny files which hurts readability IMO. For example crates/bevy_gltf/src/ext/scene.rs
is a whopping 14 lines. Jumping to this file just to see "oh this is just an extension trait" is quite underwhelming.
I would prefer just free functions for most of these (like the original implementation), just organized into modules more. For example, rather than node.node_name()
, we just have node_name(&node)
and node_transform(&node)
and so on. But with the important part being that node_name
and node_transform
should be in a mod node
.
One case where "extension traits" is likely desirable is labels - these could all be a single trait ToLabel
which Scene, Skin, Texture, etc can implement. Now all these disparate label stuffs can be brought under one roof and we can see how all of these are really the same thing over and over again. Of course whether this really is the way we want to go I'm not sure (for example Skin already breaks this pattern since it wants a inverse_bind_matrics_label
version - though this could just sit next to the trait implementations as inverse_bind_matrics_label_for_skin
to again keep the similar implementations together.
@andriyDev see if this solution is satisfactory |
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 added some specific suggestions about the ext
module, though I think I generally agree that this is feeling excessively "enterprise-grade."
I don't really agree with the way the changeset is presented. The current arrangement of "the loader stuff is in loader.rs" is logical and not necessarily worse than an "arbitrary" split.
Objective
Refactor the
load_gltf
method inbevy_gltf/loader.rs
, the criteria for the split is kind of arbitrary but at least it is not a 2.6k line file.Solution
Move methods and structs found in
bevy_gltf/loader.rs
into multiple new modules.Testing
cargo run -p ci