diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-02-20 12:55:00 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-03-20 21:49:16 +0100 |
| commit | fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4 (patch) | |
| tree | 45827ac4c754c3670d1ddb2f91fc498515d6b3b8 /examples3d/debug_prismatic3.rs | |
| parent | e740493b980dc9856864ead3206a4fa02aff965f (diff) | |
| download | rapier-fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4.tar.gz rapier-fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4.tar.bz2 rapier-fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4.zip | |
Joint API and joint motors improvements
Diffstat (limited to 'examples3d/debug_prismatic3.rs')
| -rw-r--r-- | examples3d/debug_prismatic3.rs | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/examples3d/debug_prismatic3.rs b/examples3d/debug_prismatic3.rs index 15176f3..9f93237 100644 --- a/examples3d/debug_prismatic3.rs +++ b/examples3d/debug_prismatic3.rs @@ -7,16 +7,12 @@ fn prismatic_repro( impulse_joints: &mut ImpulseJointSet, box_center: Point<f32>, ) { - let box_rb = bodies.insert( - RigidBodyBuilder::new_dynamic() - .translation(vector![box_center.x, box_center.y, box_center.z]) - .build(), - ); - colliders.insert_with_parent( - ColliderBuilder::cuboid(1.0, 0.25, 1.0).build(), - box_rb, - bodies, - ); + let box_rb = bodies.insert(RigidBodyBuilder::new_dynamic().translation(vector![ + box_center.x, + box_center.y, + box_center.z + ])); + colliders.insert_with_parent(ColliderBuilder::cuboid(1.0, 0.25, 1.0), box_rb, bodies); let wheel_y = -1.0; let wheel_positions = vec![ @@ -28,36 +24,28 @@ fn prismatic_repro( for pos in wheel_positions { let wheel_pos_in_world = box_center + pos; - let wheel_rb = bodies.insert( - RigidBodyBuilder::new_dynamic() - .translation(vector![ - wheel_pos_in_world.x, - wheel_pos_in_world.y, - wheel_pos_in_world.z - ]) - .build(), - ); - colliders.insert_with_parent(ColliderBuilder::ball(0.5).build(), wheel_rb, bodies); + let wheel_rb = bodies.insert(RigidBodyBuilder::new_dynamic().translation(vector![ + wheel_pos_in_world.x, + wheel_pos_in_world.y, + wheel_pos_in_world.z + ])); + colliders.insert_with_parent(ColliderBuilder::ball(0.5), wheel_rb, bodies); let (stiffness, damping) = (0.05, 0.2); - let prismatic = PrismaticJoint::new(Vector::y_axis()) + let prismatic = PrismaticJointBuilder::new(Vector::y_axis()) .local_anchor1(point![pos.x, pos.y, pos.z]) .motor_position(0.0, stiffness, damping); impulse_joints.insert(box_rb, wheel_rb, prismatic); } // put a small box under one of the wheels - let gravel = bodies.insert( - RigidBodyBuilder::new_dynamic() - .translation(vector![box_center.x + 1.0, box_center.y - 2.4, -1.0]) - .build(), - ); - colliders.insert_with_parent( - ColliderBuilder::cuboid(0.5, 0.1, 0.5).build(), - gravel, - bodies, - ); + let gravel = bodies.insert(RigidBodyBuilder::new_dynamic().translation(vector![ + box_center.x + 1.0, + box_center.y - 2.4, + -1.0 + ])); + colliders.insert_with_parent(ColliderBuilder::cuboid(0.5, 0.1, 0.5), gravel, bodies); } pub fn init_world(testbed: &mut Testbed) { @@ -75,11 +63,9 @@ pub fn init_world(testbed: &mut Testbed) { let ground_size = 50.0; let ground_height = 0.1; - let rigid_body = RigidBodyBuilder::new_static() - .translation(vector![0.0, -ground_height, 0.0]) - .build(); + let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]); let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build(); + let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size); colliders.insert_with_parent(collider, handle, &mut bodies); prismatic_repro( |
