Skip to content

Commit f68bc01

Browse files
BrezakElabajaba
andauthored
Run CheckVisibility after all the other visibility system sets have… (#12962)
# Objective Make visibility system ordering explicit. Fixes #12953. ## Solution Specify `CheckVisibility` happens after all other `VisibilitySystems` sets have happened. --------- Co-authored-by: Elabajaba <Elabajaba@users.noreply.github.com>
1 parent 2b3e334 commit f68bc01

File tree

5 files changed

+19
-45
lines changed

5 files changed

+19
-45
lines changed

crates/bevy_pbr/src/lib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,7 @@ impl Plugin for PbrPlugin {
350350
.in_set(SimulationLightSystems::UpdateLightFrusta)
351351
.after(TransformSystem::TransformPropagate)
352352
.after(SimulationLightSystems::AssignLightsToClusters),
353-
check_visibility::<WithLight>
354-
.in_set(VisibilitySystems::CheckVisibility)
355-
.after(VisibilitySystems::CalculateBounds)
356-
.after(VisibilitySystems::UpdateOrthographicFrusta)
357-
.after(VisibilitySystems::UpdatePerspectiveFrusta)
358-
.after(VisibilitySystems::UpdateProjectionFrusta)
359-
.after(VisibilitySystems::VisibilityPropagate)
360-
.after(TransformSystem::TransformPropagate),
353+
check_visibility::<WithLight>.in_set(VisibilitySystems::CheckVisibility),
361354
check_light_mesh_visibility
362355
.in_set(SimulationLightSystems::CheckLightVisibility)
363356
.after(VisibilitySystems::CalculateBounds)

crates/bevy_pbr/src/meshlet/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ use bevy_render::{
8383
ExtractSchedule, Render, RenderApp, RenderSet,
8484
};
8585
use bevy_transform::components::{GlobalTransform, Transform};
86-
use bevy_transform::TransformSystem;
8786

8887
const MESHLET_BINDINGS_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(1325134235233421);
8988
const MESHLET_MESH_MATERIAL_SHADER_HANDLE: Handle<Shader> =
@@ -168,14 +167,7 @@ impl Plugin for MeshletPlugin {
168167
.insert_resource(Msaa::Off)
169168
.add_systems(
170169
PostUpdate,
171-
check_visibility::<WithMeshletMesh>
172-
.in_set(VisibilitySystems::CheckVisibility)
173-
.after(VisibilitySystems::CalculateBounds)
174-
.after(VisibilitySystems::UpdateOrthographicFrusta)
175-
.after(VisibilitySystems::UpdatePerspectiveFrusta)
176-
.after(VisibilitySystems::UpdateProjectionFrusta)
177-
.after(VisibilitySystems::VisibilityPropagate)
178-
.after(TransformSystem::TransformPropagate),
170+
check_visibility::<WithMeshletMesh>.in_set(VisibilitySystems::CheckVisibility),
179171
);
180172
}
181173

crates/bevy_render/src/view/visibility/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,25 @@ impl Plugin for VisibilityPlugin {
259259
fn build(&self, app: &mut bevy_app::App) {
260260
use VisibilitySystems::*;
261261

262-
app.add_systems(
262+
app.configure_sets(
263+
PostUpdate,
264+
(
265+
CalculateBounds,
266+
UpdateOrthographicFrusta,
267+
UpdatePerspectiveFrusta,
268+
UpdateProjectionFrusta,
269+
VisibilityPropagate,
270+
)
271+
.before(CheckVisibility)
272+
.after(TransformSystem::TransformPropagate),
273+
)
274+
.add_systems(
263275
PostUpdate,
264276
(
265277
calculate_bounds.in_set(CalculateBounds),
266278
update_frusta::<OrthographicProjection>
267279
.in_set(UpdateOrthographicFrusta)
268280
.after(camera_system::<OrthographicProjection>)
269-
.after(TransformSystem::TransformPropagate)
270281
// We assume that no camera will have more than one projection component,
271282
// so these systems will run independently of one another.
272283
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
@@ -275,24 +286,15 @@ impl Plugin for VisibilityPlugin {
275286
update_frusta::<PerspectiveProjection>
276287
.in_set(UpdatePerspectiveFrusta)
277288
.after(camera_system::<PerspectiveProjection>)
278-
.after(TransformSystem::TransformPropagate)
279289
// We assume that no camera will have more than one projection component,
280290
// so these systems will run independently of one another.
281291
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
282292
.ambiguous_with(update_frusta::<Projection>),
283293
update_frusta::<Projection>
284294
.in_set(UpdateProjectionFrusta)
285-
.after(camera_system::<Projection>)
286-
.after(TransformSystem::TransformPropagate),
295+
.after(camera_system::<Projection>),
287296
(visibility_propagate_system, reset_view_visibility).in_set(VisibilityPropagate),
288-
check_visibility::<WithMesh>
289-
.in_set(CheckVisibility)
290-
.after(CalculateBounds)
291-
.after(UpdateOrthographicFrusta)
292-
.after(UpdatePerspectiveFrusta)
293-
.after(UpdateProjectionFrusta)
294-
.after(VisibilityPropagate)
295-
.after(TransformSystem::TransformPropagate),
297+
check_visibility::<WithMesh>.in_set(CheckVisibility),
296298
),
297299
);
298300
}

crates/bevy_sprite/src/lib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub mod prelude {
3333
}
3434

3535
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
36-
use bevy_transform::TransformSystem;
3736
pub use bundle::*;
3837
pub use dynamic_texture_atlas_builder::*;
3938
pub use mesh2d::*;
@@ -122,13 +121,7 @@ impl Plugin for SpritePlugin {
122121
check_visibility::<WithMesh2d>,
123122
check_visibility::<WithSprite>,
124123
)
125-
.in_set(VisibilitySystems::CheckVisibility)
126-
.after(VisibilitySystems::CalculateBounds)
127-
.after(VisibilitySystems::UpdateOrthographicFrusta)
128-
.after(VisibilitySystems::UpdatePerspectiveFrusta)
129-
.after(VisibilitySystems::UpdateProjectionFrusta)
130-
.after(VisibilitySystems::VisibilityPropagate)
131-
.after(TransformSystem::TransformPropagate),
124+
.in_set(VisibilitySystems::CheckVisibility),
132125
),
133126
);
134127

crates/bevy_ui/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,7 @@ impl Plugin for UiPlugin {
137137
app.add_systems(
138138
PostUpdate,
139139
(
140-
check_visibility::<WithNode>
141-
.in_set(VisibilitySystems::CheckVisibility)
142-
.after(VisibilitySystems::CalculateBounds)
143-
.after(VisibilitySystems::UpdateOrthographicFrusta)
144-
.after(VisibilitySystems::UpdatePerspectiveFrusta)
145-
.after(VisibilitySystems::UpdateProjectionFrusta)
146-
.after(VisibilitySystems::VisibilityPropagate),
140+
check_visibility::<WithNode>.in_set(VisibilitySystems::CheckVisibility),
147141
update_target_camera_system.before(UiSystem::Layout),
148142
apply_deferred
149143
.after(update_target_camera_system)

0 commit comments

Comments
 (0)