bevy/crates
Testare 02b0ea22dd Bugfix: Scene reload fix (nonbreaking) (#7951)
Fix a bug with scene reload.

(This is a copy of #7570 but without the breaking API change, in order
to allow the bugfix to be introduced in 0.10.1)

When a scene was reloaded, it was corrupting components that weren't
native to the scene itself. In particular, when a DynamicScene was
created on Entity (A), all components in the scene without parents are
automatically added as children of Entity (A). But if that scene was
reloaded and the same ID of Entity (A) was a scene ID as well*, that
parent component was corrupted, causing the hierarchy to become
malformed and bevy to panic.

*For example, if Entity (A)'s ID was 3, and the scene contained an
entity with ID 3

This issue could affect any components that:
* Implemented `MapEntities`, basically components that contained
references to other entities
* Were added to entities from a scene file but weren't defined in the
scene file

- Fixes #7529

The solution was to keep track of entities+components that had
`MapEntities` functionality during scene load, and only apply the entity
update behavior to them. They were tracked with a HashMap from the
component's TypeID to a vector of entity ID's. Then the
`ReflectMapEntities` struct was updated to hold a function that took a
list of entities to be applied to, instead of naively applying itself to
all values in the EntityMap.

(See this PR comment
https://github.com/bevyengine/bevy/pull/7570#issuecomment-1432302796 for
a story-based explanation of this bug and solution)

- Components that implement `MapEntities` added to scene entities after
load are not corrupted during scene reload.
2023-03-28 01:56:29 +02:00
..
bevy_a11y Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_animation Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_app Fix Plugin::build detection (#8103) 2023-03-28 01:42:06 +02:00
bevy_asset Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_audio Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_core Register missing types in bevy_window (#7993) 2023-03-28 01:51:13 +02:00
bevy_core_pipeline Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_derive Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_diagnostic Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_dylib Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_dynamic_plugin Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_ecs Bugfix: Scene reload fix (nonbreaking) (#7951) 2023-03-28 01:56:29 +02:00
bevy_ecs_compile_fail_tests EntityMut: rename remove_intersection to remove and remove to take (#7810) 2023-02-26 00:09:19 +00:00
bevy_encase_derive Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_gilrs Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_gltf Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_hierarchy Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_input add Clone to common conditions (#8060) 2023-03-28 01:29:06 +02:00
bevy_internal Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_log Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_macro_utils Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_math Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_mikktspace Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_pbr Dither fix (#7977) 2023-03-28 01:50:20 +02:00
bevy_ptr Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_reflect bevy_reflect: Fix trailing comma breaking derives (#8014) 2023-03-28 01:50:37 +02:00
bevy_reflect_compile_fail_tests bevy_reflect: Fix trailing comma breaking derives (#8014) 2023-03-28 01:50:37 +02:00
bevy_render Fix documentation on RegularPolygon (#8164) 2023-03-28 01:49:28 +02:00
bevy_scene Bugfix: Scene reload fix (nonbreaking) (#7951) 2023-03-28 01:56:29 +02:00
bevy_sprite Add ReflectComponent registration for Sprite (#8207) 2023-03-28 01:50:00 +02:00
bevy_tasks Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_text Fix the Text2d text anchor's incorrect horizontal alignment (#8019) 2023-03-28 01:25:28 +02:00
bevy_time add Clone to common conditions (#8060) 2023-03-28 01:29:06 +02:00
bevy_transform docs: update docs and comments that still refer to stages (#8156) 2023-03-28 01:54:20 +02:00
bevy_ui Skip the UV calculations for untextured UI nodes (#7809) 2023-03-28 01:42:50 +02:00
bevy_utils Release 0.10.0 (#7919) 2023-03-06 03:53:02 +00:00
bevy_window Register missing types in bevy_window (#7993) 2023-03-28 01:51:13 +02:00
bevy_winit docs: update docs and comments that still refer to stages (#8156) 2023-03-28 01:54:20 +02:00