Skip to content

Update to Bevy 0.16.0-rc.1 #670

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

Merged
merged 15 commits into from
Mar 21, 2025
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ cargo run --example cubes --no-default-features --features "3d f64 parry-f64"

| Bevy | Avian |
| ------- | ----- |
| 0.16 RC | main |
| 0.15 | 0.2 |
| 0.14 | 0.1 |

Expand Down
20 changes: 13 additions & 7 deletions crates/avian2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ bench = false

[dependencies]
avian_derive = { path = "../avian_derive", version = "0.2" }
bevy = { version = "0.15", default-features = false }
bevy_math = { version = "0.15" }
bevy_heavy = { version = "0.1" }
bevy_transform_interpolation = { version = "0.1" }
bevy = { version = "0.16.0-rc.1", default-features = false, features = [
"std",
"bevy_log",
] }
bevy_math = { version = "0.16.0-rc.1" }
bevy_heavy = { git = "https://github.com/Jondolf/bevy_heavy" }
bevy_transform_interpolation = { git = "https://github.com/Jondolf/bevy_transform_interpolation" }
libm = { version = "0.2", optional = true }
parry2d = { version = "0.17", optional = true }
parry2d-f64 = { version = "0.17", optional = true }
Expand All @@ -87,13 +90,16 @@ bitflags = "2.5.0"
[dev-dependencies]
examples_common_2d = { path = "../examples_common_2d" }
benches_common_2d = { path = "../benches_common_2d" }
bevy_math = { version = "0.15", features = ["approx"] }
bevy_heavy = { version = "0.1", features = ["approx"] }
bevy_math = { version = "0.16.0-rc.1", features = ["approx"] }
bevy_heavy = { git = "https://github.com/Jondolf/bevy_heavy", features = [
"approx",
] }
glam = { version = "0.29", features = ["bytemuck"] }
approx = "0.5"
bytemuck = "1.19"
criterion = { version = "0.5", features = ["html_reports"] }
bevy_mod_debugdump = { version = "0.12" }
# TODO: Update to the latest version when it's available.
# bevy_mod_debugdump = { version = "0.12" }

[lints]
workspace = true
Expand Down
10 changes: 6 additions & 4 deletions crates/avian2d/examples/chain_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ fn follow_mouse(
windows: Query<&Window, With<PrimaryWindow>>,
camera: Query<(&Camera, &GlobalTransform)>,
mut follower: Query<&mut Transform, With<FollowMouse>>,
) {
) -> Result {
if buttons.pressed(MouseButton::Left) {
let window = windows.single();
let (camera, camera_transform) = camera.single();
let mut follower_position = follower.single_mut();
let window = windows.single()?;
let (camera, camera_transform) = camera.single()?;
let mut follower_position = follower.single_mut()?;

if let Some(cursor_world_pos) = window
.cursor_position()
Expand All @@ -85,4 +85,6 @@ fn follow_mouse(
cursor_world_pos.extend(follower_position.translation.z);
}
}

Ok(())
}
9 changes: 7 additions & 2 deletions crates/avian2d/examples/debugdump_2d.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! Run with:
//! `cargo run --example debugdump_2d > dump.dot && dot -Tsvg dump.dot > dump.svg`

use avian2d::prelude::*;
use bevy::prelude::*;
// use avian2d::prelude::*;
// use bevy::prelude::*;

fn main() {
todo!("`bevy_mod_debugdump` is not compatible with Bevy 0.16 yet. This example will be updated when it is.");

/*
let mut app = App::new();

app.add_plugins((PhysicsPlugins::default(), PhysicsDebugPlugin::default()));
Expand All @@ -14,5 +17,7 @@ fn main() {
// - SubstepSchedule
// - FixedPostUpdate
// - Update

bevy_mod_debugdump::print_schedule_graph(&mut app, PhysicsSchedule);
*/
}
2 changes: 1 addition & 1 deletion crates/avian2d/examples/determinism_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn clear_scene(
) {
step.0 = 0;
for entity in &query {
commands.entity(entity).despawn_recursive();
commands.entity(entity).despawn();
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/avian2d/examples/dynamic_character_2d/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ fn keyboard_input(
let direction = horizontal as Scalar;

if direction != 0.0 {
movement_event_writer.send(MovementAction::Move(direction));
movement_event_writer.write(MovementAction::Move(direction));
}

if keyboard_input.just_pressed(KeyCode::Space) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}

Expand All @@ -151,11 +151,11 @@ fn gamepad_input(
) {
for gamepad in gamepads.iter() {
if let Some(x) = gamepad.get(GamepadAxis::LeftStickX) {
movement_event_writer.send(MovementAction::Move(x as Scalar));
movement_event_writer.write(MovementAction::Move(x as Scalar));
}

if gamepad.just_pressed(GamepadButton::South) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/avian2d/examples/kinematic_character_2d/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ fn keyboard_input(
let direction = horizontal as Scalar;

if direction != 0.0 {
movement_event_writer.send(MovementAction::Move(direction));
movement_event_writer.write(MovementAction::Move(direction));
}

if keyboard_input.just_pressed(KeyCode::Space) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}

Expand All @@ -165,11 +165,11 @@ fn gamepad_input(
) {
for gamepad in gamepads.iter() {
if let Some(x) = gamepad.get(GamepadAxis::LeftStickX) {
movement_event_writer.send(MovementAction::Move(x as Scalar));
movement_event_writer.write(MovementAction::Move(x as Scalar));
}

if gamepad.just_pressed(GamepadButton::South) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions crates/avian2d/examples/one_way_platform_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

use avian2d::{math::*, prelude::*};
use bevy::{
ecs::system::{lifetimeless::Read, SystemParam},
ecs::{
entity::hash_set::EntityHashSet,
system::{lifetimeless::Read, SystemParam},
},
prelude::*,
utils::HashSet,
};
use examples_common_2d::ExampleCommonPlugin;

Expand Down Expand Up @@ -46,7 +48,7 @@ struct JumpImpulse(Scalar);
// Here we use required components, but you could also add it manually.
#[derive(Clone, Eq, PartialEq, Debug, Default, Component)]
#[require(ActiveCollisionHooks(|| ActiveCollisionHooks::MODIFY_CONTACTS))]
pub struct OneWayPlatform(HashSet<Entity>);
pub struct OneWayPlatform(EntityHashSet);

/// A component to control how an actor interacts with a one-way platform.
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Component, Reflect)]
Expand Down
18 changes: 9 additions & 9 deletions crates/avian2d/examples/sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn keyboard_input1(
}
let space = keyboard_input.pressed(KeyCode::Space);
if space {
movement_event_writer.send(MovementAction::Stop);
movement_event_writer.write(MovementAction::Stop);
return;
}

Expand All @@ -120,7 +120,7 @@ fn keyboard_input1(
let vertical = up as i8 - down as i8;
let direction = Vector::new(horizontal as Scalar, vertical as Scalar);
if direction != Vector::ZERO {
movement_event_writer.send(MovementAction::Velocity(direction));
movement_event_writer.write(MovementAction::Velocity(direction));
}
}
// use position offset
Expand All @@ -140,7 +140,7 @@ fn keyboard_input2(
let vertical = up as i8 - down as i8;
let direction = Vector::new(horizontal as Scalar, vertical as Scalar);
if direction != Vector::ZERO {
movement_event_writer.send(MovementAction::Offset(direction));
movement_event_writer.write(MovementAction::Offset(direction));
}
}

Expand Down Expand Up @@ -219,16 +219,16 @@ fn update_velocity_text(
character_query: Query<(&LinearVelocity, Has<Sleeping>), With<Character>>,
pressure_plate_query: Query<Has<Sleeping>, With<PressurePlate>>,
mut text_query: Query<&mut Text, With<CharacterVelocityText>>,
) {
if let (Ok((velocity, character_sleeping)), Ok(pressure_plate_sleeping)) = (
character_query.get_single(),
pressure_plate_query.get_single(),
) {
text_query.single_mut().0 = format!(
) -> Result {
if let (Ok((velocity, character_sleeping)), Ok(pressure_plate_sleeping)) =
(character_query.single(), pressure_plate_query.single())
{
text_query.single_mut()?.0 = format!(
"Velocity: {:.4}, {:.4}\nCharacter sleeping:{}\nPressure plate sleeping: {}",
velocity.x, velocity.y, character_sleeping, pressure_plate_sleeping
);
}
Ok(())
}

fn log_events(mut started: EventReader<CollisionStarted>, mut ended: EventReader<CollisionEnded>) {
Expand Down
22 changes: 14 additions & 8 deletions crates/avian3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ bench = false

[dependencies]
avian_derive = { path = "../avian_derive", version = "0.2" }
bevy = { version = "0.15", default-features = false }
bevy_math = { version = "0.15" }
bevy_heavy = { version = "0.1" }
bevy_transform_interpolation = { version = "0.1" }
bevy = { version = "0.16.0-rc.1", default-features = false, features = [
"std",
"bevy_log",
] }
bevy_math = { version = "0.16.0-rc.1" }
bevy_heavy = { git = "https://github.com/Jondolf/bevy_heavy" }
bevy_transform_interpolation = { git = "https://github.com/Jondolf/bevy_transform_interpolation" }
libm = { version = "0.2", optional = true }
parry3d = { version = "0.17", optional = true }
parry3d-f64 = { version = "0.17", optional = true }
Expand All @@ -89,15 +92,18 @@ bitflags = "2.5.0"
[dev-dependencies]
examples_common_3d = { path = "../examples_common_3d" }
benches_common_3d = { path = "../benches_common_3d" }
bevy = { version = "0.15", default-features = false, features = [
bevy = { version = "0.16.0-rc.1", default-features = false, features = [
"bevy_gltf",
"animation",
] }
bevy_math = { version = "0.15", features = ["approx"] }
bevy_heavy = { version = "0.1", features = ["approx"] }
bevy_math = { version = "0.16.0-rc.1", features = ["approx"] }
bevy_heavy = { git = "https://github.com/Jondolf/bevy_heavy", features = [
"approx",
] }
approx = "0.5"
criterion = { version = "0.5", features = ["html_reports"] }
bevy_mod_debugdump = { version = "0.12" }
# TODO: Update to the latest version when it's available.
# bevy_mod_debugdump = { version = "0.12" }

[lints]
workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/avian3d/examples/custom_constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl XpbdConstraint<2> for CustomDistanceConstraint {

impl MapEntities for CustomDistanceConstraint {
fn map_entities<M: EntityMapper>(&mut self, entity_mapper: &mut M) {
self.entity1 = entity_mapper.map_entity(self.entity1);
self.entity2 = entity_mapper.map_entity(self.entity2);
self.entity1 = entity_mapper.get_mapped(self.entity1);
self.entity2 = entity_mapper.get_mapped(self.entity2);
}
}

Expand Down
9 changes: 6 additions & 3 deletions crates/avian3d/examples/debugdump_3d.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! Run with:
//! `cargo run --example debugdump_3d > dump.dot && dot -Tsvg dump.dot > dump.svg`

use avian3d::debug_render::PhysicsDebugPlugin;
use avian3d::prelude::*;
use bevy::prelude::*;
// use avian3d::prelude::*;
// use bevy::prelude::*;

fn main() {
todo!("`bevy_mod_debugdump` is not compatible with Bevy 0.16 yet. This example will be updated when it is.");

/*
let mut app = App::new();

app.add_plugins((PhysicsPlugins::default(), PhysicsDebugPlugin::default()));
Expand All @@ -16,4 +18,5 @@ fn main() {
// - FixedPostUpdate
// - Update
bevy_mod_debugdump::print_schedule_graph(&mut app, PhysicsSchedule);
*/
}
2 changes: 1 addition & 1 deletion crates/avian3d/examples/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
// in a debug UI. Requires the `diagnostic_ui` feature.
PhysicsDiagnosticsUiPlugin,
// Optional: Add the `FrameTimeDiagnosticsPlugin` to display frame time.
FrameTimeDiagnosticsPlugin,
FrameTimeDiagnosticsPlugin::default(),
))
// The `PhysicsDiagnosticsUiSettings` resource can be used to configure the diagnostics UI.
//
Expand Down
8 changes: 4 additions & 4 deletions crates/avian3d/examples/dynamic_character_3d/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ fn keyboard_input(
let direction = Vector2::new(horizontal as Scalar, vertical as Scalar).clamp_length_max(1.0);

if direction != Vector2::ZERO {
movement_event_writer.send(MovementAction::Move(direction));
movement_event_writer.write(MovementAction::Move(direction));
}

if keyboard_input.just_pressed(KeyCode::Space) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}

Expand All @@ -162,13 +162,13 @@ fn gamepad_input(
gamepad.get(GamepadAxis::LeftStickX),
gamepad.get(GamepadAxis::LeftStickY),
) {
movement_event_writer.send(MovementAction::Move(
movement_event_writer.write(MovementAction::Move(
Vector2::new(x as Scalar, y as Scalar).clamp_length_max(1.0),
));
}

if gamepad.just_pressed(GamepadButton::South) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/avian3d/examples/kinematic_character_3d/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ fn keyboard_input(
let direction = Vector2::new(horizontal as Scalar, vertical as Scalar).clamp_length_max(1.0);

if direction != Vector2::ZERO {
movement_event_writer.send(MovementAction::Move(direction));
movement_event_writer.write(MovementAction::Move(direction));
}

if keyboard_input.just_pressed(KeyCode::Space) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}

Expand All @@ -177,13 +177,13 @@ fn gamepad_input(
gamepad.get(GamepadAxis::LeftStickX),
gamepad.get(GamepadAxis::LeftStickY),
) {
movement_event_writer.send(MovementAction::Move(
movement_event_writer.write(MovementAction::Move(
Vector2::new(x as Scalar, y as Scalar).clamp_length_max(1.0),
));
}

if gamepad.just_pressed(GamepadButton::South) {
movement_event_writer.send(MovementAction::Jump);
movement_event_writer.write(MovementAction::Jump);
}
}
}
Expand Down
Loading