Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bevy 0.11 #380

Merged
merged 12 commits into from
Jul 10, 2023
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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"
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/boxes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
11 changes: 5 additions & 6 deletions bevy_rapier2d/examples/contact_filter2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<SameUserDataFilter>::pixels_per_meter(
100.0,
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<SameUserDataFilter>::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();
}

Expand Down
84 changes: 28 additions & 56 deletions bevy_rapier2d/examples/custom_system_setup2.rs
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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::<NoUserData>::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::<NoUserData>::get_systems(PhysicsSet::SyncBackend)
.in_base_set(PhysicsSet::SyncBackend),
);

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackendFlush)
.in_base_set(PhysicsSet::SyncBackendFlush),
);

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation)
.in_base_set(PhysicsSet::StepSimulation),
);
schedule.add_system(despawn_one_box.in_base_set(PhysicsSet::StepSimulation));

schedule.add_systems(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::Writeback)
.in_base_set(PhysicsSet::Writeback),
app.add_systems(
PostUpdate,
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackend)
.in_set(PhysicsSet::SyncBackend),
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackendFlush)
.in_set(PhysicsSet::SyncBackendFlush),
(
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation),
despawn_one_box,
)
.in_set(PhysicsSet::StepSimulation),
RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::Writeback)
.in_set(PhysicsSet::Writeback),
),
);

app.add_schedule(SpecialSchedule, schedule)
.add_plugin(
RapierPhysicsPlugin::<NoUserData>::default()
.with_physics_scale(100.)
.with_default_system_setup(false),
)
.run();
app.run();
}

fn despawn_one_box(
Expand Down
12 changes: 7 additions & 5 deletions bevy_rapier2d/examples/debug_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ fn main() {
App::new()
.init_resource::<Game>()
.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::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, setup_game)
.add_systems(Update, cube_sleep_detection)
.run();
}

Expand Down
14 changes: 7 additions & 7 deletions bevy_rapier2d/examples/despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ fn main() {
)))
.insert_resource(DespawnResource::default())
.insert_resource(ResizeResource::default())
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, (despawn, resize))
.run();
}

Expand Down
13 changes: 7 additions & 6 deletions bevy_rapier2d/examples/events2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(PostUpdate, display_events)
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/joints2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
13 changes: 7 additions & 6 deletions bevy_rapier2d/examples/joints_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ fn main() {
0xFF as f32 / 255.0,
)))
.insert_resource(DespawnResource::default())
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, despawn)
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/locked_rotations2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/multiple_colliders2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
22 changes: 12 additions & 10 deletions bevy_rapier2d/examples/player_movement2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, spawn_player)
.add_systems(Update, player_movement)
.run();
}

Expand Down
11 changes: 6 additions & 5 deletions bevy_rapier2d/examples/rope_joint2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ fn main() {
0xF9 as f32 / 255.0,
0xFF as f32 / 255.0,
)))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down