Skip to content

Commit 6c47917

Browse files
committed
Non-exclusive systems for clearing contexts
1 parent 694a6c0 commit 6c47917

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

crates/bevy_gizmos/src/lib.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -259,33 +259,27 @@ where
259259
/// Pop the default gizmos context out of the [`Swap<Clear>`] gizmo storage.
260260
///
261261
/// This must be called before [`UpdateGizmoMeshes`] in the [`Last`] schedule.
262-
pub fn end_gizmo_context<Config, Clear>(world: &mut World)
263-
where
262+
pub fn end_gizmo_context<Config, Clear>(
263+
mut swap: ResMut<GizmoStorage<Config, Swap<Clear>>>,
264+
mut default: ResMut<GizmoStorage<Config, ()>>,
265+
) where
264266
Config: GizmoConfigGroup,
265267
Clear: 'static + Send + Sync,
266268
{
267-
world.resource_scope(
268-
|world: &mut World, mut swap: Mut<GizmoStorage<Config, Swap<Clear>>>| {
269-
let mut default = world.resource_mut::<GizmoStorage<Config, ()>>();
270-
default.clear();
271-
default.swap(&mut *swap);
272-
},
273-
);
269+
default.clear();
270+
default.swap(&mut *swap);
274271
}
275272

276273
/// Collect the requested gizmos into a specific clear context.
277-
pub fn collect_requested_gizmos<Config, Clear>(world: &mut World)
278-
where
274+
pub fn collect_requested_gizmos<Config, Clear>(
275+
mut update: ResMut<GizmoStorage<Config, ()>>,
276+
mut context: ResMut<GizmoStorage<Config, Clear>>,
277+
) where
279278
Config: GizmoConfigGroup,
280279
Clear: 'static + Send + Sync,
281280
{
282-
world.resource_scope(
283-
|world: &mut World, mut update: Mut<GizmoStorage<Config, ()>>| {
284-
let mut context = world.resource_mut::<GizmoStorage<Config, Clear>>();
285-
context.append_storage(&update);
286-
update.clear();
287-
},
288-
);
281+
context.append_storage(&update);
282+
update.clear();
289283
}
290284

291285
/// Clear out the contextual gizmos.

0 commit comments

Comments
 (0)