diff --git a/crates/bevy_animation/Cargo.toml b/crates/bevy_animation/Cargo.toml index 8e529b5171e20..eeb2660f104b3 100644 --- a/crates/bevy_animation/Cargo.toml +++ b/crates/bevy_animation/Cargo.toml @@ -21,3 +21,4 @@ bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" } bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" } bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.12.0-dev" } +bevy_ui = { path = "../bevy_ui", version = "0.12.0-dev" } diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index d108782119cc5..c22b15c22dd4b 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -738,7 +738,9 @@ impl Plugin for AnimationPlugin { .register_type::() .add_systems( PostUpdate, - animation_player.before(TransformSystem::TransformPropagate), + animation_player + .before(TransformSystem::TransformPropagate) + .before(bevy_ui::UiSystem::Layout), ); } } diff --git a/crates/bevy_audio/Cargo.toml b/crates/bevy_audio/Cargo.toml index b905ebf88ac2c..a0af5830f4817 100644 --- a/crates/bevy_audio/Cargo.toml +++ b/crates/bevy_audio/Cargo.toml @@ -14,6 +14,7 @@ bevy_app = { path = "../bevy_app", version = "0.12.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.12.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" } bevy_math = { path = "../bevy_math", version = "0.12.0-dev" } +bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = ["bevy"] } bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" } bevy_derive = { path = "../bevy_derive", version = "0.12.0-dev" } diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index a2003a3b5967f..3b84e6403dfec 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -92,9 +92,16 @@ impl AddAudioSource for App { { self.init_asset::().add_systems( PostUpdate, - play_queued_audio_system::.in_set(AudioPlaySet), + play_queued_audio_system:: + .in_set(AudioPlaySet) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), + ); + self.add_systems( + PostUpdate, + cleanup_finished_audio:: + .in_set(AudioPlaySet) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), ); - self.add_systems(PostUpdate, cleanup_finished_audio::.in_set(AudioPlaySet)); self } } diff --git a/crates/bevy_gilrs/Cargo.toml b/crates/bevy_gilrs/Cargo.toml index 4f8a51b9064bd..621b2397a00be 100644 --- a/crates/bevy_gilrs/Cargo.toml +++ b/crates/bevy_gilrs/Cargo.toml @@ -16,6 +16,7 @@ bevy_input = { path = "../bevy_input", version = "0.12.0-dev" } bevy_log = { path = "../bevy_log", version = "0.12.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" } bevy_time = { path = "../bevy_time", version = "0.12.0-dev" } +bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" } # other gilrs = "0.10.1" diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index 1afcf515f6613..ecb77fea5c040 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -31,7 +31,12 @@ impl Plugin for GilrsPlugin { .init_non_send_resource::() .add_systems(PreStartup, gilrs_event_startup_system) .add_systems(PreUpdate, gilrs_event_system.before(InputSystem)) - .add_systems(PostUpdate, play_gilrs_rumble.in_set(RumbleSystem)); + .add_systems( + PostUpdate, + play_gilrs_rumble + .in_set(RumbleSystem) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), + ); } Err(err) => error!("Failed to start Gilrs. {}", err), } diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 79f696e1f063e..c07a555234e31 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -90,7 +90,8 @@ impl Plugin for GizmoPlugin { draw_aabbs, draw_all_aabbs.run_if(|config: Res| config.aabb.draw_all), ) - .after(TransformSystem::TransformPropagate), + .after(TransformSystem::TransformPropagate) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), ); let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { diff --git a/crates/bevy_pbr/Cargo.toml b/crates/bevy_pbr/Cargo.toml index 5ff50b66d6644..bdfeecab0d938 100644 --- a/crates/bevy_pbr/Cargo.toml +++ b/crates/bevy_pbr/Cargo.toml @@ -23,6 +23,7 @@ bevy_render = { path = "../bevy_render", version = "0.12.0-dev" } bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" } bevy_window = { path = "../bevy_window", version = "0.12.0-dev" } +bevy_winit = { path = "../bevy_winit", version = "0.12.0-dev" } bevy_derive = { path = "../bevy_derive", version = "0.12.0-dev" } # other diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 228de223caa98..e427fd7c95b2e 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -195,8 +195,17 @@ impl Plugin for PbrPlugin { .add_systems( PostUpdate, ( - add_clusters.in_set(SimulationLightSystems::AddClusters), - apply_deferred.in_set(SimulationLightSystems::AddClustersFlush), + add_clusters + .in_set(SimulationLightSystems::AddClusters) + .after(bevy_render::view::VisibilitySystems::CalculateBoundsFlush), + apply_deferred + .in_set(SimulationLightSystems::AddClustersFlush) + .after(bevy_render::view::VisibilitySystems::CalculateBounds) + .after(VisibilitySystems::CheckVisibility) + .after(bevy_winit::accessibility::AccessKitSystemSet) + .before(bevy_window::exit_on_all_closed) + .after(TransformSystem::TransformPropagate) + .after(bevy_render::mesh::morph::inherit_weights), assign_lights_to_clusters .in_set(SimulationLightSystems::AssignLightsToClusters) .after(TransformSystem::TransformPropagate) @@ -204,6 +213,7 @@ impl Plugin for PbrPlugin { .after(CameraUpdateSystem), update_directional_light_cascades .in_set(SimulationLightSystems::UpdateDirectionalLightCascades) + .after(SimulationLightSystems::AddClustersFlush) .after(TransformSystem::TransformPropagate) .after(CameraUpdateSystem), update_directional_light_frusta @@ -212,6 +222,7 @@ impl Plugin for PbrPlugin { .after(VisibilitySystems::CheckVisibility) .after(TransformSystem::TransformPropagate) .after(SimulationLightSystems::UpdateDirectionalLightCascades) + .after(SimulationLightSystems::AddClustersFlush) // We assume that no entity will be both a directional light and a spot light, // so these systems will run independently of one another. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 32573be7b9a11..60402ce086c06 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -50,6 +50,7 @@ bevy_render_macros = { path = "macros", version = "0.12.0-dev" } bevy_time = { path = "../bevy_time", version = "0.12.0-dev" } bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" } bevy_window = { path = "../bevy_window", version = "0.12.0-dev" } +bevy_winit = { path = "../bevy_winit", version = "0.12.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" } bevy_tasks = { path = "../bevy_tasks", version = "0.12.0-dev" } diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index a824d886c80aa..e242a6e405ad0 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -42,7 +42,8 @@ impl Plugin for CameraPro // We assume that each camera will only have one projection, // so we can ignore ambiguities with all other monomorphizations. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. - .ambiguous_with(CameraUpdateSystem), + .ambiguous_with(CameraUpdateSystem) + .after(crate::view::VisibilitySystems::CalculateBoundsFlush), ); } } diff --git a/crates/bevy_render/src/mesh/morph.rs b/crates/bevy_render/src/mesh/morph.rs index cb523113be231..42e4fb9aa5e30 100644 --- a/crates/bevy_render/src/mesh/morph.rs +++ b/crates/bevy_render/src/mesh/morph.rs @@ -28,7 +28,10 @@ impl Plugin for MorphPlugin { fn build(&self, app: &mut bevy_app::App) { app.register_type::() .register_type::() - .add_systems(PostUpdate, inherit_weights); + .add_systems( + PostUpdate, + inherit_weights.after(crate::view::VisibilitySystems::CalculateBoundsFlush), + ); } } diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index f55563751ff78..0a4567e8f36e3 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -215,7 +215,14 @@ impl Plugin for VisibilityPlugin { app // We add an AABB component in CalculateBounds, which must be ready on the same frame. - .add_systems(PostUpdate, apply_deferred.in_set(CalculateBoundsFlush)) + .add_systems( + PostUpdate, + apply_deferred + .in_set(CalculateBoundsFlush) + .before(TransformSystem::TransformPropagate) + .before(bevy_transform::systems::sync_simple_transforms) + .after(bevy_winit::accessibility::AccessKitSystemSet), + ) .configure_sets(PostUpdate, CalculateBoundsFlush.after(CalculateBounds)) .add_systems( PostUpdate, @@ -225,6 +232,7 @@ impl Plugin for VisibilityPlugin { .in_set(UpdateOrthographicFrusta) .after(camera_system::) .after(TransformSystem::TransformPropagate) + .after(CalculateBoundsFlush) // We assume that no camera will have more than one projection component, // so these systems will run independently of one another. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. @@ -234,6 +242,7 @@ impl Plugin for VisibilityPlugin { .in_set(UpdatePerspectiveFrusta) .after(camera_system::) .after(TransformSystem::TransformPropagate) + .after(CalculateBoundsFlush) // We assume that no camera will have more than one projection component, // so these systems will run independently of one another. // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481. @@ -241,9 +250,11 @@ impl Plugin for VisibilityPlugin { update_frusta:: .in_set(UpdateProjectionFrusta) .after(camera_system::) - .after(TransformSystem::TransformPropagate), + .after(TransformSystem::TransformPropagate) + .after(CalculateBoundsFlush), (visibility_propagate_system, reset_view_visibility) - .in_set(VisibilityPropagate), + .in_set(VisibilityPropagate) + .after(crate::view::VisibilitySystems::CalculateBoundsFlush), check_visibility .in_set(CheckVisibility) .after(CalculateBoundsFlush) @@ -493,7 +504,10 @@ mod test { #[test] fn visibility_propagation() { let mut app = App::new(); - app.add_systems(Update, visibility_propagate_system); + app.add_systems( + Update, + visibility_propagate_system.after(crate::view::VisibilitySystems::CalculateBoundsFlush), + ); let root1 = app .world @@ -600,7 +614,10 @@ mod test { #[test] fn visibility_propagation_unconditional_visible() { let mut app = App::new(); - app.add_systems(Update, visibility_propagate_system); + app.add_systems( + Update, + visibility_propagate_system.after(crate::view::VisibilitySystems::CalculateBoundsFlush), + ); let root1 = app .world @@ -700,7 +717,9 @@ mod test { fn visibility_progation_change_detection() { let mut world = World::new(); let mut schedule = Schedule::default(); - schedule.add_systems(visibility_propagate_system); + schedule.add_systems( + visibility_propagate_system.after(crate::view::VisibilitySystems::CalculateBoundsFlush), + ); // Set up an entity hierarchy. diff --git a/crates/bevy_text/Cargo.toml b/crates/bevy_text/Cargo.toml index 9055e3a97dac3..52759a6aca8cd 100644 --- a/crates/bevy_text/Cargo.toml +++ b/crates/bevy_text/Cargo.toml @@ -18,6 +18,7 @@ bevy_app = { path = "../bevy_app", version = "0.12.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.12.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.12.0-dev" } bevy_math = { path = "../bevy_math", version = "0.12.0-dev" } +bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = ["bevy"] } bevy_render = { path = "../bevy_render", version = "0.12.0-dev" } bevy_sprite = { path = "../bevy_sprite", version = "0.12.0-dev" } diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index f5498d26ef1fb..e5268e30d7db2 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -92,9 +92,12 @@ impl Plugin for TextPlugin { // In practice, they run independently since `bevy_render::camera_update_system` // will only ever observe its own render target, and `update_text2d_layout` // will never modify a pre-existing `Image` asset. - .ambiguous_with(CameraUpdateSystem), + .ambiguous_with(CameraUpdateSystem) + .ambiguous_with(bevy_sprite::calculate_bounds_2d), font_atlas_set::remove_dropped_font_atlas_sets, - ), + ) + .chain() + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), ); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { diff --git a/crates/bevy_ui/Cargo.toml b/crates/bevy_ui/Cargo.toml index 60e8d74477ac5..11702ca919a2b 100644 --- a/crates/bevy_ui/Cargo.toml +++ b/crates/bevy_ui/Cargo.toml @@ -20,6 +20,7 @@ bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.12.0-dev" } bevy_input = { path = "../bevy_input", version = "0.12.0-dev" } bevy_log = { path = "../bevy_log", version = "0.12.0-dev" } bevy_math = { path = "../bevy_math", version = "0.12.0-dev" } +bevy_pbr = { path = "../bevy_pbr", version = "0.12.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.12.0-dev", features = [ "bevy", ] } @@ -28,6 +29,7 @@ bevy_sprite = { path = "../bevy_sprite", version = "0.12.0-dev" } bevy_text = { path = "../bevy_text", version = "0.12.0-dev", optional = true } bevy_transform = { path = "../bevy_transform", version = "0.12.0-dev" } bevy_window = { path = "../bevy_window", version = "0.12.0-dev" } +bevy_winit = { path = "../bevy_winit", version = "0.12.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.12.0-dev" } # other diff --git a/crates/bevy_ui/src/accessibility.rs b/crates/bevy_ui/src/accessibility.rs index a1203a766d0f9..8c3d4505c9658 100644 --- a/crates/bevy_ui/src/accessibility.rs +++ b/crates/bevy_ui/src/accessibility.rs @@ -154,7 +154,10 @@ impl Plugin for AccessibilityPlugin { button_changed, image_changed, label_changed, - ), + ) + .chain() + .after(bevy_winit::accessibility::AccessKitSystemSet) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), ); } } diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index ae9f9f41885d9..74928381d3cc7 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -132,6 +132,7 @@ impl Plugin for UiPlugin { PostUpdate, ( widget::measure_text_system + .after(widget::update_atlas_content_size_system) .before(UiSystem::Layout) // Potential conflict: `Assets` // In practice, they run independently since `bevy_render::camera_update_system` @@ -144,13 +145,20 @@ impl Plugin for UiPlugin { .ambiguous_with(bevy_text::update_text2d_layout), widget::text_system .after(UiSystem::Layout) + .after(bevy_render::view::VisibilitySystems::CalculateBounds) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush) + .after(bevy_text::update_text2d_layout) + .before(bevy_text::remove_dropped_font_atlas_sets) .before(Assets::::track_assets), ), ); #[cfg(feature = "bevy_text")] app.add_plugins(accessibility::AccessibilityPlugin); app.add_systems(PostUpdate, { - let system = widget::update_image_content_size_system.before(UiSystem::Layout); + let system = widget::update_image_content_size_system + .before(UiSystem::Layout) + .before(bevy_render::view::VisibilitySystems::CalculateBoundsFlush) + .after(widget::measure_text_system); // Potential conflicts: `Assets` // They run independently since `widget::image_node_system` will only ever observe // its own UiImage, and `widget::text_system` & `bevy_text::update_text2d_layout` @@ -171,9 +179,15 @@ impl Plugin for UiPlugin { ( ui_layout_system .in_set(UiSystem::Layout) - .before(TransformSystem::TransformPropagate), - ui_stack_system.in_set(UiSystem::Stack), - update_clipping_system.after(TransformSystem::TransformPropagate), + .before(TransformSystem::TransformPropagate) + .before(bevy_pbr::SimulationLightSystems::AddClustersFlush) + .before(bevy_render::view::VisibilitySystems::CalculateBoundsFlush), + ui_stack_system + .in_set(UiSystem::Stack) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), + update_clipping_system + .after(TransformSystem::TransformPropagate) + .after(bevy_pbr::SimulationLightSystems::AddClustersFlush), ), ); diff --git a/crates/bevy_winit/src/accessibility.rs b/crates/bevy_winit/src/accessibility.rs index 49a4c0d859c6d..5373a2dda6006 100644 --- a/crates/bevy_winit/src/accessibility.rs +++ b/crates/bevy_winit/src/accessibility.rs @@ -16,6 +16,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::{DetectChanges, Entity, EventReader, EventWriter}, query::With, + schedule::{IntoSystemConfigs, SystemSet}, system::{NonSend, NonSendMut, Query, Res, ResMut, Resource}, }; use bevy_hierarchy::{Children, Parent}; @@ -161,6 +162,10 @@ fn update_accessibility_nodes( } } +/// Label for [`AccessibilityPlugin`] systems. +#[derive(SystemSet, Clone, Eq, PartialEq, Hash, Debug)] +pub struct AccessKitSystemSet; + /// Implements winit-specific `AccessKit` functionality. pub struct AccessibilityPlugin; @@ -176,7 +181,9 @@ impl Plugin for AccessibilityPlugin { window_closed, poll_receivers, update_accessibility_nodes, - ), + ) + .chain() + .in_set(AccessKitSystemSet), ); } }