diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b56be125..f00b84cf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,6 +54,6 @@ jobs: targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 - name: Clippy bevy_rapier2d - run: cd bevy_rapier2d && cargo clippy --verbose --features wasm-bindgen --target wasm32-unknown-unknown + run: cd bevy_rapier2d && cargo clippy --verbose --features wasm-bindgen,bevy/webgl2 --target wasm32-unknown-unknown - name: Clippy bevy_rapier3d - run: cd bevy_rapier3d && cargo clippy --verbose --features wasm-bindgen --target wasm32-unknown-unknown + run: cd bevy_rapier3d && cargo clippy --verbose --features wasm-bindgen,bevy/webgl2 --target wasm32-unknown-unknown diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index eaae5aa8..76cc1b42 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -20,8 +20,8 @@ required-features = [ "dim2" ] [features] default = [ "dim2", "async-collider", "debug-render-2d" ] dim2 = [] -debug-render-2d = [ "bevy/bevy_core_pipeline", "bevy/bevy_sprite", "bevy/bevy_render", "rapier2d/debug-render", "bevy/bevy_asset" ] -debug-render-3d = [ "bevy/bevy_core_pipeline", "bevy/bevy_pbr", "bevy/bevy_render", "rapier2d/debug-render", "bevy/bevy_asset" ] +debug-render-2d = [ "bevy/bevy_core_pipeline", "bevy/bevy_sprite", "bevy/bevy_gizmos", "rapier2d/debug-render", "bevy/bevy_asset" ] +debug-render-3d = [ "bevy/bevy_core_pipeline", "bevy/bevy_pbr", "bevy/bevy_gizmos", "rapier2d/debug-render", "bevy/bevy_asset" ] parallel = [ "rapier2d/parallel" ] simd-stable = [ "rapier2d/simd-stable" ] simd-nightly = [ "rapier2d/simd-nightly" ] @@ -32,8 +32,8 @@ headless = [] async-collider = [ "bevy/bevy_asset", "bevy/bevy_scene" ] [dependencies] -bevy = { version = "0.10", default-features = false } -nalgebra = { version = "0.32.2", features = [ "convert-glam023" ] } +bevy = { version = "0.11", default-features = false } +nalgebra = { version = "0.32.3", features = [ "convert-glam024" ] } # Don't enable the default features because we don't need the ColliderSet/RigidBodySet rapier2d = "0.17.0" bitflags = "1" @@ -42,10 +42,10 @@ log = "0.4" serde = { version = "1", features = [ "derive" ], optional = true} [dev-dependencies] -bevy = { version = "0.10", default-features = false, features = ["x11"]} +bevy = { version = "0.11", default-features = false, features = ["x11"]} oorandom = "11" approx = "0.5.1" -glam = { version = "0.23", features = [ "approx" ] } +glam = { version = "0.24", features = [ "approx" ] } [package.metadata.docs.rs] # Enable all the features when building the docs on docs.rs diff --git a/bevy_rapier2d/examples/boxes2.rs b/bevy_rapier2d/examples/boxes2.rs index 2ea9a1d0..a942c5a5 100644 --- a/bevy_rapier2d/examples/boxes2.rs +++ b/bevy_rapier2d/examples/boxes2.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier2d/examples/contact_filter2.rs b/bevy_rapier2d/examples/contact_filter2.rs index 37dc0d08..ac4f6410 100644 --- a/bevy_rapier2d/examples/contact_filter2.rs +++ b/bevy_rapier2d/examples/contact_filter2.rs @@ -35,13 +35,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter( - 100.0, + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), )) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier2d/examples/custom_system_setup2.rs b/bevy_rapier2d/examples/custom_system_setup2.rs index 7518acef..3e9c810e 100644 --- a/bevy_rapier2d/examples/custom_system_setup2.rs +++ b/bevy_rapier2d/examples/custom_system_setup2.rs @@ -1,13 +1,6 @@ -use bevy::{ - core::FrameCount, - ecs::schedule::{LogLevel, ScheduleBuildSettings, ScheduleLabel}, - prelude::*, -}; +use bevy::{core::FrameCount, prelude::*, transform::TransformSystem}; use bevy_rapier2d::prelude::*; -#[derive(ScheduleLabel, Hash, Debug, PartialEq, Eq, Clone)] -struct SpecialSchedule; - fn main() { let mut app = App::new(); @@ -16,64 +9,43 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system( - (|world: &mut World| { - world.run_schedule(SpecialSchedule); - }) - .in_base_set(CoreSet::PostUpdate), - ); - - // Do the setup however we want, maybe in its very own schedule - let mut schedule = Schedule::new(); - - // Show errors in ambiguous systems - schedule.set_build_settings(ScheduleBuildSettings { - ambiguity_detection: LogLevel::Error, - ..default() - }); - - schedule.configure_sets( + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0).with_default_system_setup(false), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)); + + app.configure_sets( + PostUpdate, ( PhysicsSet::SyncBackend, PhysicsSet::SyncBackendFlush, PhysicsSet::StepSimulation, PhysicsSet::Writeback, ) - .chain(), + .chain() + .before(TransformSystem::TransformPropagate), ); - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) - .in_base_set(PhysicsSet::SyncBackend), - ); - - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackendFlush) - .in_base_set(PhysicsSet::SyncBackendFlush), - ); - - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation) - .in_base_set(PhysicsSet::StepSimulation), - ); - schedule.add_system(despawn_one_box.in_base_set(PhysicsSet::StepSimulation)); - - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::Writeback) - .in_base_set(PhysicsSet::Writeback), + app.add_systems( + PostUpdate, + ( + RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) + .in_set(PhysicsSet::SyncBackend), + RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackendFlush) + .in_set(PhysicsSet::SyncBackendFlush), + ( + RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation), + despawn_one_box, + ) + .in_set(PhysicsSet::StepSimulation), + RapierPhysicsPlugin::::get_systems(PhysicsSet::Writeback) + .in_set(PhysicsSet::Writeback), + ), ); - app.add_schedule(SpecialSchedule, schedule) - .add_plugin( - RapierPhysicsPlugin::::default() - .with_physics_scale(100.) - .with_default_system_setup(false), - ) - .run(); + app.run(); } fn despawn_one_box( diff --git a/bevy_rapier2d/examples/debug_despawn2.rs b/bevy_rapier2d/examples/debug_despawn2.rs index 92cdd924..e420a495 100644 --- a/bevy_rapier2d/examples/debug_despawn2.rs +++ b/bevy_rapier2d/examples/debug_despawn2.rs @@ -9,11 +9,13 @@ fn main() { App::new() .init_resource::() .insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0))) - .add_plugins(DefaultPlugins) - .add_startup_system(setup_game) - .add_system(cube_sleep_detection) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, setup_game) + .add_systems(Update, cube_sleep_detection) .run(); } diff --git a/bevy_rapier2d/examples/despawn2.rs b/bevy_rapier2d/examples/despawn2.rs index 8a2db871..2cf19a24 100644 --- a/bevy_rapier2d/examples/despawn2.rs +++ b/bevy_rapier2d/examples/despawn2.rs @@ -20,13 +20,13 @@ fn main() { ))) .insert_resource(DespawnResource::default()) .insert_resource(ResizeResource::default()) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(despawn) - .add_system(resize) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(Update, (despawn, resize)) .run(); } diff --git a/bevy_rapier2d/examples/events2.rs b/bevy_rapier2d/examples/events2.rs index 15b416a5..fa47816d 100644 --- a/bevy_rapier2d/examples/events2.rs +++ b/bevy_rapier2d/examples/events2.rs @@ -8,12 +8,13 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(display_events.in_base_set(CoreSet::PostUpdate)) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(PostUpdate, display_events) .run(); } diff --git a/bevy_rapier2d/examples/joints2.rs b/bevy_rapier2d/examples/joints2.rs index f4688f68..586a42c5 100644 --- a/bevy_rapier2d/examples/joints2.rs +++ b/bevy_rapier2d/examples/joints2.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier2d/examples/joints_despawn2.rs b/bevy_rapier2d/examples/joints_despawn2.rs index a3599a01..6e16999d 100644 --- a/bevy_rapier2d/examples/joints_despawn2.rs +++ b/bevy_rapier2d/examples/joints_despawn2.rs @@ -14,12 +14,13 @@ fn main() { 0xFF as f32 / 255.0, ))) .insert_resource(DespawnResource::default()) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(despawn) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(Update, despawn) .run(); } diff --git a/bevy_rapier2d/examples/locked_rotations2.rs b/bevy_rapier2d/examples/locked_rotations2.rs index 43aa7045..4bd16106 100644 --- a/bevy_rapier2d/examples/locked_rotations2.rs +++ b/bevy_rapier2d/examples/locked_rotations2.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier2d/examples/multiple_colliders2.rs b/bevy_rapier2d/examples/multiple_colliders2.rs index 6e473fab..93710ecb 100644 --- a/bevy_rapier2d/examples/multiple_colliders2.rs +++ b/bevy_rapier2d/examples/multiple_colliders2.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier2d/examples/player_movement2.rs b/bevy_rapier2d/examples/player_movement2.rs index bf273bd7..2a903eda 100644 --- a/bevy_rapier2d/examples/player_movement2.rs +++ b/bevy_rapier2d/examples/player_movement2.rs @@ -3,18 +3,20 @@ use bevy_rapier2d::prelude::*; fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - resolution: WindowResolution::new(1000., 1000.), - title: "Player Movement Example".to_string(), + .add_plugins(( + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + resolution: WindowResolution::new(1000., 1000.), + title: "Player Movement Example".to_string(), + ..default() + }), ..default() }), - ..default() - })) - .add_startup_system(spawn_player) - .add_system(player_movement) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, spawn_player) + .add_systems(Update, player_movement) .run(); } diff --git a/bevy_rapier2d/examples/rope_joint2.rs b/bevy_rapier2d/examples/rope_joint2.rs index ebe0400d..f00d1939 100644 --- a/bevy_rapier2d/examples/rope_joint2.rs +++ b/bevy_rapier2d/examples/rope_joint2.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(100.0)) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::pixels_per_meter(100.0), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index d801f768..c69a42a2 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -21,8 +21,8 @@ required-features = [ "dim3" ] default = [ "dim3", "async-collider", "debug-render-3d" ] dim3 = [] debug-render = [ "debug-render-3d" ] -debug-render-2d = [ "bevy/bevy_core_pipeline", "bevy/bevy_sprite", "bevy/bevy_render", "rapier3d/debug-render", "bevy/bevy_asset" ] -debug-render-3d = [ "bevy/bevy_core_pipeline", "bevy/bevy_pbr", "bevy/bevy_render", "rapier3d/debug-render", "bevy/bevy_asset" ] +debug-render-2d = [ "bevy/bevy_core_pipeline", "bevy/bevy_sprite", "bevy/bevy_gizmos", "rapier3d/debug-render", "bevy/bevy_asset" ] +debug-render-3d = [ "bevy/bevy_core_pipeline", "bevy/bevy_pbr", "bevy/bevy_gizmos", "rapier3d/debug-render", "bevy/bevy_asset" ] parallel = [ "rapier3d/parallel" ] simd-stable = [ "rapier3d/simd-stable" ] simd-nightly = [ "rapier3d/simd-nightly" ] @@ -33,8 +33,8 @@ headless = [ ] async-collider = [ "bevy/bevy_asset", "bevy/bevy_scene" ] [dependencies] -bevy = { version = "0.10", default-features = false } -nalgebra = { version = "0.32.2", features = [ "convert-glam023" ] } +bevy = { version = "0.11", default-features = false } +nalgebra = { version = "0.32.3", features = [ "convert-glam024" ] } # Don't enable the default features because we don't need the ColliderSet/RigidBodySet rapier3d = "0.17.0" bitflags = "1" @@ -43,9 +43,9 @@ log = "0.4" serde = { version = "1", features = [ "derive" ], optional = true} [dev-dependencies] -bevy = { version = "0.10", default-features = false, features = ["x11"]} +bevy = { version = "0.11", default-features = false, features = ["x11"]} approx = "0.5.1" -glam = { version = "0.23", features = [ "approx" ] } +glam = { version = "0.24", features = [ "approx" ] } [package.metadata.docs.rs] # Enable all the features when building the docs on docs.rs diff --git a/bevy_rapier3d/examples/boxes3.rs b/bevy_rapier3d/examples/boxes3.rs index 075110b7..3d510720 100644 --- a/bevy_rapier3d/examples/boxes3.rs +++ b/bevy_rapier3d/examples/boxes3.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier3d/examples/contact_filter3.rs b/bevy_rapier3d/examples/contact_filter3.rs index 7a5ebfaa..5d6595e3 100644 --- a/bevy_rapier3d/examples/contact_filter3.rs +++ b/bevy_rapier3d/examples/contact_filter3.rs @@ -35,11 +35,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier3d/examples/custom_system_setup3.rs b/bevy_rapier3d/examples/custom_system_setup3.rs index 87fb9feb..ea422422 100644 --- a/bevy_rapier3d/examples/custom_system_setup3.rs +++ b/bevy_rapier3d/examples/custom_system_setup3.rs @@ -1,13 +1,6 @@ -use bevy::{ - core::FrameCount, - ecs::schedule::{LogLevel, ScheduleBuildSettings, ScheduleLabel}, - prelude::*, -}; +use bevy::{core::FrameCount, prelude::*, transform::TransformSystem}; use bevy_rapier3d::prelude::*; -#[derive(ScheduleLabel, Hash, Debug, PartialEq, Eq, Clone)] -struct SpecialSchedule; - fn main() { let mut app = App::new(); @@ -16,60 +9,43 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system( - (|world: &mut World| { - world.run_schedule(SpecialSchedule); - }) - .in_base_set(CoreSet::PostUpdate), - ); - - // Do the setup however we want, maybe in its very own schedule - let mut schedule = Schedule::new(); - - // Show errors in ambiguous systems - schedule.set_build_settings(ScheduleBuildSettings { - ambiguity_detection: LogLevel::Error, - ..default() - }); - - schedule.configure_sets( + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default().with_default_system_setup(false), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)); + + app.configure_sets( + PostUpdate, ( PhysicsSet::SyncBackend, PhysicsSet::SyncBackendFlush, PhysicsSet::StepSimulation, PhysicsSet::Writeback, ) - .chain(), + .chain() + .before(TransformSystem::TransformPropagate), ); - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) - .in_base_set(PhysicsSet::SyncBackend), - ); - - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackendFlush) - .in_base_set(PhysicsSet::SyncBackendFlush), - ); - - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation) - .in_base_set(PhysicsSet::StepSimulation), - ); - schedule.add_system(despawn_one_box.in_base_set(PhysicsSet::StepSimulation)); - - schedule.add_systems( - RapierPhysicsPlugin::::get_systems(PhysicsSet::Writeback) - .in_base_set(PhysicsSet::Writeback), + app.add_systems( + PostUpdate, + ( + RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) + .in_set(PhysicsSet::SyncBackend), + RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackendFlush) + .in_set(PhysicsSet::SyncBackendFlush), + ( + RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation), + despawn_one_box, + ) + .in_set(PhysicsSet::StepSimulation), + RapierPhysicsPlugin::::get_systems(PhysicsSet::Writeback) + .in_set(PhysicsSet::Writeback), + ), ); - app.add_schedule(SpecialSchedule, schedule) - .add_plugin(RapierPhysicsPlugin::::default().with_default_system_setup(false)) - .run(); + app.run(); } fn despawn_one_box( diff --git a/bevy_rapier3d/examples/despawn3.rs b/bevy_rapier3d/examples/despawn3.rs index ae78a7ad..f78cdcb5 100644 --- a/bevy_rapier3d/examples/despawn3.rs +++ b/bevy_rapier3d/examples/despawn3.rs @@ -14,12 +14,13 @@ fn main() { 0xFF as f32 / 255.0, ))) .insert_resource(DespawnResource::default()) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(despawn) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(Update, despawn) .run(); } diff --git a/bevy_rapier3d/examples/events3.rs b/bevy_rapier3d/examples/events3.rs index 15d65f57..d7574dc0 100644 --- a/bevy_rapier3d/examples/events3.rs +++ b/bevy_rapier3d/examples/events3.rs @@ -8,12 +8,13 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(display_events.in_base_set(CoreSet::PostUpdate)) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(PostUpdate, display_events) .run(); } diff --git a/bevy_rapier3d/examples/joints3.rs b/bevy_rapier3d/examples/joints3.rs index 4f1fd058..a7cb84f9 100644 --- a/bevy_rapier3d/examples/joints3.rs +++ b/bevy_rapier3d/examples/joints3.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier3d/examples/joints_despawn3.rs b/bevy_rapier3d/examples/joints_despawn3.rs index a04cc3b6..177d4ea9 100644 --- a/bevy_rapier3d/examples/joints_despawn3.rs +++ b/bevy_rapier3d/examples/joints_despawn3.rs @@ -14,12 +14,13 @@ fn main() { 0xFF as f32 / 255.0, ))) .insert_resource(DespawnResource::default()) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(despawn) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(Update, despawn) .run(); } diff --git a/bevy_rapier3d/examples/locked_rotations3.rs b/bevy_rapier3d/examples/locked_rotations3.rs index c5ce9e73..89ba26e4 100644 --- a/bevy_rapier3d/examples/locked_rotations3.rs +++ b/bevy_rapier3d/examples/locked_rotations3.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier3d/examples/multiple_colliders3.rs b/bevy_rapier3d/examples/multiple_colliders3.rs index 6d13f3ba..45d372d4 100644 --- a/bevy_rapier3d/examples/multiple_colliders3.rs +++ b/bevy_rapier3d/examples/multiple_colliders3.rs @@ -8,11 +8,12 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .run(); } diff --git a/bevy_rapier3d/examples/ray_casting3.rs b/bevy_rapier3d/examples/ray_casting3.rs index 5ecc5cce..50a27a4c 100644 --- a/bevy_rapier3d/examples/ray_casting3.rs +++ b/bevy_rapier3d/examples/ray_casting3.rs @@ -9,12 +9,13 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) - .add_system(cast_ray) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) + .add_systems(Update, cast_ray) .run(); } diff --git a/bevy_rapier3d/examples/static_trimesh3.rs b/bevy_rapier3d/examples/static_trimesh3.rs index 4b926bfd..09c6e4bb 100644 --- a/bevy_rapier3d/examples/static_trimesh3.rs +++ b/bevy_rapier3d/examples/static_trimesh3.rs @@ -10,13 +10,14 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system(setup_graphics) - .add_startup_system(setup_physics) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)) .insert_resource(BallState::default()) - .add_system(ball_spawner) + .add_systems(Update, ball_spawner) .run(); } diff --git a/src/dynamics/mod.rs b/src/dynamics/mod.rs index ee886bed..1e112d96 100644 --- a/src/dynamics/mod.rs +++ b/src/dynamics/mod.rs @@ -7,7 +7,7 @@ pub use self::prismatic_joint::*; pub use self::revolute_joint::*; pub use self::rope_joint::*; -use bevy::reflect::{FromReflect, Reflect}; +use bevy::reflect::Reflect; use rapier::dynamics::CoefficientCombineRule as RapierCoefficientCombineRule; #[cfg(feature = "dim3")] @@ -32,7 +32,7 @@ mod spherical_joint; /// Each collider has its combination rule of type /// `CoefficientCombineRule`. And the rule /// actually used is given by `max(first_combine_rule as usize, second_combine_rule as usize)`. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect, FromReflect, Default)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect, Default)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub enum CoefficientCombineRule { #[default] diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index e8e7f185..52ac1f86 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -1,5 +1,5 @@ use crate::math::Vect; -use bevy::{prelude::*, reflect::FromReflect}; +use bevy::prelude::*; use rapier::prelude::{ Isometry, LockedAxes as RapierLockedAxes, RigidBodyActivation, RigidBodyHandle, RigidBodyType, }; @@ -10,7 +10,7 @@ use std::ops::{Add, AddAssign, Sub, SubAssign}; pub struct RapierRigidBodyHandle(pub RigidBodyHandle); /// A rigid-body. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Component, Reflect, FromReflect, Default)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Component, Reflect, Default)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[reflect(Component, PartialEq)] pub enum RigidBody { @@ -62,7 +62,7 @@ impl From for RigidBody { /// Use this component to control and/or read the velocity of a dynamic or kinematic rigid-body. /// If this component isn’t present, a dynamic rigid-body will still be able to move (you will just /// not be able to read/modify its velocity). -#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[reflect(Component, PartialEq)] pub struct Velocity { @@ -132,7 +132,7 @@ impl Velocity { } /// Mass-properties of a rigid-body, added to the contributions of its attached colliders. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub enum AdditionalMassProperties { /// This mass will be added to the rigid-body. The rigid-body’s total @@ -155,7 +155,7 @@ impl Default for AdditionalMassProperties { /// a rigid-body (including the colliders contribution). Modifying this component won’t /// affect the mass-properties of the rigid-body (the attached colliders’ `ColliderMassProperties` /// and the `AdditionalMassProperties` should be modified instead). -#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct ReadMassProperties(pub MassProperties); @@ -163,7 +163,7 @@ pub struct ReadMassProperties(pub MassProperties); /// /// This cannot be used as a component. Use the components `ReadMassProperties` to read a rigid-body’s /// mass-properties or `AdditionalMassProperties` to set its additional mass-properties. -#[derive(Copy, Clone, Debug, Default, PartialEq, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Reflect)] #[reflect(PartialEq)] pub struct MassProperties { /// The center of mass of a rigid-body expressed in its local-space. @@ -219,7 +219,7 @@ impl MassProperties { } bitflags::bitflags! { - #[derive(Default, Component, Reflect, FromReflect)] + #[derive(Default, Component, Reflect)] #[reflect(Component, PartialEq)] /// Flags affecting the behavior of the constraints solver for a given contact manifold. pub struct LockedAxes: u8 { @@ -251,7 +251,7 @@ impl From for RapierLockedAxes { /// Constant external forces applied continuously to a rigid-body. /// /// This force is applied at each timestep. -#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct ExternalForce { /// The linear force applied to the rigid-body. @@ -323,7 +323,7 @@ impl SubAssign for ExternalForce { /// /// The impulse is only applied once, and whenever it it modified (based /// on Bevy’s change detection). -#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct ExternalImpulse { /// The linear impulse applied to the rigid-body. @@ -398,7 +398,7 @@ impl SubAssign for ExternalImpulse { /// Gravity is multiplied by this scaling factor before it's /// applied to this rigid-body. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct GravityScale(pub f32); @@ -409,7 +409,7 @@ impl Default for GravityScale { } /// Information used for Continuous-Collision-Detection. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Ccd { /// Is CCD enabled for this rigid-body? @@ -432,7 +432,7 @@ impl Ccd { } /// The dominance groups of a rigid-body. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Dominance { // FIXME: rename this to `group` (no `s`). @@ -451,7 +451,7 @@ impl Dominance { /// /// This controls whether a body is sleeping or not. /// If the threshold is negative, the body never sleeps. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Sleeping { /// The linear velocity below which the body can fall asleep. @@ -484,7 +484,7 @@ impl Default for Sleeping { } /// Damping factors to gradually slow down a rigid-body. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Damping { // TODO: rename these to "linear" and "angular"? @@ -526,6 +526,6 @@ impl TransformInterpolation { } /// Indicates whether or not the rigid-body is disabled explicitly by the user. -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct RigidBodyDisabled; diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index 4d416e89..364a4564 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -4,7 +4,6 @@ use std::fmt; use {crate::geometry::VHACDParameters, bevy::utils::HashMap}; use bevy::prelude::*; -use bevy::reflect::FromReflect; use bevy::utils::HashSet; use rapier::geometry::Shape; @@ -91,7 +90,7 @@ impl fmt::Debug for Collider { } /// Overwrites the default application of [`GlobalTransform::scale`] to collider shapes. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] pub enum ColliderScale { /// This scale will be multiplied with the scale in the [`GlobalTransform`] component /// before being applied to the collider. @@ -101,12 +100,12 @@ pub enum ColliderScale { } /// Indicates whether or not the collider is a sensor. -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Sensor; /// Custom mass-properties of a collider. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub enum ColliderMassProperties { /// The mass-properties are computed automatically from the collider’s shape and this density. @@ -124,7 +123,7 @@ impl Default for ColliderMassProperties { } /// The friction affecting a collider. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Friction { /// The friction coefficient of a collider. @@ -166,7 +165,7 @@ impl Friction { } /// The restitution affecting a collider. -#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, PartialEq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct Restitution { /// The restitution coefficient of a collider. @@ -208,7 +207,7 @@ impl Default for Restitution { } bitflags::bitflags! { - #[derive(Component, Reflect, FromReflect)] + #[derive(Component, Reflect)] #[reflect(Component, Hash, PartialEq)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// Flags affecting whether or not collision-detection happens between two colliders @@ -253,7 +252,7 @@ impl From for rapier::geometry::ActiveCollisionTypes { bitflags::bitflags! { /// A bit mask identifying groups for interaction. - #[derive(Component, Reflect, FromReflect)] + #[derive(Component, Reflect)] #[reflect(Component, Hash, PartialEq)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] pub struct Group: u32 { @@ -350,7 +349,7 @@ impl Default for Group { /// ```ignore /// (self.memberships & rhs.filter) != 0 && (rhs.memberships & self.filter) != 0 /// ``` -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Component, Reflect)] #[reflect(Component, Hash, PartialEq)] pub struct CollisionGroups { /// Groups memberships. @@ -382,7 +381,7 @@ impl From for InteractionGroups { /// Pairwise constraints resolution filtering using bit masks. /// /// This follows the same rules as the `CollisionGroups`. -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Hash, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Hash, Component, Reflect)] #[reflect(Component, Hash, PartialEq)] pub struct SolverGroups { /// Groups memberships. @@ -412,7 +411,7 @@ impl From for InteractionGroups { } bitflags::bitflags! { - #[derive(Default, Component, Reflect, FromReflect)] + #[derive(Default, Component, Reflect)] #[reflect(Component)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// Flags affecting the behavior of the constraints solver for a given contact manifold. @@ -434,7 +433,7 @@ impl From for rapier::pipeline::ActiveHooks { } bitflags::bitflags! { - #[derive(Default, Component, Reflect, FromReflect)] + #[derive(Default, Component, Reflect)] #[reflect(Component)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// Flags affecting the events generated for this collider. @@ -456,7 +455,7 @@ impl From for rapier::pipeline::ActiveEvents { } /// The total force magnitude beyond which a contact force event can be emitted. -#[derive(Copy, Clone, PartialEq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, PartialEq, Component, Reflect)] #[reflect(Component)] pub struct ContactForceEventThreshold(pub f32); @@ -468,7 +467,7 @@ impl Default for ContactForceEventThreshold { /// Component which will be filled (if present) with a list of entities with which the current /// entity is currently in contact. -#[derive(Component, Default, Reflect, FromReflect)] +#[derive(Component, Default, Reflect)] #[reflect(Component)] pub struct CollidingEntities(pub(crate) HashSet); @@ -498,7 +497,7 @@ impl CollidingEntities { } /// Indicates whether or not the collider is disabled explicitly by the user. -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Component, Reflect, FromReflect)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Component, Reflect)] #[reflect(Component, PartialEq)] pub struct ColliderDisabled; diff --git a/src/pipeline/events.rs b/src/pipeline/events.rs index 9293a13c..7e15a819 100644 --- a/src/pipeline/events.rs +++ b/src/pipeline/events.rs @@ -1,5 +1,5 @@ use crate::math::{Real, Vect}; -use bevy::prelude::{Entity, EventWriter}; +use bevy::prelude::{Entity, Event, EventWriter}; use rapier::dynamics::RigidBodySet; use rapier::geometry::{ ColliderHandle, ColliderSet, CollisionEvent as RapierCollisionEvent, CollisionEventFlags, @@ -10,7 +10,7 @@ use std::collections::HashMap; use std::sync::RwLock; /// Events occurring when two colliders start or stop colliding -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Event, Copy, Clone, Debug, PartialEq, Eq)] pub enum CollisionEvent { /// Event occurring when two colliders start colliding Started(Entity, Entity, CollisionEventFlags), @@ -20,7 +20,7 @@ pub enum CollisionEvent { /// Event occurring when the sum of the magnitudes of the contact forces /// between two colliders exceed a threshold. -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Event, Copy, Clone, Debug, PartialEq)] pub struct ContactForceEvent { /// The first collider involved in the contact. pub collider1: Entity, diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index a76810d5..2b808a95 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -3,7 +3,7 @@ use crate::plugin::configuration::SimulationToRenderTime; use crate::plugin::{systems, RapierConfiguration, RapierContext}; use crate::prelude::*; use bevy::ecs::{event::Events, schedule::SystemConfigs, system::SystemParamItem}; -use bevy::prelude::*; +use bevy::{prelude::*, transform::TransformSystem}; use std::marker::PhantomData; /// No specific user-data is associated to the hooks. @@ -60,23 +60,17 @@ where /// [`with_system_setup(false)`](Self::with_system_setup). /// See [`PhysicsSet`] for a description of these systems. pub fn get_systems(set: PhysicsSet) -> SystemConfigs { - // A set for `propagate_transforms` to mark it as ambiguous with `sync_simple_transforms`. - // Used instead of the `SystemTypeSet` as that would not allow multiple instances of the system. - #[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)] - struct PropagateTransformsSet; - match set { PhysicsSet::SyncBackend => ( // Run the character controller before the manual transform propagation. systems::update_character_controls, // Run Bevy transform propagation additionally to sync [`GlobalTransform`] - bevy::transform::systems::sync_simple_transforms - .after(systems::update_character_controls) - .ambiguous_with(PropagateTransformsSet) - .in_set(RapierTransformPropagateSet), - bevy::transform::systems::propagate_transforms + ( + bevy::transform::systems::sync_simple_transforms, + bevy::transform::systems::propagate_transforms, + ) + .chain() .after(systems::update_character_controls) - .in_set(PropagateTransformsSet) .in_set(RapierTransformPropagateSet), systems::init_async_colliders.after(RapierTransformPropagateSet), systems::apply_scale.after(systems::init_async_colliders), @@ -100,7 +94,7 @@ where .before(systems::init_async_colliders), ) .into_configs(), - PhysicsSet::SyncBackendFlush => (apply_system_buffers,).into_configs(), + PhysicsSet::SyncBackendFlush => (apply_deferred,).into_configs(), PhysicsSet::StepSimulation => ( systems::step_simulation::, Events::::update_system @@ -135,8 +129,7 @@ impl Default for RapierPhysicsPlugin() - .add_system(update_colliding_entities); + .add_systems(Update, update_colliding_entities); let entity1 = app.world.spawn(CollidingEntities::default()).id(); let entity2 = app.world.spawn(CollidingEntities::default()).id(); @@ -1532,8 +1532,8 @@ mod tests { #[cfg(all(feature = "dim3", feature = "async-collider"))] fn async_collider_initializes() { let mut app = App::new(); - app.add_plugin(HeadlessRenderPlugin) - .add_system(init_async_colliders); + app.add_plugins(HeadlessRenderPlugin) + .add_systems(Update, init_async_colliders); let mut meshes = app.world.resource_mut::>(); let cube = meshes.add(Cube::default().into()); @@ -1559,8 +1559,10 @@ mod tests { use bevy::scene::scene_spawner_system; let mut app = App::new(); - app.add_plugin(HeadlessRenderPlugin) - .add_system(init_async_scene_colliders.after(scene_spawner_system)); + app.add_plugins(HeadlessRenderPlugin).add_systems( + Update, + init_async_scene_colliders.after(scene_spawner_system), + ); let mut meshes = app.world.resource_mut::>(); let cube_handle = meshes.add(Cube::default().into()); @@ -1604,10 +1606,12 @@ mod tests { #[test] fn transform_propagation() { let mut app = App::new(); - app.add_plugin(HeadlessRenderPlugin) - .add_plugin(TransformPlugin) - .add_plugin(TimePlugin) - .add_plugin(RapierPhysicsPlugin::::default()); + app.add_plugins(( + HeadlessRenderPlugin, + TransformPlugin, + TimePlugin, + RapierPhysicsPlugin::::default(), + )); let zero = (Transform::default(), Transform::default()); @@ -1659,10 +1663,12 @@ mod tests { #[test] fn transform_propagation2() { let mut app = App::new(); - app.add_plugin(HeadlessRenderPlugin) - .add_plugin(TransformPlugin) - .add_plugin(TimePlugin) - .add_plugin(RapierPhysicsPlugin::::default()); + app.add_plugins(( + HeadlessRenderPlugin, + TransformPlugin, + TimePlugin, + RapierPhysicsPlugin::::default(), + )); let zero = (Transform::default(), Transform::default()); @@ -1739,16 +1745,18 @@ mod tests { impl Plugin for HeadlessRenderPlugin { fn build(&self, app: &mut App) { - app.add_plugin(WindowPlugin::default()) - .add_plugin(AssetPlugin::default()) - .add_plugin(ScenePlugin::default()) - .add_plugin(RenderPlugin { + app.add_plugins(( + WindowPlugin::default(), + AssetPlugin::default(), + ScenePlugin::default(), + RenderPlugin { wgpu_settings: WgpuSettings { backends: None, ..Default::default() }, - }) - .add_plugin(ImagePlugin::default()); + }, + ImagePlugin::default(), + )); } } } diff --git a/src/render/lines/debuglines.wgsl b/src/render/lines/debuglines.wgsl deleted file mode 100644 index 4f5a373e..00000000 --- a/src/render/lines/debuglines.wgsl +++ /dev/null @@ -1,50 +0,0 @@ -#ifdef LINES_3D - #import bevy_pbr::mesh_view_bindings -#else - #import bevy_sprite::mesh2d_view_bindings -#endif - -struct Vertex { - @location(0) pos: vec3, - @location(1) color: vec4, -} - -struct VertexOutput { - @builtin(position) clip_position: vec4, - @location(0) color: vec4, -} - -struct FragmentOutput { -#ifdef LINES_3D // We don’t need frag_depth 2D. - @builtin(frag_depth) depth: f32, -#endif - @location(0) color: vec4, -} - -@vertex -fn vertex(vertex: Vertex) -> VertexOutput { - var out: VertexOutput; - - out.clip_position = view.view_proj * vec4(vertex.pos, 1.0); - out.color = vertex.color; - - return out; -} - -@fragment -fn fragment(in: VertexOutput) -> FragmentOutput { - var out: FragmentOutput; - -// This should be #ifdef DEPTH_TEST_ENABLED && LINES_3D, but the -// preprocessor doesn't support that yet. -// Luckily, DEPTH_TEST_ENABLED isn't set in 2d anyway. -#ifdef LINES_3D - #ifdef DEPTH_TEST_ENABLED - out.depth = in.clip_position.z; - #else - out.depth = 1.0; - #endif -#endif - out.color = in.color; - return out; -} diff --git a/src/render/lines/mod.rs b/src/render/lines/mod.rs deleted file mode 100644 index 2274b268..00000000 --- a/src/render/lines/mod.rs +++ /dev/null @@ -1,409 +0,0 @@ -#![allow(warnings)] - -/** - * - * NOTE: this module and its submodules are only temporary. It is a copy-paste of the bevy-debug-lines - * crate: https://github.com/Toqozz/bevy_debug_lines (MIT license) - * It has been partially updated to work with bevy 0.7, but hasn’t been released yet. - * So, in the mean time, we are keeping a version here that we will replace by the - * upstream dependency once: - * 1. The version compatible with bevy 0.7 is released to crates.io. - * 2. We find a way to make the 2D version work with our examples. The problem - * only happens when running our own examples because cargo’s unification of - * features will enable the `3d` feature of `bevy_debug_lines` when running - * a `2d` example. - * - */ -use bevy::{ - asset::{load_internal_asset, Assets, HandleUntyped}, - prelude::*, - reflect::TypeUuid, - render::{ - mesh::{/*Indices,*/ Mesh, VertexAttributeValues}, - render_phase::AddRenderCommand, - render_resource::PrimitiveTopology, - render_resource::Shader, - view::NoFrustumCulling, - Extract, - }, -}; -use std::sync::{Arc, RwLock}; - -mod render_dim; - -// This module exists to "isolate" the `#[cfg]` attributes to this part of the -// code. Otherwise, we would pollute the code with a lot of feature -// gates-specific code. -#[cfg(feature = "debug-render-3d")] -mod dim3 { - pub(crate) use super::render_dim::r3d::{queue, DebugLinePipeline, DrawDebugLines}; - pub(crate) use bevy::core_pipeline::core_3d::Opaque3d as Phase; -} -#[cfg(feature = "debug-render-2d")] -mod dim2 { - pub(crate) use super::render_dim::r2d::{queue, DebugLinePipeline, DrawDebugLines}; - pub(crate) use bevy::core_pipeline::core_2d::Transparent2d as Phase; -} - -pub(crate) const SHADER_FILE: &str = include_str!("debuglines.wgsl"); -pub(crate) const DEBUG_LINES_SHADER_HANDLE: HandleUntyped = - HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 17477439189930443325); - -#[derive(Resource, Clone)] -pub(crate) struct DebugLinesConfig { - pub always_on_top: Arc>, // Don’t know how to do this properly since this resource lives in a sub-app. -} - -impl DebugLinesConfig { - fn always_on_top(on_top: bool) -> Self { - Self { - always_on_top: Arc::new(RwLock::new(on_top)), - } - } -} - -/// Bevy plugin, for initializing stuff. -/// -/// # Usage -/// -/// ```.ignore -/// use bevy::prelude::*; -/// use bevy_prototype_debug_lines::*; -/// -/// App::new() -/// .add_plugins(DefaultPlugins) -/// .add_plugin(DebugLinesPlugin::default()) -/// .run(); -/// ``` -/// -/// Alternatively, you can initialize the plugin with depth testing, so that -/// debug lines cut through geometry. To do this, use [`DebugLinesPlugin::with_depth_test(true)`]. -/// ```.ignore -/// use bevy::prelude::*; -/// use bevy_prototype_debug_lines::*; -/// -/// App::new() -/// .add_plugins(DefaultPlugins) -/// .add_plugin(DebugLinesPlugin::with_depth_test(true)) -/// .run(); -/// ``` -#[derive(Debug, Default, Clone)] -pub struct DebugLinesPlugin { - always_on_top: bool, -} - -impl DebugLinesPlugin { - /// Controls whether debug lines should be drawn with depth testing enabled - /// or disabled. - /// - /// # Arguments - /// - /// * `val` - True if lines should intersect with other geometry, or false - /// if lines should always draw on top be drawn on top (the default). - pub fn always_on_top(val: bool) -> Self { - Self { always_on_top: val } - } -} - -#[derive(SystemSet, Hash, Debug, PartialEq, Eq, Clone)] -pub struct DrawLinesLabel; - -impl Plugin for DebugLinesPlugin { - fn build(&self, app: &mut App) { - use bevy::render::{render_resource::SpecializedMeshPipelines, RenderApp, RenderSet}; - let mut shaders = app.world.get_resource_mut::>().unwrap(); - shaders.set_untracked(DEBUG_LINES_SHADER_HANDLE, Shader::from_wgsl(SHADER_FILE)); - - let lines_config = DebugLinesConfig::always_on_top(self.always_on_top); - app.init_resource::() - .add_startup_system(setup) - .add_system( - update - .in_base_set(CoreSet::PostUpdate) - .in_set(DrawLinesLabel), - ) - .insert_resource(lines_config.clone()); - - #[cfg(feature = "debug-render-3d")] - app.sub_app_mut(RenderApp) - .add_render_command::() - .init_resource::() - .init_resource::>() - .add_system(dim3::queue.in_set(RenderSet::Queue)); - - #[cfg(feature = "debug-render-2d")] - app.sub_app_mut(RenderApp) - .add_render_command::() - .init_resource::() - .init_resource::>() - .add_system(dim2::queue.in_set(RenderSet::Queue)); - - app.sub_app_mut(RenderApp) - .insert_resource(lines_config) - .add_system(extract.in_schedule(ExtractSchedule)); - - #[cfg(feature = "debug-render-3d")] - info!("Loaded 3d debug lines plugin."); - #[cfg(feature = "debug-render-2d")] - info!("Loaded 2d debug lines plugin."); - } -} - -// Number of meshes to separate line buffers into. -// We don't really do culling currently but this is a gateway to that. -const MESH_COUNT: usize = 4; -// Maximum number of points for each individual mesh. -const MAX_POINTS_PER_MESH: usize = 2_usize.pow(16); -const _MAX_LINES_PER_MESH: usize = MAX_POINTS_PER_MESH / 2; -/// Maximum number of points. -pub const MAX_POINTS: usize = MAX_POINTS_PER_MESH * MESH_COUNT; -/// Maximum number of unique lines to draw at once. -pub const MAX_LINES: usize = MAX_POINTS / 2; - -fn setup(mut cmds: Commands, mut meshes: ResMut>) { - cmds.spawn(( - Name::new("Rapier Debug"), - TransformBundle::default(), - VisibilityBundle::default(), - )) - .with_children(|parent| { - // Spawn a bunch of meshes to use for lines. - for i in 0..MESH_COUNT { - // Create a new mesh with the number of vertices we need. - let mut mesh = Mesh::new(PrimitiveTopology::LineList); - mesh.insert_attribute( - Mesh::ATTRIBUTE_POSITION, - VertexAttributeValues::Float32x3(Vec::with_capacity(MAX_POINTS_PER_MESH)), - ); - mesh.insert_attribute( - Mesh::ATTRIBUTE_COLOR, - VertexAttributeValues::Float32x4(Vec::with_capacity(MAX_POINTS_PER_MESH)), - ); - // https://github.com/Toqozz/bevy_debug_lines/issues/16 - //mesh.set_indices(Some(Indices::U16(Vec::with_capacity(MAX_POINTS_PER_MESH)))); - - let mesh_handle = meshes.add(mesh); - - parent.spawn(( - Name::new(format!("Debug Mesh {i}")), - SpatialBundle::INHERITED_IDENTITY, - NoFrustumCulling, - DebugLinesMesh(i), - #[cfg(feature = "debug-render-3d")] - ( - mesh_handle.clone(), - bevy::pbr::NotShadowCaster, - bevy::pbr::NotShadowReceiver, - ), - #[cfg(feature = "debug-render-2d")] - bevy::sprite::Mesh2dHandle(mesh_handle), - )); - } - }); -} - -fn update( - #[cfg(feature = "debug-render-3d")] debug_line_meshes_3d: Query<( - &Handle, - &DebugLinesMesh, - )>, - #[cfg(feature = "debug-render-2d")] debug_line_meshes_2d: Query<( - &bevy::sprite::Mesh2dHandle, - &DebugLinesMesh, - )>, - time: Res