-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Mesh serialization #19545
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
base: main
Are you sure you want to change the base?
Mesh serialization #19545
Conversation
I like the idea (and this is very useful), but I'm not sure what our plans are for handling Handle serialization. Pinging some experts for review. |
match self.path() { | ||
Some(asset_path) => asset_path.serialize(serializer), | ||
// Maybe this should be an error? | ||
None => AssetPath::default().serialize(serializer), |
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.
This definitely feels like it should be an error case: this will cause serious bugs if people don't catch this.
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 agree with this. I think we can return an error with S::Error::custom("blah")
.
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 don't think I'm substantially against serializing handles, though the fact that we don't have a way to deserialize them is quite sad and could lead to users asking for that (which just isn't possible in the current design).
I'm not fully clear on whether Mesh should be Serialize at all. Makes me a little uncomfy for some reason, but I won't block on that.
As an aside, I have been dreaming of doing the cursed thing and moving our asset loading stuff to a static
to resolve a bunch of our woes (but probably introduce a few more). Could be worth exploring!
match self.path() { | ||
Some(asset_path) => asset_path.serialize(serializer), | ||
// Maybe this should be an error? | ||
None => AssetPath::default().serialize(serializer), |
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 agree with this. I think we can return an error with S::Error::custom("blah")
.
Objective
Mesh
serializable.Solution
Serialize
forMesh
andHandle
(as anAssetPath
).Mesh
does not implDeserialize
because it contains a handle which aren't directly deserializable from asset paths. But it can be deserialized via reflection. I have an example of round-trip saving and loading meshes with an asset loader and reflect deserialization processor that I can submit in a following PR.Testing
cargo test -p bevy_mesh --features serialize