bevy
bevy copied to clipboard
Disjoint `QueryData` access
Objective
Fixes https://github.com/bevyengine/bevy/issues/14518
Solution
Added QueryData implementer similarly to how ParamSet is implemented
Testing
2 doc tests and 3 tests that are adapted forms of the same tests for ParamSet
Showcase
Adds DataSet that imlements QueryData and allows disjoint access to it's members, similarly to how ParamSet works.
Mainly would be useful with in generic contexts where you need QueryData, but can't guarantee it won't conflict with other QueryData. Or with complex custom QueryData implementers that conflict with each other.
This will compile even if A and B conflict:
fn iterate_generic_data<A: QueryData, B: QueryData>(mut query: Query<DataSet<(A, B)>>) {
for mut set in query.iter_mut() {
let a = set.d0();
let b = set.d1();
}
}