diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2fe847..3813a5ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,14 @@ ## Unreleased +**This is an update to Rapier 0.20 which includes several stability improvements +and new features. Please have a look at the +[0.20 changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md) of Rapier.** + ### Modified - Renamed `has_any_active_contacts` to `has_any_active_contact` for better consistency with rapier. +- Update to rapier `0.20`. ### Added diff --git a/Cargo.toml b/Cargo.toml index f752cf60..69f7b7de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,4 +20,4 @@ codegen-units = 1 #parry2d = { git = "https://github.com/dimforge/parry", branch = "master" } #parry3d = { git = "https://github.com/dimforge/parry", branch = "master" } #rapier2d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } -#rapier3d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } \ No newline at end of file +#rapier3d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index 8c1b435e..e576dc41 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -20,8 +20,20 @@ required-features = ["dim2"] [features] default = ["dim2", "async-collider", "debug-render-2d"] dim2 = [] -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"] +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"] @@ -34,7 +46,7 @@ async-collider = ["bevy/bevy_asset", "bevy/bevy_scene"] [dependencies] bevy = { version = "0.13", default-features = false } nalgebra = { version = "0.32.3", features = ["convert-glam025"] } -rapier2d = "0.19.0" +rapier2d = "0.20" bitflags = "2.4" log = "0.4" serde = { version = "1", features = ["derive"], optional = true } diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index 60073514..d519f049 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -21,8 +21,20 @@ 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_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"] +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"] @@ -35,13 +47,16 @@ async-collider = ["bevy/bevy_asset", "bevy/bevy_scene"] [dependencies] bevy = { version = "0.13", default-features = false } nalgebra = { version = "0.32.3", features = ["convert-glam025"] } -rapier3d = "0.19" +rapier3d = "0.20" bitflags = "2.4" log = "0.4" serde = { version = "1", features = ["derive"], optional = true } [dev-dependencies] -bevy = { version = "0.13", default-features = false, features = ["x11", "tonemapping_luts"] } +bevy = { version = "0.13", default-features = false, features = [ + "x11", + "tonemapping_luts", +] } approx = "0.5.1" glam = { version = "0.25", features = ["approx"] } diff --git a/src/dynamics/prismatic_joint.rs b/src/dynamics/prismatic_joint.rs index 5d3f35e4..fdbc4f0f 100644 --- a/src/dynamics/prismatic_joint.rs +++ b/src/dynamics/prismatic_joint.rs @@ -89,19 +89,19 @@ impl PrismaticJoint { /// The motor affecting the joint’s translational degree of freedom. #[must_use] pub fn motor(&self) -> Option<&JointMotor> { - self.data.motor(JointAxis::X) + self.data.motor(JointAxis::LinX) } /// Set the spring-like model used by the motor to reach the desired target velocity and position. pub fn set_motor_model(&mut self, model: MotorModel) -> &mut Self { - self.data.set_motor_model(JointAxis::X, model); + self.data.set_motor_model(JointAxis::LinX, model); self } /// Sets the target velocity this motor needs to reach. pub fn set_motor_velocity(&mut self, target_vel: Real, factor: Real) -> &mut Self { self.data - .set_motor_velocity(JointAxis::X, target_vel, factor); + .set_motor_velocity(JointAxis::LinX, target_vel, factor); self } @@ -113,7 +113,7 @@ impl PrismaticJoint { damping: Real, ) -> &mut Self { self.data - .set_motor_position(JointAxis::X, target_pos, stiffness, damping); + .set_motor_position(JointAxis::LinX, target_pos, stiffness, damping); self } @@ -126,25 +126,25 @@ impl PrismaticJoint { damping: Real, ) -> &mut Self { self.data - .set_motor(JointAxis::X, target_pos, target_vel, stiffness, damping); + .set_motor(JointAxis::LinX, target_pos, target_vel, stiffness, damping); self } /// Sets the maximum force the motor can deliver. pub fn set_motor_max_force(&mut self, max_force: Real) -> &mut Self { - self.data.set_motor_max_force(JointAxis::X, max_force); + self.data.set_motor_max_force(JointAxis::LinX, max_force); self } /// The limit distance attached bodies can translate along the joint’s principal axis. #[must_use] pub fn limits(&self) -> Option<&JointLimits> { - self.data.limits(JointAxis::X) + self.data.limits(JointAxis::LinX) } /// Sets the `[min,max]` limit distances attached bodies can translate along the joint’s principal axis. pub fn set_limits(&mut self, limits: [Real; 2]) -> &mut Self { - self.data.set_limits(JointAxis::X, limits); + self.data.set_limits(JointAxis::LinX, limits); self } } diff --git a/src/dynamics/rope_joint.rs b/src/dynamics/rope_joint.rs index 4369d8b1..d0fbb15d 100644 --- a/src/dynamics/rope_joint.rs +++ b/src/dynamics/rope_joint.rs @@ -93,14 +93,14 @@ impl RopeJoint { /// Set the spring-like model used by the motor to reach the desired target velocity and position. pub fn set_motor_model(&mut self, model: MotorModel) -> &mut Self { - self.data.set_motor_model(JointAxis::X, model); + self.data.set_motor_model(JointAxis::LinX, model); self } /// Sets the target velocity this motor needs to reach. pub fn set_motor_velocity(&mut self, target_vel: Real, factor: Real) -> &mut Self { self.data - .set_motor_velocity(JointAxis::X, target_vel, factor); + .set_motor_velocity(JointAxis::LinX, target_vel, factor); self } @@ -112,7 +112,7 @@ impl RopeJoint { damping: Real, ) -> &mut Self { self.data - .set_motor_position(JointAxis::X, target_pos, stiffness, damping); + .set_motor_position(JointAxis::LinX, target_pos, stiffness, damping); self } @@ -125,13 +125,13 @@ impl RopeJoint { damping: Real, ) -> &mut Self { self.data - .set_motor(JointAxis::X, target_pos, target_vel, stiffness, damping); + .set_motor(JointAxis::LinX, target_pos, target_vel, stiffness, damping); self } /// Sets the maximum force the motor can deliver. pub fn set_motor_max_force(&mut self, max_force: Real) -> &mut Self { - self.data.set_motor_max_force(JointAxis::X, max_force); + self.data.set_motor_max_force(JointAxis::LinX, max_force); self } @@ -145,14 +145,14 @@ impl RopeJoint { /// /// The `max_dist` must be strictly greater than 0.0. pub fn set_max_distance(&mut self, max_dist: Real) -> &mut Self { - self.data.set_limits(JointAxis::X, [0.0, max_dist]); + self.data.set_limits(JointAxis::LinX, [0.0, max_dist]); self } /// The maximum distance between the attached bodies. pub fn max_distance(&self) -> Real { self.data - .limits(JointAxis::X) + .limits(JointAxis::LinX) .map(|l| l.max) .unwrap_or(Real::MAX) } diff --git a/src/dynamics/spring_joint.rs b/src/dynamics/spring_joint.rs index 5c7f9943..c4ac9b8d 100644 --- a/src/dynamics/spring_joint.rs +++ b/src/dynamics/spring_joint.rs @@ -22,8 +22,8 @@ impl SpringJoint { pub fn new(rest_length: Real, stiffness: Real, damping: Real) -> Self { let data = GenericJointBuilder::new(JointAxesMask::empty()) .coupled_axes(JointAxesMask::LIN_AXES) - .motor_position(JointAxis::X, rest_length, stiffness, damping) - .motor_model(JointAxis::X, MotorModel::ForceBased) + .motor_position(JointAxis::LinX, rest_length, stiffness, damping) + .motor_model(JointAxis::LinX, MotorModel::ForceBased) .build(); Self { data } } @@ -75,7 +75,7 @@ impl SpringJoint { /// `MotorModel::AccelerationBased`, the spring constants will be automatically scaled by the attached masses, /// making the spring more mass-independent. pub fn set_spring_model(&mut self, model: MotorModel) -> &mut Self { - self.data.set_motor_model(JointAxis::X, model); + self.data.set_motor_model(JointAxis::LinX, model); self } } diff --git a/src/plugin/context.rs b/src/plugin/context.rs index e842a411..7f7ea17f 100644 --- a/src/plugin/context.rs +++ b/src/plugin/context.rs @@ -338,7 +338,7 @@ impl RapierContext { /// Updates the state of the query pipeline, based on the collider positions known /// from the last timestep or the last call to `self.propagate_modified_body_positions_to_colliders()`. pub fn update_query_pipeline(&mut self) { - self.query_pipeline.update(&self.bodies, &self.colliders); + self.query_pipeline.update(&self.colliders); } /// The map from entities to rigid-body handles. @@ -447,18 +447,16 @@ impl RapierContext { ); if options.apply_impulse_to_dynamic_bodies { - for collision in &*collisions { - controller.solve_character_collision_impulses( - dt, - bodies, - colliders, - query_pipeline, - (&scaled_shape).into(), - shape_mass, - collision, - filter, - ) - } + controller.solve_character_collision_impulses( + dt, + bodies, + colliders, + query_pipeline, + (&scaled_shape).into(), + shape_mass, + collisions.iter().copied(), + filter, + ) } result diff --git a/src/plugin/systems/character_controller.rs b/src/plugin/systems/character_controller.rs index 4b25f6be..57e05da0 100644 --- a/src/plugin/systems/character_controller.rs +++ b/src/plugin/systems/character_controller.rs @@ -115,18 +115,16 @@ pub fn update_character_controls( ); if controller.apply_impulse_to_dynamic_bodies { - for collision in &*collisions { - raw_controller.solve_character_collision_impulses( - context.integration_parameters.dt, - &mut context.bodies, - &context.colliders, - &context.query_pipeline, - character_shape, - character_mass, - collision, - filter, - ) - } + raw_controller.solve_character_collision_impulses( + context.integration_parameters.dt, + &mut context.bodies, + &context.colliders, + &context.query_pipeline, + character_shape, + character_mass, + collisions.iter().copied(), + filter, + ) } if let Ok(mut transform) = transforms.get_mut(entity_to_move) {