Skip to content

Fix TypeRegistry use in dynamic scene#9914

Closed
djeedai wants to merge 6 commits into
bevyengine:mainfrom
djeedai:dyn-scene
Closed

Fix TypeRegistry use in dynamic scene#9914
djeedai wants to merge 6 commits into
bevyengine:mainfrom
djeedai:dyn-scene

Conversation

@djeedai

@djeedai djeedai commented Sep 24, 2023

Copy link
Copy Markdown
Contributor

Objective

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 not about serializing to RON specifically, but rather about serializing to the official Bevy scene format (.scn / .scn.ron) which the SceneLoader can deserialize (and which happens to be based in RON, but that not the object here). Also make the link with the documentation of SceneLoader 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

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 with TypeRegistryArc::read(), e.g.
      let registry_arc: TypeRegistryArc = [...];
    - let serializer = SceneSerializer(&scene, &registry_arc);
    + let registry = registry_arc.read();
    + let serializer = SceneSerializer(&scene, &registry);
  • Rename DynamicScene::serialize_ron() to serialize().

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
@djeedai
djeedai requested a review from MrGVSV September 24, 2023 15:22
@djeedai djeedai added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Sep 24, 2023
Comment thread crates/bevy_scene/src/dynamic_scene.rs Outdated
Comment thread crates/bevy_scene/src/scene_loader.rs Outdated
@MrGVSV MrGVSV added the A-Scenes Composing and serializing ECS objects label Sep 24, 2023
@james7132 james7132 added this to the 0.13 milestone Nov 26, 2023

@james7132 james7132 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additional documentation. Could you rebase on main?

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 24, 2024

@jdm jdm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the cleanups and documentation additions make sense to me!

@alice-i-cecile alice-i-cecile removed the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 29, 2024
@alice-i-cecile

Copy link
Copy Markdown
Member

I've done my best to resolve merge conflicts here, and everything compiles. However, we're now getting some non-trivial failing tests.

I don't currently have the time or expertise to fix this up further, so I'm going to put this work done for today.

@alice-i-cecile alice-i-cecile removed this from the 0.13 milestone Feb 2, 2024
@alice-i-cecile

Copy link
Copy Markdown
Member

This is valuable stuff, but not vital enough to hold up the release. Removing from the milestone. Please feel free to reach out if you'd like assistance finishing this up :)

@cBournhonesque

Copy link
Copy Markdown
Contributor

I will adopt this PR from @djeedai (he agreed on discord)

@alice-i-cecile alice-i-cecile added the S-Adopt-Me The original PR author has no intent to complete this work. Pick me up! label Mar 25, 2024
@djeedai

djeedai commented Mar 26, 2024

Copy link
Copy Markdown
Contributor Author

Closing as adopted.

@djeedai djeedai closed this Mar 26, 2024
github-merge-queue Bot pushed a commit that referenced this pull request Mar 28, 2024
Adopted from and closes #9914 by
@djeedai


# Objective
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 not about serializing to RON specifically, but rather
about serializing to the official Bevy scene format (`.scn` /
`.scn.ron`) which the `SceneLoader` can deserialize (and which happens
to be based in RON, but that not the object here). Also make the link
with the documentation of `SceneLoader` 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](#9520))
* `DynamicScene::serialize_ron()` was renamed to `serialize()`.
 
## 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 with `TypeRegistryArc::read()`,
_e.g._
  ```diff
    let registry_arc: TypeRegistryArc = [...];
  - let serializer = SceneSerializer(&scene, &registry_arc);
  + let registry = registry_arc.read();
  + let serializer = SceneSerializer(&scene, &registry);
  ```
* Rename `DynamicScene::serialize_ron()` to `serialize()`.

---------

Co-authored-by: Jerome Humbert <djeedai@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
Co-authored-by: James Liu <contact@jamessliu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Reflection Runtime information about types A-Scenes Composing and serializing ECS objects C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Adopt-Me The original PR author has no intent to complete this work. Pick me up!

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

SceneSerializer needlessly uses specifically &TypeRegistryArc

6 participants