Skip to content

Commit ae03ba4

Browse files
committed
Non-exclusive systems for clearing contexts
1 parent 3e708bc commit ae03ba4

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
@@ -260,33 +260,27 @@ where
260260
/// Pop the default gizmos context out of the [`Swap<Clear>`] gizmo storage.
261261
///
262262
/// This must be called before [`UpdateGizmoMeshes`] in the [`Last`] schedule.
263-
pub fn end_gizmo_context<Config, Clear>(world: &mut World)
264-
where
263+
pub fn end_gizmo_context<Config, Clear>(
264+
mut swap: ResMut<GizmoStorage<Config, Swap<Clear>>>,
265+
mut default: ResMut<GizmoStorage<Config, ()>>,
266+
) where
265267
Config: GizmoConfigGroup,
266268
Clear: 'static + Send + Sync,
267269
{
268-
world.resource_scope(
269-
|world: &mut World, mut swap: Mut<GizmoStorage<Config, Swap<Clear>>>| {
270-
let mut default = world.resource_mut::<GizmoStorage<Config, ()>>();
271-
default.clear();
272-
default.swap(&mut *swap);
273-
},
274-
);
270+
default.clear();
271+
default.swap(&mut *swap);
275272
}
276273

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

292286
/// Clear out the contextual gizmos.

0 commit comments

Comments
 (0)