Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
## Unreleased

### Added

- Add `PdController` and `PidController` for making it easier to control dynamic rigid-bodies at the velocity level.
This can for example be used as a building block for a dynamic character controller.
- Add `RigidBodyPosition::pose_errors` which computes the translational and rotational delta between
`RigidBodyPosition::position` and `::next_position`.
- Implement `Sub` for `RigidBodyVelocity`.
- Add `RigidBody::local_center_of_mass()` to get its center-of-mass in the rigid-body’s local-space.

## v0.23.0 (08 Jan 2025)

### Fix

- The broad-phase region key has been replaced by an i64 in the f64 version of rapier, increasing the range before panics occur.
- The broad-phase region key has been replaced by an i64 in the f64 version of rapier, increasing the range before
panics occur.
- Fix `BroadphaseMultiSap` not being able to serialize correctly with serde_json.
- Fix `KinematicCharacterController::move_shape` not respecting parameters `max_slope_climb_angle` and `min_slope_slide_angle`.
- Fix `KinematicCharacterController::move_shape` not respecting parameters `max_slope_climb_angle` and
`min_slope_slide_angle`.
- Improve ground detection reliability for `KinematicCharacterController`. (#715)
- Fix wasm32 default values for physics hooks filter to be consistent with native: `COMPUTE_IMPULSES`.
- Fix changing a collider parent when ongoing collisions should be affected (#742):
- Fix collisions not being removed when a collider is parented to a rigidbody while in collision with it.
- Fix collisions not being added when the parent was removed while intersecting a (previously) sibling collider.
- Fix collisions not being removed when a collider is parented to a rigidbody while in collision with it.
- Fix collisions not being added when the parent was removed while intersecting a (previously) sibling collider.

### Added

- `RigidBodySet` and `ColliderSet` have a new constructor `with_capacity`.
- Use `profiling` crate to provide helpful profiling information in different tools.
- The testbeds have been updated to use `puffin_egui`
- The testbeds have been updated to use `puffin_egui`

### Modified

- `InteractionGroups` default value for `memberships` is now `GROUP_1` (#706)
- `ImpulseJointSet::get_mut` has a new parameter `wake_up: bool`, to wake up connected bodies.
- Removed unmaintained `instant` in favor of `web-time`. This effectively removes the `wasm-bindgen` transitive dependency as it's no longer needed.
- Removed unmaintained `instant` in favor of `web-time`. This effectively removes the `wasm-bindgen` transitive
dependency as it's no longer needed.
- Significantly improve performances of `QueryPipeline::intersection_with_shape`.

## v0.22.0 (20 July 2024)
Expand Down Expand Up @@ -748,7 +762,8 @@ Several new shape types are now supported:

It is possible to build `ColliderDesc` using these new shapes:

- `ColliderBuilder::round_cuboid`, `ColliderBuilder::segment`, `ColliderBuilder::triangle`, `ColliderBuilder::round_triangle`,
- `ColliderBuilder::round_cuboid`, `ColliderBuilder::segment`, `ColliderBuilder::triangle`,
`ColliderBuilder::round_triangle`,
`ColliderBuilder::convex_hull`, `ColliderBuilder::round_convex_hull`, `ColliderBuilder::polyline`,
`ColliderBuilder::convex_decomposition`, `ColliderBuilder::round_convex_decomposition`,
`ColliderBuilder::convex_polyline` (2D only), `ColliderBuilder::round_convex_polyline` (2D only),
Expand Down
2 changes: 2 additions & 0 deletions examples2d/all_examples2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ mod s2d_pyramid;
mod sensor2;
mod trimesh2;

mod utils;

#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() {
let mut builders: Vec<(_, fn(&mut Testbed))> = vec![
Expand Down
38 changes: 35 additions & 3 deletions examples2d/character_controller2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use crate::utils::character;
use crate::utils::character::CharacterControlMode;
use rapier2d::control::{KinematicCharacterController, PidController};
use rapier2d::prelude::*;
use rapier_testbed2d::Testbed;
use std::f32::consts::PI;
Expand Down Expand Up @@ -25,7 +28,12 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Character we will control manually.
*/
let rigid_body = RigidBodyBuilder::kinematic_position_based().translation(vector![-3.0, 5.0]);
let rigid_body = RigidBodyBuilder::kinematic_position_based()
.translation(vector![-3.0, 5.0])
// The two config below makes the character
// nicer to control with the PID control enabled.
.gravity_scale(10.0)
.soft_ccd_prediction(10.0);
let character_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::capsule_y(0.3, 0.15);
colliders.insert_with_parent(collider, character_handle, &mut bodies);
Expand Down Expand Up @@ -110,7 +118,7 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Create a moving platform.
*/
let body = RigidBodyBuilder::kinematic_velocity_based().translation(vector![-8.0, 1.5]);
let body = RigidBodyBuilder::kinematic_velocity_based().translation(vector![-8.0, 0.0]);
// .rotation(-0.3);
let platform_handle = bodies.insert(body);
let collider = ColliderBuilder::cuboid(2.0, ground_height);
Expand Down Expand Up @@ -160,10 +168,34 @@ pub fn init_world(testbed: &mut Testbed) {
}
});

/*
* Callback to update the character based on user inputs.
*/
let mut control_mode = CharacterControlMode::Kinematic;
let mut controller = KinematicCharacterController {
max_slope_climb_angle: impossible_slope_angle - 0.02,
min_slope_slide_angle: impossible_slope_angle - 0.02,
slide: true,
..Default::default()
};
let mut pid = PidController::default();

testbed.add_callback(move |graphics, physics, _, _| {
if let Some(graphics) = graphics {
character::update_character(
graphics,
physics,
&mut control_mode,
&mut controller,
&mut pid,
character_handle,
);
}
});

/*
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
testbed.set_character_body(character_handle);
testbed.look_at(point![0.0, 1.0], 100.0);
}
24 changes: 23 additions & 1 deletion examples2d/rope_joints2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use crate::utils::character;
use crate::utils::character::CharacterControlMode;
use rapier2d::control::{KinematicCharacterController, PidController};
use rapier2d::prelude::*;
use rapier_testbed2d::Testbed;

Expand Down Expand Up @@ -54,10 +57,29 @@ pub fn init_world(testbed: &mut Testbed) {
let joint = RopeJointBuilder::new(2.0).local_anchor2(point![0.0, 0.0]);
impulse_joints.insert(character_handle, child_handle, joint, true);

/*
* Callback to update the character based on user inputs.
*/
let mut control_mode = CharacterControlMode::Kinematic;
let mut controller = KinematicCharacterController::default();
let mut pid = PidController::default();

testbed.add_callback(move |graphics, physics, _, _| {
if let Some(graphics) = graphics {
character::update_character(
graphics,
physics,
&mut control_mode,
&mut controller,
&mut pid,
character_handle,
);
}
});

/*
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
testbed.set_character_body(character_handle);
testbed.look_at(point![0.0, 1.0], 100.0);
}
Loading