mirror of
https://github.com/bevyengine/bevy
synced 2024-12-22 02:53:07 +00:00
1bf271d56e
Objective --------- - Since #6742, It is not possible to build an `ArchetypeId` from a `ArchetypeGeneration` - This was useful to 3rd party crate extending the base bevy ECS capabilities, such as [`bevy_ecs_dynamic`] and now [`bevy_mod_dynamic_query`] - Making `ArchetypeGeneration` opaque this way made it completely useless, and removed the ability to limit archetype updates to a subset of archetypes. - Making the `index` method on `ArchetypeId` private prevented the use of bitfields and other optimized data structure to store sets of archetype ids. (without `transmute`) This PR is not a simple reversal of the change. It exposes a different API, rethought to keep the private stuff private and the public stuff less error-prone. - Add a `StartRange<ArchetypeGeneration>` `Index` implementation to `Archetypes` - Instead of converting the generation into an index, then creating a ArchetypeId from that index, and indexing `Archetypes` with it, use directly the old `ArchetypeGeneration` to get the range of new archetypes. From careful benchmarking, it seems to also be a performance improvement (~0-5%) on add_archetypes. --- Changelog --------- - Added `impl Index<RangeFrom<ArchetypeGeneration>> for Archetypes` this allows you to get a slice of newly added archetypes since the last recorded generation. - Added `ArchetypeId::index` and `ArchetypeId::new` methods. It should enable 3rd party crates to use the `Archetypes` API in a meaningful way. [`bevy_ecs_dynamic`]: https://github.com/jakobhellermann/bevy_ecs_dynamic/tree/main [`bevy_mod_dynamic_query`]: https://github.com/nicopap/bevy_mod_dynamic_query/ --------- Co-authored-by: vero <email@atlasdostal.com> |
||
---|---|---|
.. | ||
entity | ||
query | ||
reflect | ||
schedule | ||
storage | ||
system | ||
world | ||
archetype.rs | ||
bundle.rs | ||
change_detection.rs | ||
component.rs | ||
event.rs | ||
lib.rs | ||
removal_detection.rs |