-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Restore read-only World::iter_entities or provide infallible equivalent #22657
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
What problem does this solve or what need does it fill?
This issue highlights a regression introduced in the transition from Bevy 0.17 to 0.18. The deprecation and subsequent removal of
World::iter_entities()has created a gap in functionality for purely read-only access patterns. This was raised by #6228.Bevy 0.17 has deprecated
World::iter_entities()and ask users to useWorld::Query::<EntityRef>, howeverWorld::Queryrequires mutable world ptr.World::try_querycan use read-only world, but from semantics, get active entity ids does not require anytryand it is uncertain ifWorld::try_queryreturnErrbut theWorld::iter_entities()should not fail in any situation.This has unintended side effect on codes relying on
World::iter_entities()and no alternative is provided. It is better to readd the API to bevy in the future.What solution would you like?
Add function similar to following to
Worldso we can query all ids/refs of active entities from read-only context again.Fix the documentation in Bevy 0.17 since it ignored original motivation of #6228.
What alternative(s) have you considered?
read_only_queryso the query can be performed on&World.Additional context
The original issue #6228.