-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Make AccessConflicts::is_empty
public
#18688
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
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Could u give a example of how you would implement SystemParam for a type like that? I could try to make it derivable. |
pub struct NativeOM<'a> {
pub world: &'a mut World,
}
unsafe impl SystemParam for NativeOM<'_> {
type State = ();
type Item<'world, 'state> = NativeOM<'world>;
fn init_state(
_world: &mut World,
system_meta: &mut bevy_ecs::system::SystemMeta,
) -> Self::State {
let mut access = Access::default();
access.write_all();
if !system_meta
.archetype_component_access()
.is_compatible(&access)
{
panic!("NativeOM borrows &mut World and conflicts with other system parameters");
}
unsafe {
system_meta.archetype_component_access_mut().extend(&access);
}
let mut filtered_access = FilteredAccess::default();
filtered_access.write_all();
if !(match system_meta
.component_access_set()
.get_conflicts_single(&filtered_access)
{
bevy_ecs::query::AccessConflicts::All => false,
bevy_ecs::query::AccessConflicts::Individual(fixed_bit_set) => fixed_bit_set.is_empty(),
}) {
panic!("NativeOM borrows &mut World and conflicts with other system parameters");
}
unsafe {
system_meta.component_access_set_mut().add(filtered_access);
}
()
}
unsafe fn get_param<'world, 'state>(
_state: &'state mut Self::State,
_system_meta: &bevy_ecs::system::SystemMeta,
world: bevy_ecs::world::unsafe_world_cell::UnsafeWorldCell<'world>,
_change_tick: bevy_ecs::component::Tick,
) -> Self::Item<'world, 'state> {
NativeOM::new(world.world_mut())
}
} This is how I implemented it after reading the implementation for |
if !(match system_meta
.component_access_set()
.get_conflicts_single(&filtered_access)
{
bevy_ecs::query::AccessConflicts::All => false,
bevy_ecs::query::AccessConflicts::Individual(fixed_bit_set) => fixed_bit_set.is_empty(),
}) This part is where i would've used AccessConflicts::is_empty |
It's not actually sound to If you're able to use This PR seems fine, though! It is silly that this method isn't |
# Objective When implementing `SystemParam` for an object which contains a mutable reference to World, which cannot be derived due to a required lifetime parameter, it's necessary to check that there aren't any conflicts. As far as I know, the is_empty method is the only way provided to check for no conflicts at all
# Objective When implementing `SystemParam` for an object which contains a mutable reference to World, which cannot be derived due to a required lifetime parameter, it's necessary to check that there aren't any conflicts. As far as I know, the is_empty method is the only way provided to check for no conflicts at all
Objective
When implementing
SystemParam
for an object which contains a mutablereference to World, which cannot be derived due to a required lifetime parameter, it's necessary to check that there aren't any conflicts.
As far as I know, the is_empty method is the only way provided to check for no conflicts at all