feat: solver improvements + release v0.29.0 (#876)

* feat: solver improvements

* feat: add function to get/set whether gyroscopic forces are enabled on a rigid-body

* chore: switch to released versions of parry and wide instead of local patches

* fix cargo doc

* chore: typo fixes

* chore: clippy fix

* Release v0.29.0

* chore: more clippy fixes
This commit is contained in:
Sébastien Crozet
2025-09-05 19:31:58 +02:00
committed by GitHub
parent 317322b31b
commit 134f433903
94 changed files with 5066 additions and 8136 deletions

View File

@@ -44,6 +44,7 @@ mod debug_cube_high_mass_ratio3;
mod debug_internal_edges3;
mod debug_long_chain3;
mod debug_multibody_ang_motor_pos3;
mod gyroscopic3;
mod inverse_kinematics3;
mod joint_motor_position3;
mod keva3;
@@ -75,6 +76,7 @@ pub fn main() {
("Convex decomposition", convex_decomposition3::init_world),
("Convex polyhedron", convex_polyhedron3::init_world),
("Damping", damping3::init_world),
("Gyroscopic", gyroscopic3::init_world),
("Domino", domino3::init_world),
("Dynamic trimeshes", dynamic_trimesh3::init_world),
("Heightfield", heightfield3::init_world),

View File

@@ -12,7 +12,7 @@ pub fn init_world(testbed: &mut Testbed) {
let collider = ColliderBuilder::cuboid(1.0, 1.0, 1.0);
colliders.insert_with_parent(collider, body, &mut bodies);
let rigid_body = RigidBodyBuilder::dynamic().position(Isometry::translation(0.0, 1.0, 0.0));
let rigid_body = RigidBodyBuilder::dynamic().pose(Isometry::translation(0.0, 1.0, 0.0));
let body_part = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(1.0, 1.0, 1.0).density(1.0);
colliders.insert_with_parent(collider, body_part, &mut bodies);

View File

@@ -53,7 +53,7 @@ pub fn init_world(testbed: &mut Testbed) {
Translation::new(x * curr_rad, width * 2.0 + ground_height, z * curr_rad)
* tilt
* rot;
let rigid_body = RigidBodyBuilder::dynamic().position(position);
let rigid_body = RigidBodyBuilder::dynamic().pose(position);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(thickness, width * 2.0, width);
colliders.insert_with_parent(collider, handle, &mut bodies);

30
examples3d/gyroscopic3.rs Normal file
View File

@@ -0,0 +1,30 @@
use rapier_testbed3d::Testbed;
use rapier3d::prelude::*;
// Simulate the the Dzhanibekov effect:
// https://en.wikipedia.org/wiki/Tennis_racket_theorem
pub fn init_world(testbed: &mut Testbed) {
let mut colliders = ColliderSet::new();
let mut bodies = RigidBodySet::new();
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let shapes = vec![
(Isometry::identity(), SharedShape::cuboid(2.0, 0.2, 0.2)),
(
Isometry::translation(0.0, 0.8, 0.0),
SharedShape::cuboid(0.2, 0.4, 0.2),
),
];
let body = RigidBodyBuilder::dynamic()
.gravity_scale(0.0)
.angvel(vector![0.0, 20.0, 0.1])
.gyroscopic_forces_enabled(true);
let body_handle = bodies.insert(body);
let collider = ColliderBuilder::compound(shapes);
colliders.insert_with_parent(collider, body_handle, &mut bodies);
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
testbed.look_at(point![8.0, 0.0, 8.0], point![0.0, 0.0, 0.0]);
}

View File

@@ -167,7 +167,7 @@ fn create_revolute_joints(
let mut handles = [curr_parent; 4];
for k in 0..4 {
let rigid_body = RigidBodyBuilder::dynamic().position(positions[k]);
let rigid_body = RigidBodyBuilder::dynamic().pose(positions[k]);
handles[k] = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(rad, rad, rad);
colliders.insert_with_parent(collider, handles[k], bodies);

View File

@@ -104,7 +104,7 @@ pub fn init_world(testbed: &mut Testbed) {
}
}
for handle in physics.islands.active_dynamic_bodies() {
for handle in physics.islands.active_bodies() {
let body = physics.bodies.get_mut(*handle).unwrap();
if body.position().translation.y > 1.0 {
body.set_gravity_scale(1.0, false);

View File

@@ -75,21 +75,25 @@ pub fn init_world(testbed: &mut Testbed) {
testbed.add_callback(move |_, physics, _, run_state| {
let velocity = vector![
0.0,
(run_state.time * 2.0).sin(),
(run_state.time * 2.0).cos(),
run_state.time.sin() * 2.0
];
// Update the velocity-based kinematic body by setting its velocity.
if let Some(platform) = physics.bodies.get_mut(velocity_based_platform_handle) {
platform.set_linvel(velocity, true);
platform.set_angvel(vector![0.0, 0.2, 0.0], true);
platform.set_angvel(vector![0.0, 1.0, 0.0], true);
}
// Update the position-based kinematic body by setting its next position.
if let Some(platform) = physics.bodies.get_mut(position_based_platform_handle) {
let mut next_tra = *platform.translation();
next_tra += velocity * physics.integration_parameters.dt;
let mut next_rot = *platform.rotation();
next_tra += -velocity * physics.integration_parameters.dt;
next_rot = Rotation::new(vector![0.0, -0.5 * physics.integration_parameters.dt, 0.0])
* next_rot;
platform.set_next_kinematic_translation(next_tra);
platform.set_next_kinematic_rotation(next_rot);
}
});

View File

@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
.density(100.0)
.collision_groups(InteractionGroups::new(CAR_GROUP, !CAR_GROUP));
let body_rb = RigidBodyBuilder::dynamic()
.position(body_position.into())
.pose(body_position.into())
.build();
let body_handle = bodies.insert(body_rb);
colliders.insert_with_parent(body_co, body_handle, &mut bodies);
@@ -69,7 +69,7 @@ pub fn init_world(testbed: &mut Testbed) {
let axle_mass_props = MassProperties::from_ball(100.0, wheel_radius);
let axle_rb = RigidBodyBuilder::dynamic()
.position(wheel_center.into())
.pose(wheel_center.into())
.additional_mass_properties(axle_mass_props);
let axle_handle = bodies.insert(axle_rb);
@@ -87,7 +87,7 @@ pub fn init_world(testbed: &mut Testbed) {
.density(100.0)
.collision_groups(InteractionGroups::new(CAR_GROUP, !CAR_GROUP))
.friction(1.0);
let wheel_rb = RigidBodyBuilder::dynamic().position(wheel_center.into());
let wheel_rb = RigidBodyBuilder::dynamic().pose(wheel_center.into());
let wheel_handle = bodies.insert(wheel_rb);
colliders.insert_with_parent(wheel_co, wheel_handle, &mut bodies);
colliders.insert_with_parent(wheel_fake_co, wheel_handle, &mut bodies);