Fix TypeRegistry use in dynamic scene#12715
Merged
Merged
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
james7132
reviewed
Mar 25, 2024
james7132
left a comment
Member
There was a problem hiding this comment.
No real objections other than the potential cost of allocation for the serialization. LGTM.
| /// [Rust Object Notation (RON)]: https://crates.io/crates/ron | ||
| #[cfg(feature = "serialize")] | ||
| pub fn serialize_ron(&self, registry: &TypeRegistryArc) -> Result<String, ron::Error> { | ||
| pub fn serialize(&self, registry: &TypeRegistry) -> Result<String, ron::Error> { |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
This should probably done in a different PR, right? The output type change seems unrelated
Contributor
|
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. |
MrGVSV
approved these changes
Mar 26, 2024
Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
james7132
approved these changes
Mar 27, 2024
Contributor
|
Thanks @cBournhonesque for fixing this! |
zhaop
added a commit
to zhaop/bevy_editor_pls
that referenced
this pull request
Jun 24, 2024
Addresses Bevy [12715](bevyengine/bevy#12715)
zhaop
added a commit
to zhaop/bevy_editor_pls
that referenced
this pull request
Jun 24, 2024
Addresses Bevy [12715](bevyengine/bevy#12715)
5 tasks
jakobhellermann
pushed a commit
to jakobhellermann/bevy_editor_pls
that referenced
this pull request
Aug 11, 2024
Addresses Bevy [12715](bevyengine/bevy#12715)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopted from and closes #9914 by @djeedai
Objective
Fix the use of
TypeRegistryinstead ofTypeRegistryArcin 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 theSceneLoadercan deserialize (and which happens to be based in RON, but that not the object here). Also make the link with the documentation ofSceneLoaderso users understand the full serializing cycle of a Bevy dynamic scene.Document
SceneSerializerwith 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
SceneSerializerand all related serializing helper types now take a&TypeRegistryinstead of a&TypeRegistryArc. (SceneSerializer needlessly uses specifically &TypeRegistryArc #9520)DynamicScene::serialize_ron()was renamed toserialize().Migration Guide
SceneSerializerand all related serializing helper types now take a&TypeRegistryinstead of a&TypeRegistryArc. You can upgrade by getting the former from the latter withTypeRegistryArc::read(), e.g.DynamicScene::serialize_ron()toserialize().