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 for Bevy 0.11-dev : Schedule-First API. #362

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async-collider = [ ]


[dependencies]
bevy = { version = "0.10", default-features = false, features = ["bevy_asset", "bevy_scene"] }
bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["bevy_asset", "bevy_scene"] }
nalgebra = { version = "0.32.2", features = [ "convert-glam023" ] }
# Don't enable the default features because we don't need the ColliderSet/RigidBodySet
rapier2d = "0.17.0"
Expand All @@ -47,7 +47,7 @@ log = "0.4"
serde = { version = "1", features = [ "derive" ], optional = true}

[dev-dependencies]
bevy = { version = "0.10", default-features = false, features = ["x11"]}
bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["x11"]}
oorandom = "11"
approx = "0.5.1"
glam = { version = "0.23", features = [ "approx" ] }
Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier2d/examples/boxes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions bevy_rapier2d/examples/contact_filter2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fn main() {
100.0,
))
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_systems(Startup, setup_graphics)
.add_systems(Startup, setup_physics)
.run();
}

Expand Down
29 changes: 14 additions & 15 deletions bevy_rapier2d/examples/custom_system_setup2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use bevy::{core::FrameCount, ecs::schedule::ScheduleLabel, prelude::*};
use bevy::{
core::FrameCount, ecs::schedule::ScheduleLabel, prelude::*, transform::TransformSystem,
};
use bevy_rapier2d::prelude::*;

#[derive(ScheduleLabel, Hash, Debug, PartialEq, Eq, Clone)]
Expand All @@ -14,14 +16,10 @@ fn main() {
)))
.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),
);
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(PostUpdate, |world: &mut World| {
world.run_schedule(SpecialSchedule);
});

// Do the setup however we want, maybe in its very own schedule
let mut schedule = Schedule::new();
Expand All @@ -33,28 +31,29 @@ fn main() {
PhysicsSet::StepSimulation,
PhysicsSet::Writeback,
)
.chain(),
.chain()
.before(TransformSystem::TransformPropagate),
);

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

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

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

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

app.add_schedule(SpecialSchedule, schedule)
Expand Down
4 changes: 2 additions & 2 deletions bevy_rapier2d/examples/debug_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fn main() {
.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_systems(Startup, setup_game)
.add_systems(Update, cube_sleep_detection)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.run();
Expand Down
6 changes: 2 additions & 4 deletions bevy_rapier2d/examples/despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, (despawn, resize))
.run();
}

Expand Down
5 changes: 2 additions & 3 deletions bevy_rapier2d/examples/events2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.add_systems(PostUpdate, display_events)
.run();
}

Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier2d/examples/joints2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
5 changes: 2 additions & 3 deletions bevy_rapier2d/examples/joints_despawn2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, despawn)
.run();
}

Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier2d/examples/locked_rotations2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier2d/examples/multiple_colliders2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.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_systems(Startup, (setup_graphics, setup_physics))
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions bevy_rapier2d/examples/player_movement2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn main() {
}),
..default()
}))
.add_startup_system(spawn_player)
.add_system(player_movement)
.add_systems(Startup, spawn_player)
.add_systems(Update, player_movement)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.add_plugin(RapierDebugRenderPlugin::default())
.run();
Expand Down
6 changes: 3 additions & 3 deletions bevy_rapier3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ headless = [ ]
async-collider = [ ]

[dependencies]
bevy = { version = "0.10", default-features = false, features = ["bevy_asset", "bevy_scene"] }
bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["bevy_asset", "bevy_scene"] }
nalgebra = { version = "0.32.2", features = [ "convert-glam023" ] }
# Don't enable the default features because we don't need the ColliderSet/RigidBodySet
rapier3d = "0.17.0"
Expand All @@ -48,10 +48,10 @@ log = "0.4"
serde = { version = "1", features = [ "derive" ], optional = true}

[dev-dependencies]
bevy = { version = "0.10", default-features = false, features = ["x11"]}
bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["x11"]}
approx = "0.5.1"
glam = { version = "0.23", features = [ "approx" ] }

[package.metadata.docs.rs]
# Enable all the features when building the docs on docs.rs
features = [ "debug-render-3d", "serde-serialize" ]
features = [ "debug-render-3d", "serde-serialize" ]
3 changes: 1 addition & 2 deletions bevy_rapier3d/examples/boxes3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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
3 changes: 1 addition & 2 deletions bevy_rapier3d/examples/contact_filter3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<SameUserDataFilter>::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
22 changes: 9 additions & 13 deletions bevy_rapier3d/examples/custom_system_setup3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ fn main() {
)))
.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),
);
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(PostUpdate, |world: &mut World| {
world.run_schedule(SpecialSchedule);
});

// Do the setup however we want, maybe in its very own schedule
let mut schedule = Schedule::new();
Expand All @@ -38,23 +34,23 @@ fn main() {

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

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

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

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

app.add_schedule(SpecialSchedule, schedule)
Expand Down
5 changes: 2 additions & 3 deletions bevy_rapier3d/examples/despawn3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(despawn)
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, despawn)
.run();
}

Expand Down
5 changes: 2 additions & 3 deletions bevy_rapier3d/examples/events3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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_systems(Startup, (setup_graphics, setup_physics))
.add_systems(PostUpdate, display_events)
.run();
}

Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier3d/examples/joints3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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
5 changes: 2 additions & 3 deletions bevy_rapier3d/examples/joints_despawn3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(despawn)
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, despawn)
.run();
}

Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier3d/examples/locked_rotations3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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
3 changes: 1 addition & 2 deletions bevy_rapier3d/examples/multiple_colliders3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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
5 changes: 2 additions & 3 deletions bevy_rapier3d/examples/ray_casting3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_system(cast_ray)
.add_systems(Startup, (setup_graphics, setup_physics))
.add_systems(Update, cast_ray)
.run();
}

Expand Down
5 changes: 2 additions & 3 deletions bevy_rapier3d/examples/static_trimesh3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_plugin(RapierDebugRenderPlugin::default())
.add_startup_system(setup_graphics)
.add_startup_system(setup_physics)
.add_systems(Startup, (setup_graphics, setup_physics))
.insert_resource(BallState::default())
.add_system(ball_spawner)
.add_systems(Update, ball_spawner)
.run();
}

Expand Down