Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hukasu
Copy link
Contributor

@hukasu hukasu commented Oct 18, 2024

Objective

Refactor the load_gltf method in bevy_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

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@IQuick143 IQuick143 added C-Code-Quality A section of code that is hard to understand or change D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-glTF Related to the glTF 3D scene/model format labels Oct 19, 2024
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Oct 19, 2024
@suprohub
Copy link

any updates?

@hukasu
Copy link
Contributor Author

hukasu commented Dec 16, 2024

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

@BenjaminBrienen BenjaminBrienen added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 22, 2025
@hukasu hukasu closed this Feb 18, 2025
@hukasu hukasu force-pushed the refactor_load_gltf branch from 3469d1a to 73970d0 Compare February 18, 2025 13:11
@hukasu
Copy link
Contributor Author

hukasu commented Feb 18, 2025

there were too many changes on bevy_gltf since my last commit, will restart from main, will reopen when i commit something

@hukasu hukasu reopened this Feb 18, 2025
@hukasu
Copy link
Contributor Author

hukasu commented Feb 18, 2025

@alice-i-cecile can we get this moving now? who would be SME on this topic to do the reviews?

Copy link
Contributor

@thepackett thepackett left a 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.

@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Feb 20, 2025
Copy link
Contributor

@andriyDev andriyDev left a 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.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 20, 2025
@hukasu
Copy link
Contributor Author

hukasu commented Feb 20, 2025

@andriyDev see if this solution is satisfactory

Copy link
Contributor

@rparrett rparrett left a 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.

@hukasu hukasu requested review from rparrett and andriyDev February 20, 2025 15:42
@alice-i-cecile alice-i-cecile removed this from the 0.16 milestone Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-glTF Related to the glTF 3D scene/model format C-Code-Quality A section of code that is hard to understand or change D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants