Skip to content

Commit f15ff6b

Browse files
authored
Update to Bevy 0.17.3 (#680)
* Update to Bevy 0.17 * Update to rapier 0.31.0 and bevy to 0.17.3
1 parent 7258dc4 commit f15ff6b

39 files changed

+504
-226
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: Swatinem/rust-cache@v2
3232
with:
3333
prefix-key: ${{ env.RUST_CACHE_KEY }}
34-
- run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev
34+
- run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
3535
- name: Cargo doc
3636
run: cargo doc --no-deps
3737
test:
@@ -46,7 +46,7 @@ jobs:
4646
- uses: Swatinem/rust-cache@v2
4747
with:
4848
prefix-key: ${{ env.RUST_CACHE_KEY }}
49-
- run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev
49+
- run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
5050
- run: cargo install cargo-all-features
5151
- name: Clippy for bevy_rapier2d
5252
run: cargo clippy --verbose -p bevy_rapier2d --examples

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@
4848
}
4949
}
5050
]
51-
}
51+
}

bevy_rapier2d/Cargo.toml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,37 @@ async-collider = [
6464
to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"]
6565

6666
[dependencies]
67-
bevy = { version = "0.16.0", default-features = false, features = ["std"] }
68-
nalgebra = { version = "0.33", features = ["convert-glam029"] }
69-
rapier2d = "0.27.0-beta.0"
70-
bitflags = "2.4"
67+
bevy = { version = "0.17.3", default-features = false, features = ["std"] }
68+
nalgebra = { version = "0.34.1", features = ["convert-glam030"] }
69+
rapier2d = "0.31.0"
70+
bitflags = "2.10.0"
7171
log = "0.4"
7272
serde = { version = "1", features = ["derive"], optional = true }
7373

7474
[dev-dependencies]
75-
bevy = { version = "0.16.0", default-features = false, features = [
75+
bevy = { version = "0.17.3", default-features = false, features = [
7676
"x11",
7777
"bevy_state",
7878
"bevy_window",
7979
"bevy_debug_stepping",
8080
"bevy_log",
81+
"bevy_text",
82+
"default_font",
83+
"bevy_winit",
84+
"bevy_render",
85+
"bevy_core_pipeline",
86+
"bevy_sprite",
87+
"bevy_sprite_render",
88+
"bevy_gizmos",
89+
"bevy_color",
90+
"bevy_camera",
8191
] }
8292
oorandom = "11"
8393
approx = "0.5.1"
84-
glam = { version = "0.29", features = ["approx"] }
85-
bevy-inspector-egui = "0.31"
86-
bevy_egui = "0.34"
87-
bevy_mod_debugdump = "0.13"
94+
glam = { version = "0.30.9", features = ["approx"] }
95+
bevy-inspector-egui = "0.35.0"
96+
bevy_egui = "0.38.0"
97+
bevy_mod_debugdump = "0.14.0"
8898
serde_json = "1.0"
8999

90100
[package.metadata.docs.rs]

bevy_rapier2d/examples/custom_system_setup2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy::{diagnostic::FrameCount, prelude::*, transform::TransformSystem};
1+
use bevy::{diagnostic::FrameCount, prelude::*};
22
use bevy_rapier2d::prelude::*;
33

44
fn main() {
@@ -24,7 +24,7 @@ fn main() {
2424
PhysicsSet::Writeback,
2525
)
2626
.chain()
27-
.before(TransformSystem::TransformPropagate),
27+
.before(TransformSystems::Propagate),
2828
);
2929

3030
app.add_systems(

bevy_rapier2d/examples/events2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub fn setup_graphics(mut commands: Commands) {
2323
}
2424

2525
pub fn display_events(
26-
mut collision_events: EventReader<CollisionEvent>,
27-
mut contact_force_events: EventReader<ContactForceEvent>,
26+
mut collision_events: MessageReader<CollisionEvent>,
27+
mut contact_force_events: MessageReader<ContactForceEvent>,
2828
) {
2929
for collision_event in collision_events.read() {
3030
println!("Received collision event: {collision_event:?}");

bevy_rapier2d/examples/player_movement2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
.add_plugins((
77
DefaultPlugins.set(WindowPlugin {
88
primary_window: Some(Window {
9-
resolution: WindowResolution::new(1000., 1000.),
9+
resolution: WindowResolution::new(1000, 1000),
1010
title: "Player Movement Example".to_string(),
1111
..default()
1212
}),

bevy_rapier2d/examples/serialization2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ pub fn print_physics(_context: ReadRapierContext) {
3535
panic!("Example 'serialization' should be run with '--features serde-serialize'.");
3636
}
3737

38-
fn quit(mut exit_event: EventWriter<AppExit>) {
38+
fn quit(mut exit_event: MessageWriter<AppExit>) {
3939
exit_event.write(AppExit::Success);
4040
}

bevy_rapier2d/examples/testbed2.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mod rope_joint2;
1414
mod voxels2;
1515

1616
use bevy::{
17+
camera::visibility::RenderLayers,
1718
ecs::world::error::{EntityDespawnError, EntityMutableFetchError},
1819
prelude::*,
1920
};
@@ -67,9 +68,7 @@ fn main() {
6768
app.init_resource::<ExamplesRes>()
6869
.add_plugins((
6970
DefaultPlugins,
70-
EguiPlugin {
71-
enable_multipass_for_primary_context: false,
72-
},
71+
EguiPlugin::default(),
7372
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(10.0),
7473
RapierDebugRenderPlugin::default(),
7574
WorldInspectorPlugin::new(),
@@ -92,6 +91,17 @@ fn main() {
9291
(Examples::PlayerMovement2, "PlayerMovement2").into(),
9392
]))
9493
.init_resource::<ExampleSelected>()
94+
.add_systems(PreStartup, |mut commands: Commands| {
95+
commands.spawn((
96+
Camera2d,
97+
bevy_egui::PrimaryEguiContext,
98+
Camera {
99+
order: 999,
100+
..Default::default()
101+
},
102+
RenderLayers::none(),
103+
));
104+
})
95105
//
96106
//boxes2
97107
.add_systems(
@@ -254,17 +264,21 @@ fn main() {
254264
}
255265

256266
fn init(world: &mut World) {
257-
//save all entities that are in the world before setting up any example
267+
// save all entities that are in the world before setting up any example
258268
// to be able to always return to this state when switching from one example to the other
259-
world.resource_mut::<ExamplesRes>().entities_before =
260-
world.iter_entities().map(|e| e.id()).collect::<Vec<_>>();
269+
world.resource_mut::<ExamplesRes>().entities_before = world
270+
.query::<EntityRef>()
271+
.iter(world)
272+
.map(|e| e.id())
273+
.collect::<Vec<_>>();
261274
}
262275

263276
fn cleanup(world: &mut World) {
264277
let keep_alive = world.resource::<ExamplesRes>().entities_before.clone();
265278

266279
let remove = world
267-
.iter_entities()
280+
.query::<EntityRef>()
281+
.iter(world)
268282
.filter_map(|e| (!keep_alive.contains(&e.id())).then_some(e.id()))
269283
.collect::<Vec<_>>();
270284

@@ -290,7 +304,7 @@ fn ui_example_system(
290304
mut current_example: ResMut<ExampleSelected>,
291305
examples_available: Res<ExampleSet>,
292306
) {
293-
egui::Window::new("Testbed").show(contexts.ctx_mut(), |ui| {
307+
egui::Window::new("Testbed").show(contexts.ctx_mut().unwrap(), |ui| {
294308
let mut changed = false;
295309
egui::ComboBox::from_label("example")
296310
.width(150.0)
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
use bevy::prelude::*;
2+
use bevy_rapier2d::geometry::RapierColliderHandle;
3+
use bevy_rapier2d::prelude::*;
4+
5+
fn main() {
6+
App::new()
7+
.insert_resource(ClearColor(Color::srgb(
8+
0xF9 as f32 / 255.0,
9+
0xF9 as f32 / 255.0,
10+
0xFF as f32 / 255.0,
11+
)))
12+
.add_plugins((
13+
DefaultPlugins,
14+
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(10.0),
15+
RapierDebugRenderPlugin::default(),
16+
))
17+
.add_systems(Startup, setup)
18+
.add_systems(Update, (check_collisions, check_collider_enabled))
19+
.run();
20+
}
21+
22+
fn setup(mut commands: Commands) {
23+
// 2D camera
24+
commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0)));
25+
26+
let scale = 15f32;
27+
28+
let nx = 50;
29+
for i in 0..nx {
30+
for j in 0..10 {
31+
let falling_objects = (j + i) % 3;
32+
let ball_radius = 0.5 * scale;
33+
34+
let collider = match falling_objects {
35+
0 => Collider::ball(ball_radius),
36+
1 => Collider::cuboid(ball_radius, ball_radius),
37+
2 => Collider::capsule_y(ball_radius, ball_radius),
38+
_ => unreachable!(),
39+
};
40+
41+
commands
42+
.spawn((
43+
Transform::from_xyz(
44+
(i as f32 * 2.0 - nx as f32 / 2.0) * scale,
45+
(20.0 + j as f32 * 2.0) * scale,
46+
0.0,
47+
),
48+
RigidBody::Dynamic,
49+
AdditionalMassProperties::Mass(1.0),
50+
))
51+
.with_children(|parent| {
52+
parent.spawn((collider, ColliderDisabled));
53+
});
54+
}
55+
}
56+
57+
let polyline = [
58+
Vec2::new(0.0, 0.0),
59+
Vec2::new(0.0, 10.0),
60+
Vec2::new(7.0, 4.0),
61+
Vec2::new(14.0, 10.0),
62+
Vec2::new(14.0, 0.0),
63+
Vec2::new(13.0, 7.0),
64+
Vec2::new(7.0, 2.0),
65+
Vec2::new(1.0, 7.0),
66+
]
67+
.iter()
68+
.map(|p| p * scale)
69+
.collect::<Vec<_>>();
70+
let indices: Vec<_> = (0..polyline.len() as u32)
71+
.map(|i| [i, (i + 1) % polyline.len() as u32])
72+
.collect();
73+
74+
commands.spawn((
75+
Transform::from_xyz(-20.0 * scale, -10.0 * scale, 0.0),
76+
Collider::voxelized_mesh(&polyline, &indices, 0.2 * scale, FillMode::default()),
77+
ColliderDisabled,
78+
));
79+
80+
let voxel_size = Vec2::new(scale, scale);
81+
let voxels: Vec<_> = (0..300)
82+
.map(|i| {
83+
let y = (i as f32 / 20.0).sin().clamp(-0.5, 0.5) * 20.0;
84+
Vec2::new((i as f32 - 125.0) * voxel_size.x / 2.0, y * voxel_size.y)
85+
})
86+
.collect();
87+
commands.spawn((
88+
Transform::from_xyz(0.0, 0.0, 0.0),
89+
Collider::voxels_from_points(voxel_size, &voxels),
90+
));
91+
}
92+
93+
fn check_collisions(mut collision_events: MessageReader<CollisionEvent>) {
94+
for event in collision_events.read() {
95+
info!("Collision event: {:?}", event);
96+
}
97+
}
98+
99+
fn check_collider_enabled(
100+
rapier_context: ReadRapierContext,
101+
query: Query<&RapierColliderHandle, With<ColliderDisabled>>,
102+
) {
103+
let context = match rapier_context.single() {
104+
Ok(c) => c,
105+
Err(_) => return,
106+
};
107+
108+
for rapier_handle in &query {
109+
let handle = rapier_handle.0;
110+
if let Some(col) = context.colliders.colliders.get(handle) {
111+
if col.is_enabled() {
112+
info!(
113+
"FIX ME: Voxel collider should NOT be enabled: {}",
114+
col.is_enabled()
115+
);
116+
}
117+
}
118+
}
119+
}

bevy_rapier3d/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ async-collider = [
6565
to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"]
6666

6767
[dependencies]
68-
bevy = { version = "0.16.0", default-features = false, features = ["std"] }
69-
nalgebra = { version = "0.33", features = ["convert-glam029"] }
70-
rapier3d = "0.27.0-beta.0"
71-
bitflags = "2.4"
68+
bevy = { version = "0.17.3", default-features = false, features = ["std"] }
69+
nalgebra = { version = "0.34.1", features = ["convert-glam030"] }
70+
rapier3d = "0.31.0"
71+
bitflags = "2.10.0"
7272
log = "0.4"
7373
serde = { version = "1", features = ["derive"], optional = true }
7474

7575
[dev-dependencies]
76-
bevy = { version = "0.16.0", default-features = false, features = [
76+
bevy = { version = "0.17.3", default-features = false, features = [
7777
"bevy_window",
7878
"x11",
7979
"tonemapping_luts",
@@ -85,10 +85,10 @@ bevy = { version = "0.16.0", default-features = false, features = [
8585
"bevy_log",
8686
] }
8787
approx = "0.5.1"
88-
glam = { version = "0.29", features = ["approx"] }
89-
bevy-inspector-egui = "0.31"
90-
bevy_egui = "0.34"
91-
bevy_mod_debugdump = "0.13"
88+
glam = { version = "0.30.9", features = ["approx"] }
89+
bevy-inspector-egui = "0.35.0"
90+
bevy_egui = "0.38.0"
91+
bevy_mod_debugdump = "0.14.0"
9292

9393
[package.metadata.docs.rs]
9494
# Enable all the features when building the docs on docs.rs

0 commit comments

Comments
 (0)