Skip to content

Commit

Permalink
Non-exclusive systems for clearing contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceeri committed Mar 11, 2024
1 parent 027ae0a commit f71152a
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,33 +260,27 @@ where
/// Pop the default gizmos context out of the [`Swap<Clear>`] gizmo storage.
///
/// This must be called before [`UpdateGizmoMeshes`] in the [`Last`] schedule.
pub fn end_gizmo_context<Config, Clear>(world: &mut World)
where
pub fn end_gizmo_context<Config, Clear>(
mut swap: ResMut<GizmoStorage<Config, Swap<Clear>>>,
mut default: ResMut<GizmoStorage<Config, ()>>,
) where
Config: GizmoConfigGroup,
Clear: 'static + Send + Sync,
{
world.resource_scope(
|world: &mut World, mut swap: Mut<GizmoStorage<Config, Swap<Clear>>>| {
let mut default = world.resource_mut::<GizmoStorage<Config, ()>>();
default.clear();
default.swap(&mut *swap);
},
);
default.clear();
default.swap(&mut *swap);
}

/// Collect the requested gizmos into a specific clear context.
pub fn collect_requested_gizmos<Config, Clear>(world: &mut World)
where
pub fn collect_requested_gizmos<Config, Clear>(
mut update: ResMut<GizmoStorage<Config, ()>>,
mut context: ResMut<GizmoStorage<Config, Clear>>,
) where
Config: GizmoConfigGroup,
Clear: 'static + Send + Sync,
{
world.resource_scope(
|world: &mut World, mut update: Mut<GizmoStorage<Config, ()>>| {
let mut context = world.resource_mut::<GizmoStorage<Config, Clear>>();
context.append_storage(&update);
update.clear();
},
);
context.append_storage(&update);
update.clear();
}

/// Clear out the contextual gizmos.
Expand Down

0 comments on commit f71152a

Please sign in to comment.