Skip to content

Commit a2fc9de

Browse files
Add RenderSet::FinalCleanup for World::clear_entities (#14764)
# Objective `World::clear_entities` is ambiguous with all of the other systems in `RenderSet::Cleanup` because it access `&mut World`. ## Solution I've added another system set variant, and made sure that this runs after everything else. ## Testing The `ambiguity_detection` example ## Migration Guide `World::clear_entities` is now part of `RenderSet::PostCleanup` rather than `RenderSet::Cleanup`. Your cleanup systems should likely stay in `RenderSet::Cleanup`. ## Additional context Spotted when working on #7386: this was responsible for a large number of ambiguities. This should be removed if / when #14449 is merged: there's no need to call `clear_entities` at all if the rendering world is retained!
1 parent ac29bdf commit a2fc9de

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

crates/bevy_render/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub struct RenderPlugin {
104104

105105
/// The systems sets of the default [`App`] rendering schedule.
106106
///
107-
/// that runs immediately after the matching system set.
108107
/// These can be useful for ordering, but you almost never want to add your systems to these sets.
109108
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
110109
pub enum RenderSet {
@@ -138,6 +137,10 @@ pub enum RenderSet {
138137
Render,
139138
/// Cleanup render resources here.
140139
Cleanup,
140+
/// Final cleanup occurs: all entities will be despawned.
141+
///
142+
/// Runs after [`Cleanup`](RenderSet::Cleanup).
143+
PostCleanup,
141144
}
142145

143146
/// The main render schedule.
@@ -162,6 +165,7 @@ impl Render {
162165
Prepare,
163166
Render,
164167
Cleanup,
168+
PostCleanup,
165169
)
166170
.chain(),
167171
);
@@ -469,7 +473,7 @@ unsafe fn initialize_render_app(app: &mut App) {
469473
render_system,
470474
)
471475
.in_set(RenderSet::Render),
472-
World::clear_entities.in_set(RenderSet::Cleanup),
476+
World::clear_entities.in_set(RenderSet::PostCleanup),
473477
),
474478
);
475479

0 commit comments

Comments
 (0)