Joint API and joint motors improvements

This commit is contained in:
Sébastien Crozet
2022-02-20 12:55:00 +01:00
committed by Sébastien Crozet
parent e740493b98
commit fb20d72ee2
108 changed files with 2650 additions and 1854 deletions

View File

@@ -16,14 +16,12 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_size = 20.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 ground_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size)
.friction(0.15)
// .restitution(0.5)
.build();
;
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
/*
@@ -32,10 +30,9 @@ pub fn init_world(testbed: &mut Testbed) {
let ball_rad = 0.1;
let rb = RigidBodyBuilder::new_dynamic()
.translation(vector![0.0, 0.2, 0.0])
.linvel(vector![10.0, 0.0, 0.0])
.build();
.linvel(vector![10.0, 0.0, 0.0]);
let ball_handle = bodies.insert(rb);
let collider = ColliderBuilder::ball(ball_rad).density(100.0).build();
let collider = ColliderBuilder::ball(ball_rad).density(100.0);
let ball_coll_handle = colliders.insert_with_parent(collider, ball_handle, &mut bodies);
let mut linvel = Vector::zeros();
@@ -90,19 +87,17 @@ pub fn init_world(testbed: &mut Testbed) {
let z = k as f32 * shiftz - centerz + offset;
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic()
.translation(vector![x, y, z])
.build();
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
let handle = bodies.insert(rigid_body);
let collider = match j % 5 {
0 => ColliderBuilder::cuboid(rad, rad, rad).build(),
1 => ColliderBuilder::ball(rad).build(),
0 => ColliderBuilder::cuboid(rad, rad, rad),
1 => ColliderBuilder::ball(rad),
// Rounded cylinders are much more efficient that cylinder, even if the
// rounding margin is small.
2 => ColliderBuilder::round_cylinder(rad, rad, rad / 10.0).build(),
3 => ColliderBuilder::cone(rad, rad).build(),
_ => ColliderBuilder::capsule_y(rad, rad).build(),
2 => ColliderBuilder::round_cylinder(rad, rad, rad / 10.0),
3 => ColliderBuilder::cone(rad, rad),
_ => ColliderBuilder::capsule_y(rad, rad),
};
colliders.insert_with_parent(collider, handle, &mut bodies);