Option
and Has
ignore sparse components in transmuted dense queries
#16397
Labels
A-ECS
Entities, components, systems, and events
C-Bug
An unexpected or incorrect behavior
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
Bevy version
e155fe1d86
What you did
Transmuted a
QueryState<EntityMut>
to eitherQueryState<Option<&S>>
orQueryState<Has<S>>
, whereS
is a sparse set component.What went wrong
The matched entity has an
S
component, butOption<&S>
yieldsNone
andHas<S>
yieldsfalse
.Additional information
Option
andHas
cache whether the component exists inset_table
orset_archetype
. To make this work for sparse set components, they setIS_DENSE = false
and require sparse iteration. ButEntityMut
performs dense iteration, so the transmuted query is dense and callsset_table
.Option
andHas
don't find the component in the table, since sparse set components are not stored in tables, and returnNone
orfalse
for the entire table.#14628 is also caused by transmuting a dense query to a sparse one.
#16396 would make this also occur in cases involving
FilteredEnittyMut
.The text was updated successfully, but these errors were encountered: