-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix TypeRegistry use in dynamic scene #12715
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
Fix the use of `TypeRegistry` instead of `TypeRegistryArc` in dynamic scene and its serializer. Rename `DynamicScene::serialize_ron()` into `serialize()` to highlight the fact this is less about serializing to RON and more about serializing to the official Bevy scene format (`.scn` / `.scn.ron`) which the `SceneLoader` can deserialize. The fact the format is based on RON is not the object here. Document `SceneSerializer` with an example showing how to serialize to RON, which is easily transposed to serializing into any other format. Also make the link with the documentation of `SceneLoader` so users understand the full serializing cycle of a Bevy dynamic scene. Fixes bevyengine#9520
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.
No real objections other than the potential cost of allocation for the serialization. LGTM.
#[cfg(feature = "serialize")] | ||
pub fn serialize_ron(&self, registry: &TypeRegistryArc) -> Result<String, ron::Error> { | ||
pub fn serialize(&self, registry: &TypeRegistry) -> Result<String, ron::Error> { |
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.
Ideally this would support serializing the results to an arbitary output stream (i..e std::io::Write
) instead of materializing the results to a string then writing that string out.
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 should probably done in a different PR, right? The output type change seems unrelated
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.
Yes, different PR
CI seems to have a bug, @mockersf do you know about this? Looking at CI miri, it complains about duplicate sysroot. Unrelated to this PR. |
Co-authored-by: Gino Valente <[email protected]>
Co-authored-by: Gino Valente <[email protected]>
Thanks @cBournhonesque for fixing this! |
Addresses Bevy [12715](bevyengine/bevy#12715)
Addresses Bevy [12715](bevyengine/bevy#12715)
Addresses Bevy [12715](bevyengine/bevy#12715)
Adopted from and closes #9914 by @djeedai
Objective
Fix the use of
TypeRegistry
instead ofTypeRegistryArc
in dynamic scene and its serializer.Rename
DynamicScene::serialize_ron()
intoserialize()
to highlight the fact this is not about serializing to RON specifically, but rather about serializing to the official Bevy scene format (.scn
/.scn.ron
) which theSceneLoader
can deserialize (and which happens to be based in RON, but that not the object here). Also make the link with the documentation ofSceneLoader
so users understand the full serializing cycle of a Bevy dynamic scene.Document
SceneSerializer
with an example showing how to serialize to a custom format (here: RON), which is easily transposed to serializing into any other format.Fixes #9520
Changelog
Changed
SceneSerializer
and all related serializing helper types now take a&TypeRegistry
instead of a&TypeRegistryArc
. (SceneSerializer needlessly uses specifically &TypeRegistryArc #9520)DynamicScene::serialize_ron()
was renamed toserialize()
.Migration Guide
SceneSerializer
and all related serializing helper types now take a&TypeRegistry
instead of a&TypeRegistryArc
. You can upgrade by getting the former from the latter withTypeRegistryArc::read()
, e.g.DynamicScene::serialize_ron()
toserialize()
.