-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Scene entity map when saving scene #22369
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?
Conversation
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.
The logic looks good. Thanks for the test.
What’s the need to have this functionality? Just curious as someone who is new to scenes. I’m assuming it makes it easier to compare two scenes if you’re changing something in between extractions?
I don’t have much context to scene work to determine whether this is controversial or anything, so that’s a caveat!
| component_filter: SceneFilter, | ||
| resource_filter: SceneFilter, | ||
| original_world: &'w World, | ||
| entity_map: Option<&'w mut EntityHashMap<Entity>>, |
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.
Nit: Not sure if anyone is a fan of too verbose names, but I wonder if the name world_to_scene_entity_map or world_to_scene_map would be better here. I appreciate how succinct entity_map is though, so I may be in the minority
|
|
||
| // Map entities in the component if an entity map is provided | ||
| if let Some(entity_map) = self.entity_map.as_mut() | ||
| && let Some(map_entities) = type_registration.data::<ReflectComponent>() |
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.
Is it more accurate for this to be named like so?
| && let Some(map_entities) = type_registration.data::<ReflectComponent>() | |
| && let Some(refl_component) = type_registration.data::<ReflectComponent>() |
| .find(|e| e.entity == original_entity.entity) | ||
| .expect("Entity should be present in recreated scene"); | ||
|
|
||
| assert_eq!(original_entity.entity, recreated_entity.entity); |
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.
is this is a redundant check since recreated_entity will assert that there is true for at least one of the &original_scene.entities?
Objective
Entitys more stable by providing the reverse entity map.Solution
with_entity_maptoDynamicSceneBuilderTesting