diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-12-11 15:18:11 +0100 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2022-12-11 15:22:36 +0100 |
| commit | 8ef8680817af5b098c65ff5a8b6a1db8e629988a (patch) | |
| tree | a44c591c31bb7c95177787323168f95b31bcbdcc | |
| parent | 849f398031c61b4894d5b8ca229037c026c9186d (diff) | |
| download | rapier-8ef8680817af5b098c65ff5a8b6a1db8e629988a.tar.gz rapier-8ef8680817af5b098c65ff5a8b6a1db8e629988a.tar.bz2 rapier-8ef8680817af5b098c65ff5a8b6a1db8e629988a.zip | |
Update parry and changelog
| -rw-r--r-- | CHANGELOG.md | 5 | ||||
| -rw-r--r-- | crates/rapier2d-f64/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/rapier2d/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/rapier3d-f64/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/rapier3d/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples3d/vehicle_controller3.rs | 112 | ||||
| -rw-r--r-- | src_testbed/testbed.rs | 16 |
7 files changed, 65 insertions, 76 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d00d7..15dd631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,13 @@ ## Unreleased ### Added - Add `RigidBody::set_enabled`, `RigidBody::is_enabled`, `RigidBodyBuilder::enabled` to enable/disable a rigid-body - without having to delete it. + without having to delete it. Disabling a rigid-body attached to a multibody joint isn’t supported yet. - Add `Collider::set_enabled`, `Collider::is_enabled`, `ColliderBuilder::enabled` to enable/disable a collider without having to delete it. - Add `GenericJoint::set_enabled`, `GenericJoint::is_enabled` to enable/disable a joint without having to delete it. + Disabling a multibody joint isn’t supported yet. +- Add `DynamicRayCastVehicleController`, a vehicle controller based on ray-casting and dynamic rigid-bodies (mostly + a port of the vehicle controller from Bullet physics). ### Modified - Add the `QueryPipeline` as an optional argument to `PhysicsPipeline::step` and `CollisionPipeline::step`. If this diff --git a/crates/rapier2d-f64/Cargo.toml b/crates/rapier2d-f64/Cargo.toml index b949095..60ea169 100644 --- a/crates/rapier2d-f64/Cargo.toml +++ b/crates/rapier2d-f64/Cargo.toml @@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true } instant = { version = "0.1", features = [ "now" ], optional = true } num-traits = "0.2" nalgebra = "0.31" -parry2d-f64 = "^0.11.1" +parry2d-f64 = "0.12" simba = "0.7" approx = "0.5" rayon = { version = "1", optional = true } diff --git a/crates/rapier2d/Cargo.toml b/crates/rapier2d/Cargo.toml index 2cc9004..115069c 100644 --- a/crates/rapier2d/Cargo.toml +++ b/crates/rapier2d/Cargo.toml @@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true } instant = { version = "0.1", features = [ "now" ], optional = true } num-traits = "0.2" nalgebra = "0.31" -parry2d = "^0.11.1" +parry2d = "0.12" simba = "0.7" approx = "0.5" rayon = { version = "1", optional = true } diff --git a/crates/rapier3d-f64/Cargo.toml b/crates/rapier3d-f64/Cargo.toml index 929e688..79c2783 100644 --- a/crates/rapier3d-f64/Cargo.toml +++ b/crates/rapier3d-f64/Cargo.toml @@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true } instant = { version = "0.1", features = [ "now" ], optional = true } num-traits = "0.2" nalgebra = "0.31" -parry3d-f64 = "^0.11.1" +parry3d-f64 = "0.12" simba = "0.7" approx = "0.5" rayon = { version = "1", optional = true } diff --git a/crates/rapier3d/Cargo.toml b/crates/rapier3d/Cargo.toml index 942e618..88c5281 100644 --- a/crates/rapier3d/Cargo.toml +++ b/crates/rapier3d/Cargo.toml @@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true } instant = { version = "0.1", features = [ "now" ], optional = true } num-traits = "0.2" nalgebra = "0.31" -parry3d = "^0.11.1" +parry3d = "0.12" simba = "0.7" approx = "0.5" rayon = { version = "1", optional = true } diff --git a/examples3d/vehicle_controller3.rs b/examples3d/vehicle_controller3.rs index 622c008..4f36d9f 100644 --- a/examples3d/vehicle_controller3.rs +++ b/examples3d/vehicle_controller3.rs @@ -29,7 +29,7 @@ pub fn init_world(testbed: &mut Testbed) { let hh = 0.15; let rigid_body = RigidBodyBuilder::dynamic().translation(vector![0.0, 1.0, 0.0]); let vehicle_handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::cuboid(hw, hh, hw); + let collider = ColliderBuilder::cuboid(hw * 2.0, hh, hw).density(100.0); colliders.insert_with_parent(collider, vehicle_handle, &mut bodies); let mut tuning = WheelTuning::default(); @@ -37,10 +37,10 @@ pub fn init_world(testbed: &mut Testbed) { tuning.suspension_damping = 10.0; let mut vehicle = DynamicRayCastVehicleController::new(vehicle_handle); let wheel_positions = [ - point![hw, -hh, hw], - point![hw, -hh, -hw], - point![-hw, -hh, hw], - point![-hw, -hh, -hw], + point![hw * 1.5, -hh, hw], + point![hw * 1.5, -hh, -hw], + point![-hw * 1.5, -hh, hw], + point![-hw * 1.5, -hh, -hw], ]; for pos in wheel_positions { @@ -57,7 +57,7 @@ pub fn init_world(testbed: &mut Testbed) { let centerx = shift * (num / 2) as f32; let centery = rad; - for j in 0usize..4 { + for j in 0usize..1 { for k in 0usize..4 { for i in 0..num { let x = i as f32 * shift - centerx; @@ -73,25 +73,11 @@ pub fn init_world(testbed: &mut Testbed) { } /* - * Create some stairs. - */ - let stair_width = 1.0; - let stair_height = 0.1; - for i in 0..10 { - let x = i as f32 * stair_width / 2.0; - let y = i as f32 * stair_height * 1.5 + 3.0; - - let collider = ColliderBuilder::cuboid(stair_width / 2.0, stair_height / 2.0, stair_width) - .translation(vector![x, y, 0.0]); - colliders.insert(collider); - } - - /* * Create a slope we can climb. */ let slope_angle = 0.2; let slope_size = 2.0; - let collider = ColliderBuilder::cuboid(slope_size, ground_height, slope_size) + let collider = ColliderBuilder::cuboid(slope_size, ground_height, ground_size) .translation(vector![ground_size + slope_size, -ground_height + 0.4, 0.0]) .rotation(Vector::z() * slope_angle); colliders.insert(collider); @@ -110,60 +96,60 @@ pub fn init_world(testbed: &mut Testbed) { .rotation(Vector::z() * impossible_slope_angle); colliders.insert(collider); - /* - * Create a moving platform. - */ - let body = RigidBodyBuilder::kinematic_velocity_based().translation(vector![-8.0, 1.5, 0.0]); - // .rotation(-0.3); - let platform_handle = bodies.insert(body); - let collider = ColliderBuilder::cuboid(2.0, ground_height, 2.0); - colliders.insert_with_parent(collider, platform_handle, &mut bodies); + // /* + // * Create a moving platform. + // */ + // let body = RigidBodyBuilder::kinematic_velocity_based().translation(vector![-8.0, 1.5, 0.0]); + // // .rotation(-0.3); + // let platform_handle = bodies.insert(body); + // let collider = ColliderBuilder::cuboid(2.0, ground_height, 2.0); + // colliders.insert_with_parent(collider, platform_handle, &mut bodies); /* * More complex ground. */ - let ground_size = Vector::new(10.0, 1.0, 10.0); + let ground_size = Vector::new(10.0, 0.4, 10.0); let nsubdivs = 20; let heights = DMatrix::from_fn(nsubdivs + 1, nsubdivs + 1, |i, j| { - (i as f32 * ground_size.x / (nsubdivs as f32) / 2.0).cos() - + (j as f32 * ground_size.z / (nsubdivs as f32) / 2.0).cos() + -(i as f32 * ground_size.x / (nsubdivs as f32) / 2.0).cos() + - (j as f32 * ground_size.z / (nsubdivs as f32) / 2.0).cos() }); let collider = - ColliderBuilder::heightfield(heights, ground_size).translation(vector![-8.0, 5.0, 0.0]); + ColliderBuilder::heightfield(heights, ground_size).translation(vector![-7.0, 0.0, 0.0]); colliders.insert(collider); - /* - * A tilting dynamic body with a limited joint. - */ - let ground = RigidBodyBuilder::fixed().translation(vector![0.0, 5.0, 0.0]); - let ground_handle = bodies.insert(ground); - let body = RigidBodyBuilder::dynamic().translation(vector![0.0, 5.0, 0.0]); - let handle = bodies.insert(body); - let collider = ColliderBuilder::cuboid(1.0, 0.1, 2.0); - colliders.insert_with_parent(collider, handle, &mut bodies); - let joint = RevoluteJointBuilder::new(Vector::z_axis()).limits([-0.3, 0.3]); - impulse_joints.insert(ground_handle, handle, joint, true); - - /* - * Setup a callback to move the platform. - */ - testbed.add_callback(move |_, physics, _, run_state| { - let linvel = vector![ - (run_state.time * 2.0).sin() * 2.0, - (run_state.time * 5.0).sin() * 1.5, - 0.0 - ]; - // let angvel = run_state.time.sin() * 0.5; - - // Update the velocity-based kinematic body by setting its velocity. - if let Some(platform) = physics.bodies.get_mut(platform_handle) { - platform.set_linvel(linvel, true); - // NOTE: interaction with rotating platforms isn’t handled very well yet. - // platform.set_angvel(angvel, true); - } - }); + // /* + // * A tilting dynamic body with a limited joint. + // */ + // let ground = RigidBodyBuilder::fixed().translation(vector![0.0, 5.0, 0.0]); + // let ground_handle = bodies.insert(ground); + // let body = RigidBodyBuilder::dynamic().translation(vector![0.0, 5.0, 0.0]); + // let handle = bodies.insert(body); + // let collider = ColliderBuilder::cuboid(1.0, 0.1, 2.0); + // colliders.insert_with_parent(collider, handle, &mut bodies); + // let joint = RevoluteJointBuilder::new(Vector::z_axis()).limits([-0.3, 0.3]); + // impulse_joints.insert(ground_handle, handle, joint, true); + + // /* + // * Setup a callback to move the platform. + // */ + // testbed.add_callback(move |_, physics, _, run_state| { + // let linvel = vector![ + // (run_state.time * 2.0).sin() * 2.0, + // (run_state.time * 5.0).sin() * 1.5, + // 0.0 + // ]; + // // let angvel = run_state.time.sin() * 0.5; + // + // // Update the velocity-based kinematic body by setting its velocity. + // if let Some(platform) = physics.bodies.get_mut(platform_handle) { + // platform.set_linvel(linvel, true); + // // NOTE: interaction with rotating platforms isn’t handled very well yet. + // // platform.set_angvel(angvel, true); + // } + // }); /* * Set up the testbed. diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs index 50b77c8..1052c55 100644 --- a/src_testbed/testbed.rs +++ b/src_testbed/testbed.rs @@ -652,16 +652,16 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> { for key in events.get_pressed() { match *key { KeyCode::Right => { - steering_angle += -0.1; + steering_angle += -0.7; } KeyCode::Left => { - steering_angle += 0.1; + steering_angle += 0.7; } KeyCode::Up => { - engine_force += 0.1; + engine_force += 30.0; } KeyCode::Down => { - engine_force += -0.1; + engine_force += -30.0; } _ => {} } @@ -1308,10 +1308,10 @@ fn update_testbed( || state.prev_flags.contains(TestbedStateFlags::WIREFRAME) != state.flags.contains(TestbedStateFlags::WIREFRAME) { - // graphics.toggle_wireframe_mode( - // &harness.physics.colliders, - // state.flags.contains(TestbedStateFlags::WIREFRAME), - // ) + graphics.toggle_wireframe_mode( + &harness.physics.colliders, + state.flags.contains(TestbedStateFlags::WIREFRAME), + ) } if state.prev_flags.contains(TestbedStateFlags::SLEEP) |
