bevy/crates
Carter Anderson 80961d1bd0 Fix sparse insert (#1748)
Removing the checks on this line https://github.com/bevyengine/bevy/blob/main/crates/bevy_sprite/src/frustum_culling.rs#L64 and running the "many_sprites" example revealed two corner case bugs in bevy_ecs. The first, a simple and honest missed line introduced in #1471. The other, an insidious monster that has been there since the ECS v2 rewrite, just waiting for the time to strike:

1. #1471 accidentally removed the "insert" line for sparse set components with the "mutated" bundle state. Re-adding it fixes the problem. I did a slight refactor here to make the implementation simpler and remove a branch.
2. The other issue is nastier. ECS v2 added an "archetype graph". When determining what components were added/mutated during an archetype change, we read the FromBundle edge (which encodes this state) on the "new" archetype.  The problem is that unlike "add edges" which are guaranteed to be unique for a given ("graph node", "bundle id") pair, FromBundle edges are not necessarily unique:

```rust
// OLD_ARCHETYPE -> NEW_ARCHETYPE

// [] -> [usize]
e.insert(2usize);
// [usize] -> [usize, i32]
e.insert(1i32);
// [usize, i32] -> [usize, i32]
e.insert(1i32);
// [usize, i32] -> [usize]
e.remove::<i32>();
// [usize] -> [usize, i32]
e.insert(1i32);
```

Note that the second `e.insert(1i32)` command has a different "archetype graph edge" than the first, but they both lead to the same "new archetype".

The fix here is simple: just remove FromBundle edges because they are broken and store the information in the "add edges", which are guaranteed to be unique.

FromBundle edges were added to cut down on the number of archetype accesses / make the archetype access patterns nicer. But benching this change resulted in no significant perf changes and the addition of get_2_mut() for archetypes resolves the access pattern issue.
2021-03-25 05:56:00 +00:00
..
bevy_app System sets and run criteria v2 (#1675) 2021-03-24 20:11:55 +00:00
bevy_asset improve error message when asset type hasn't beed added to app (#1487) 2021-03-14 00:36:15 +00:00
bevy_audio Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_core Reliable change detection (#1471) 2021-03-19 17:53:26 +00:00
bevy_derive format comments (#1612) 2021-03-11 00:27:30 +00:00
bevy_diagnostic ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00
bevy_dylib release 0.4.0 (#1093) 2020-12-19 13:28:00 -06:00
bevy_dynamic_plugin update libloading (#1543) 2021-03-03 03:11:12 +00:00
bevy_ecs Fix sparse insert (#1748) 2021-03-25 05:56:00 +00:00
bevy_gilrs Resolve (most) internal system ambiguities (#1606) 2021-03-10 22:37:02 +00:00
bevy_gltf Make Commands and World apis consistent (#1703) 2021-03-23 00:23:40 +00:00
bevy_input format comments (#1612) 2021-03-11 00:27:30 +00:00
bevy_internal Rebase of existing PBR work (#1554) 2021-03-20 03:22:33 +00:00
bevy_log Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_math use std clamp instead of Bevy's (#1644) 2021-03-13 18:07:14 +00:00
bevy_pbr Rebase of existing PBR work (#1554) 2021-03-20 03:22:33 +00:00
bevy_reflect fix dyn warning (#1690) 2021-03-19 02:53:26 +00:00
bevy_render Frustum Culling (for Sprites) (#1492) 2021-03-24 21:29:53 +00:00
bevy_scene Make Commands and World apis consistent (#1703) 2021-03-23 00:23:40 +00:00
bevy_sprite Frustum Culling (for Sprites) (#1492) 2021-03-24 21:29:53 +00:00
bevy_tasks format comments (#1612) 2021-03-11 00:27:30 +00:00
bevy_text Frustum Culling (for Sprites) (#1492) 2021-03-24 21:29:53 +00:00
bevy_transform Make Commands and World apis consistent (#1703) 2021-03-23 00:23:40 +00:00
bevy_ui Frustum Culling (for Sprites) (#1492) 2021-03-24 21:29:53 +00:00
bevy_utils Update ahash requirement from 0.6.1 to 0.7.0 (#1370) 2021-02-01 13:29:54 -08:00
bevy_wgpu color spaces and representation (#1572) 2021-03-17 23:59:51 +00:00
bevy_window Derive PartialEq for WindowMode (#1688) 2021-03-18 23:47:34 +00:00
bevy_winit format comments (#1612) 2021-03-11 00:27:30 +00:00