Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilteredEntityRef/FilteredEntityMut's access is empty when used in composite queries #14349

Open
SkiFire13 opened this issue Jul 16, 2024 · 0 comments · May be fixed by #18236
Open

FilteredEntityRef/FilteredEntityMut's access is empty when used in composite queries #14349

SkiFire13 opened this issue Jul 16, 2024 · 0 comments · May be fixed by #18236
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon

Comments

@SkiFire13
Copy link
Contributor

Bevy version

Both 0.14.0 and af865e7

What you did

#[derive(Component)]
struct Foo;

let mut world = World::new();

let foo_id = world.init_component::<Foo>();

world.spawn(Foo);

// With just `FilteredEntityRef` it works fine.
let mut query = QueryBuilder::<FilteredEntityRef>::new(&mut world)
    .ref_id(foo_id)
    .build();
let entity_ref = query.single(&world);
assert!(entity_ref.access().has_read(foo_id));
assert!(entity_ref.get::<Foo>().is_some());

// Inside any tuple it does not work, even 1-element tuples.
let mut query = QueryBuilder::<(FilteredEntityRef,)>::new(&mut world)
    .ref_id(foo_id)
    .build();
let (entity_ref,) = query.single(&world);
assert!(entity_ref.access().has_read(foo_id));
assert!(entity_ref.get::<Foo>().is_some());

What went wrong

It seems that when FilteredEntityRef/FilteredEntityMut are nested inside a tuple the access is not properly set. Indeed the implementation of WorldQuery for tuples does not call the set_access method used by FilteredEntityRef/FilteredEntityMut. However the fix doesn't seem as simple as just calling it, since may ignore any potential conflict between the FilteredEntity* and the other QueryDatas in the query.

@SkiFire13 SkiFire13 added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 16, 2024
@janhohenheim janhohenheim added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled labels Jul 17, 2024
@alice-i-cecile alice-i-cecile added S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants