Rename rigid-body static to fixed
This commit is contained in:
committed by
Sébastien Crozet
parent
db6a8c526d
commit
a9e3441ecd
@@ -6,6 +6,10 @@
|
|||||||
- `RigidsBody::apply_force`, `::apply_torque`, `::apply_force_at_point` have been renamed to `::add_force`,
|
- `RigidsBody::apply_force`, `::apply_torque`, `::apply_force_at_point` have been renamed to `::add_force`,
|
||||||
`::add_torque`, and `::add_force_at_point` to better reflect the fact that they are not cleared at the end
|
`::add_torque`, and `::add_force_at_point` to better reflect the fact that they are not cleared at the end
|
||||||
of the timestep.
|
of the timestep.
|
||||||
|
- Rename `RigidBodyType::Static` to `RigidBodyType::Fixed` to avoid confusion with the `static` keyword.
|
||||||
|
- All method referring to `static` rigid-bodies now use `fixed` instead of `static`.
|
||||||
|
- Rename `RigidBodyBuilder::new_static, new_kinematic_velocity_based, new_kinematic_velocity_based` to
|
||||||
|
`RigidBodyBuilder::fixed, kinematic_velocity_based, kinematic_velocity_based`.
|
||||||
|
|
||||||
## v0.12.0-alpha.0 (2 Jan. 2022)
|
## v0.12.0-alpha.0 (2 Jan. 2022)
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shifty + centery;
|
let y = j as f32 * shifty + centery;
|
||||||
|
|
||||||
let status = if j == 0 {
|
let status = if j == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
let ground_size = 25.0;
|
let ground_size = 25.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![ground_size, ground_size * 2.0]);
|
.translation(vector![ground_size, ground_size * 2.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![-ground_size, ground_size * 2.0]);
|
.translation(vector![-ground_size, ground_size * 2.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -50,7 +50,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift + centery + 2.0;
|
let y = j as f32 * shift + centery + 2.0;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
let ground_size = 25.0;
|
let ground_size = 25.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![ground_size, ground_size * 4.0]);
|
.translation(vector![ground_size, ground_size * 4.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size * 4.0, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size * 4.0, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![-ground_size, ground_size * 4.0]);
|
.translation(vector![-ground_size, ground_size * 4.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -52,7 +52,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shifty + centery + 3.0;
|
let y = j as f32 * shifty + centery + 3.0;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::capsule_y(rad * 1.5, rad);
|
let collider = ColliderBuilder::capsule_y(rad * 1.5, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
let ground_size = 30.0;
|
let ground_size = 30.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![ground_size, ground_size * 2.0]);
|
.translation(vector![ground_size, ground_size * 2.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![-ground_size, ground_size * 2.0]);
|
.translation(vector![-ground_size, ground_size * 2.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let x = i as f32 * shift - centerx;
|
let x = i as f32 * shift - centerx;
|
||||||
let y = j as f32 * shift * 2.0 + centery + 2.0;
|
let y = j as f32 * shift * 2.0 + centery + 2.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let mut points = Vec::new();
|
let mut points = Vec::new();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -46,7 +46,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift + centery + 3.0;
|
let y = j as f32 * shift + centery + 3.0;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
if j % 2 == 0 {
|
if j % 2 == 0 {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let fi = i as f32;
|
let fi = i as f32;
|
||||||
|
|
||||||
let status = if k >= numk / 2 - 3 && k <= numk / 2 + 3 && i == 0 {
|
let status = if k >= numk / 2 - 3 && k <= numk / 2 + 3 && i == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let fi = i as f32;
|
let fi = i as f32;
|
||||||
|
|
||||||
let status = if k == 0 {
|
let status = if k == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for j in 0..50 {
|
for j in 0..50 {
|
||||||
let x = j as f32 * shift * 4.0;
|
let x = j as f32 * shift * 4.0;
|
||||||
|
|
||||||
let ground = RigidBodyBuilder::new_static().translation(vector![x, y]);
|
let ground = RigidBodyBuilder::fixed().translation(vector![x, y]);
|
||||||
let mut curr_parent = bodies.insert(ground);
|
let mut curr_parent = bodies.insert(ground);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
||||||
@@ -32,7 +32,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for i in 0..num {
|
for i in 0..num {
|
||||||
let y = y - (i + 1) as f32 * shift;
|
let y = y - (i + 1) as f32 * shift;
|
||||||
let density = 1.0;
|
let density = 1.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let curr_child = bodies.insert(rigid_body);
|
let curr_child = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad).density(density);
|
let collider = ColliderBuilder::cuboid(rad, rad).density(density);
|
||||||
colliders.insert_with_parent(collider, curr_child, &mut bodies);
|
colliders.insert_with_parent(collider, curr_child, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.0;
|
let ground_size = 100.0;
|
||||||
let ground_thickness = 1.0;
|
let ground_thickness = 1.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness);
|
||||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||||
@@ -39,7 +39,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = fi * shift + centery;
|
let y = fi * shift + centery;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
let status = if j == 0 {
|
let status = if j == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -42,7 +42,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz + offset;
|
let z = k as f32 * shift - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -43,7 +43,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz + offset;
|
let z = k as f32 * shift - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::capsule_y(rad, rad);
|
let collider = ColliderBuilder::capsule_y(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.1;
|
let ground_size = 100.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -45,7 +45,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shiftz - centerz + offset;
|
let z = k as f32 * shiftz - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![x, y, z])
|
.translation(vector![x, y, z])
|
||||||
.linvel(vector![0.0, -1000.0, 0.0])
|
.linvel(vector![0.0, -1000.0, 0.0])
|
||||||
.ccd_enabled(true);
|
.ccd_enabled(true);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -42,7 +42,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift * 2.0 - centerz + offset;
|
let z = k as f32 * shift * 2.0 - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider1 = ColliderBuilder::cuboid(rad * 10.0, rad, rad);
|
let collider1 = ColliderBuilder::cuboid(rad * 10.0, rad, rad);
|
||||||
let collider2 = ColliderBuilder::cuboid(rad, rad * 10.0, rad).translation(vector![
|
let collider2 = ColliderBuilder::cuboid(rad, rad * 10.0, rad).translation(vector![
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::round_convex_hull(&points, border_rad).unwrap();
|
let collider = ColliderBuilder::round_convex_hull(&points, border_rad).unwrap();
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
if j % 2 == 0 {
|
if j % 2 == 0 {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let fi = i as f32;
|
let fi = i as f32;
|
||||||
|
|
||||||
let status = if i == 0 && (k % 4 == 0 || k == num - 1) {
|
let status = if i == 0 && (k % 4 == 0 || k == num - 1) {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
// a joint between these.
|
// a joint between these.
|
||||||
|
|
||||||
let status = if i == 0 && (k % 4 == 0 && k != num - 2 || k == num - 1) {
|
let status = if i == 0 && (k % 4 == 0 && k != num - 2 || k == num - 1) {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for j in 0..50 {
|
for j in 0..50 {
|
||||||
let x = j as f32 * shift * 4.0;
|
let x = j as f32 * shift * 4.0;
|
||||||
|
|
||||||
let ground = RigidBodyBuilder::new_static().translation(vector![x, y, z]);
|
let ground = RigidBodyBuilder::fixed().translation(vector![x, y, z]);
|
||||||
let mut curr_parent = bodies.insert(ground);
|
let mut curr_parent = bodies.insert(ground);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
||||||
@@ -31,7 +31,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for i in 0..num {
|
for i in 0..num {
|
||||||
let z = z + (i + 1) as f32 * shift;
|
let z = z + (i + 1) as f32 * shift;
|
||||||
let density = 1.0;
|
let density = 1.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let curr_child = bodies.insert(rigid_body);
|
let curr_child = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad).density(density);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad).density(density);
|
||||||
colliders.insert_with_parent(collider, curr_child, &mut bodies);
|
colliders.insert_with_parent(collider, curr_child, &mut bodies);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for j in 0..50 {
|
for j in 0..50 {
|
||||||
let x = j as f32 * shift * 4.0;
|
let x = j as f32 * shift * 4.0;
|
||||||
|
|
||||||
let ground = RigidBodyBuilder::new_static().translation(vector![x, y, 0.0]);
|
let ground = RigidBodyBuilder::fixed().translation(vector![x, y, 0.0]);
|
||||||
let mut curr_parent = bodies.insert(ground);
|
let mut curr_parent = bodies.insert(ground);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
colliders.insert_with_parent(collider, curr_parent, &mut bodies);
|
||||||
@@ -38,7 +38,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let mut handles = [curr_parent; 4];
|
let mut handles = [curr_parent; 4];
|
||||||
for k in 0..4 {
|
for k in 0..4 {
|
||||||
let density = 1.0;
|
let density = 1.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().position(positions[k]);
|
let rigid_body = RigidBodyBuilder::dynamic().position(positions[k]);
|
||||||
handles[k] = bodies.insert(rigid_body);
|
handles[k] = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad).density(density);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad).density(density);
|
||||||
colliders.insert_with_parent(collider, handles[k], &mut bodies);
|
colliders.insert_with_parent(collider, handles[k], &mut bodies);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub fn build_block(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
|
||||||
x + dim.x + shift.x,
|
x + dim.x + shift.x,
|
||||||
y + dim.y + shift.y,
|
y + dim.y + shift.y,
|
||||||
z + dim.z + shift.z
|
z + dim.z + shift.z
|
||||||
@@ -59,7 +59,7 @@ pub fn build_block(
|
|||||||
for i in 0..(block_width / (dim.x as f32 * 2.0)) as usize {
|
for i in 0..(block_width / (dim.x as f32 * 2.0)) as usize {
|
||||||
for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
|
for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
|
||||||
i as f32 * dim.x * 2.0 + dim.x + shift.x,
|
i as f32 * dim.x * 2.0 + dim.x + shift.x,
|
||||||
dim.y + shift.y + block_height,
|
dim.y + shift.y + block_height,
|
||||||
j as f32 * dim.z * 2.0 + dim.z + shift.z
|
j as f32 * dim.z * 2.0 + dim.z + shift.z
|
||||||
@@ -88,7 +88,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ fn create_pyramid(
|
|||||||
- stack_height as f32 * half_extents.z;
|
- stack_height as f32 * half_extents.z;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let rigid_body_handle = bodies.insert(rigid_body);
|
let rigid_body_handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider =
|
let collider =
|
||||||
@@ -48,7 +48,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ fn create_tower_circle(
|
|||||||
* Translation::new(0.0, y, radius);
|
* Translation::new(0.0, y, radius);
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().position(pos);
|
let rigid_body = RigidBodyBuilder::dynamic().position(pos);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
||||||
colliders.insert_with_parent(collider, handle, bodies);
|
colliders.insert_with_parent(collider, handle, bodies);
|
||||||
@@ -49,7 +49,7 @@ fn create_wall(
|
|||||||
- stack_height as f32 * half_extents.z;
|
- stack_height as f32 * half_extents.z;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
||||||
colliders.insert_with_parent(collider, handle, bodies);
|
colliders.insert_with_parent(collider, handle, bodies);
|
||||||
@@ -79,7 +79,7 @@ fn create_pyramid(
|
|||||||
- stack_height as f32 * half_extents.z;
|
- stack_height as f32 * half_extents.z;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider =
|
let collider =
|
||||||
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
||||||
@@ -104,7 +104,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.0;
|
let ground_size = 200.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let heightfield = HeightField::new(heights, ground_size);
|
let heightfield = HeightField::new(heights, ground_size);
|
||||||
let (vertices, indices) = heightfield.to_trimesh();
|
let (vertices, indices) = heightfield.to_trimesh();
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::trimesh(vertices, indices);
|
let collider = ColliderBuilder::trimesh(vertices, indices);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -60,7 +60,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
if j % 2 == 0 {
|
if j % 2 == 0 {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let platform_handles = positions
|
let platform_handles = positions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|pos| {
|
.map(|pos| {
|
||||||
let rigid_body = RigidBodyBuilder::new_kinematic_position_based().translation(pos);
|
let rigid_body = RigidBodyBuilder::kinematic_position_based().translation(pos);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad * 10.0, rad);
|
let collider = ColliderBuilder::cuboid(rad * 10.0, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -33,7 +33,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
if state.timestep_id % 10 == 0 {
|
if state.timestep_id % 10 == 0 {
|
||||||
let x = rand::random::<f32>() * 10.0 - 5.0;
|
let x = rand::random::<f32>() * 10.0 - 5.0;
|
||||||
let y = rand::random::<f32>() * 10.0 + 10.0;
|
let y = rand::random::<f32>() * 10.0 + 10.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = physics.bodies.insert(rigid_body);
|
let handle = physics.bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
physics
|
physics
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 25.0;
|
let ground_size = 25.0;
|
||||||
let ground_thickness = 0.1;
|
let ground_thickness = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().ccd_enabled(true);
|
let rigid_body = RigidBodyBuilder::fixed().ccd_enabled(true);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness);
|
||||||
@@ -66,7 +66,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift + centery;
|
let y = j as f32 * shift + centery;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![x, y])
|
.translation(vector![x, y])
|
||||||
.linvel(vector![100.0, -10.0])
|
.linvel(vector![100.0, -10.0])
|
||||||
.ccd_enabled(true);
|
.ccd_enabled(true);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 5.0;
|
let ground_size = 5.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height]);
|
||||||
let floor_handle = bodies.insert(rigid_body);
|
let floor_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
||||||
colliders.insert_with_parent(collider, floor_handle, &mut bodies);
|
colliders.insert_with_parent(collider, floor_handle, &mut bodies);
|
||||||
@@ -70,7 +70,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
(BLUE_GROUP, [0.0, 0.0, 1.0])
|
(BLUE_GROUP, [0.0, 0.0, 1.0])
|
||||||
};
|
};
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad).collision_groups(group);
|
let collider = ColliderBuilder::cuboid(rad, rad).collision_groups(group);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
let ground_size = 30.0;
|
let ground_size = 30.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![ground_size, ground_size * 2.0]);
|
.translation(vector![ground_size, ground_size * 2.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![-ground_size, ground_size * 2.0]);
|
.translation(vector![-ground_size, ground_size * 2.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let x = i as f32 * shift - centerx;
|
let x = i as f32 * shift - centerx;
|
||||||
let y = j as f32 * shift * 2.0 + centery + 2.0;
|
let y = j as f32 * shift * 2.0 + centery + 2.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let mut points = Vec::new();
|
let mut points = Vec::new();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let (x, y) = (i as f32 * subdiv * std::f32::consts::PI * 2.0).sin_cos();
|
let (x, y) = (i as f32 * subdiv * std::f32::consts::PI * 2.0).sin_cos();
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rb = RigidBodyBuilder::new_dynamic()
|
let rb = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![x, y])
|
.translation(vector![x, y])
|
||||||
.linvel(vector![x * 10.0, y * 10.0])
|
.linvel(vector![x * 10.0, y * 10.0])
|
||||||
.angvel(100.0)
|
.angvel(100.0)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
* Ground
|
* Ground
|
||||||
*/
|
*/
|
||||||
let rad = 1.0;
|
let rad = 1.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.translation(vector![0.0, -rad])
|
.translation(vector![0.0, -rad])
|
||||||
.rotation(std::f32::consts::PI / 4.0);
|
.rotation(std::f32::consts::PI / 4.0);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -22,7 +22,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
// Build the dynamic box rigid body.
|
// Build the dynamic box rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 3.0 * rad])
|
.translation(vector![0.0, 3.0 * rad])
|
||||||
.can_sleep(false);
|
.can_sleep(false);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift - centery;
|
let y = j as f32 * shift - centery;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -36,7 +36,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Setup a velocity-based kinematic rigid body.
|
* Setup a velocity-based kinematic rigid body.
|
||||||
*/
|
*/
|
||||||
let platform_body = RigidBodyBuilder::new_kinematic_velocity_based();
|
let platform_body = RigidBodyBuilder::kinematic_velocity_based();
|
||||||
let velocity_based_platform_handle = bodies.insert(platform_body);
|
let velocity_based_platform_handle = bodies.insert(platform_body);
|
||||||
|
|
||||||
let sides = [
|
let sides = [
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -46,7 +46,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift + centery + 3.0;
|
let y = j as f32 * shift + centery + 3.0;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
if j % 2 == 0 {
|
if j % 2 == 0 {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let fi = i as f32;
|
let fi = i as f32;
|
||||||
|
|
||||||
let status = if i == 0 && k == 0 {
|
let status = if i == 0 && k == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 5.0;
|
let ground_size = 5.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -27,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* A rectangle that only rotate.
|
* A rectangle that only rotate.
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 3.0])
|
.translation(vector![0.0, 3.0])
|
||||||
.lock_translations();
|
.lock_translations();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -37,7 +37,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* A tilted capsule that cannot rotate.
|
* A tilted capsule that cannot rotate.
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 5.0])
|
.translation(vector![0.0, 5.0])
|
||||||
.rotation(1.0)
|
.rotation(1.0)
|
||||||
.lock_rotations();
|
.lock_rotations();
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Ground
|
* Ground
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = ColliderBuilder::cuboid(25.0, 0.5)
|
let collider = ColliderBuilder::cuboid(25.0, 0.5)
|
||||||
@@ -96,7 +96,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
if run_state.timestep_id % 50 == 0 && physics.bodies.len() <= 7 {
|
if run_state.timestep_id % 50 == 0 && physics.bodies.len() <= 7 {
|
||||||
// Spawn a new cube.
|
// Spawn a new cube.
|
||||||
let collider = ColliderBuilder::cuboid(1.5, 2.0);
|
let collider = ColliderBuilder::cuboid(1.5, 2.0);
|
||||||
let body = RigidBodyBuilder::new_dynamic().translation(vector![20.0, 10.0]);
|
let body = RigidBodyBuilder::dynamic().translation(vector![20.0, 10.0]);
|
||||||
let handle = physics.bodies.insert(body);
|
let handle = physics.bodies.insert(body);
|
||||||
physics
|
physics
|
||||||
.colliders
|
.colliders
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 10.0;
|
let ground_size = 10.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -37,7 +37,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift + centery;
|
let y = j as f32 * shift + centery;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -47,8 +47,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Setup a position-based kinematic rigid body.
|
* Setup a position-based kinematic rigid body.
|
||||||
*/
|
*/
|
||||||
let platform_body = RigidBodyBuilder::new_kinematic_velocity_based()
|
let platform_body =
|
||||||
.translation(vector![-10.0 * rad, 1.5 + 0.8]);
|
RigidBodyBuilder::kinematic_velocity_based().translation(vector![-10.0 * rad, 1.5 + 0.8]);
|
||||||
let velocity_based_platform_handle = bodies.insert(platform_body);
|
let velocity_based_platform_handle = bodies.insert(platform_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad * 10.0, rad);
|
let collider = ColliderBuilder::cuboid(rad * 10.0, rad);
|
||||||
colliders.insert_with_parent(collider, velocity_based_platform_handle, &mut bodies);
|
colliders.insert_with_parent(collider, velocity_based_platform_handle, &mut bodies);
|
||||||
@@ -56,7 +56,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Setup a velocity-based kinematic rigid body.
|
* Setup a velocity-based kinematic rigid body.
|
||||||
*/
|
*/
|
||||||
let platform_body = RigidBodyBuilder::new_kinematic_position_based()
|
let platform_body = RigidBodyBuilder::kinematic_position_based()
|
||||||
.translation(vector![-10.0 * rad, 2.0 + 1.5 + 0.8]);
|
.translation(vector![-10.0 * rad, 2.0 + 1.5 + 0.8]);
|
||||||
let position_based_platform_handle = bodies.insert(platform_body);
|
let position_based_platform_handle = bodies.insert(platform_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad * 10.0, rad);
|
let collider = ColliderBuilder::cuboid(rad * 10.0, rad);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
points.push(point![ground_size / 2.0, 40.0]);
|
points.push(point![ground_size / 2.0, 40.0]);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::polyline(points, None);
|
let collider = ColliderBuilder::polyline(points, None);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -48,7 +48,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = j as f32 * shift + centery + 3.0;
|
let y = j as f32 * shift + centery + 3.0;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
if j % 2 == 0 {
|
if j % 2 == 0 {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 10.0;
|
let ground_size = 10.0;
|
||||||
let ground_thickness = 1.0;
|
let ground_thickness = 1.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_thickness);
|
||||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||||
@@ -39,7 +39,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = fi * shift + centery;
|
let y = fi * shift + centery;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 20.;
|
let ground_size = 20.;
|
||||||
let ground_height = 1.0;
|
let ground_height = 1.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height).restitution(1.0);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height).restitution(1.0);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -27,8 +27,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for j in 0..2 {
|
for j in 0..2 {
|
||||||
for i in 0..=num {
|
for i in 0..=num {
|
||||||
let x = (i as f32) - num as f32 / 2.0;
|
let x = (i as f32) - num as f32 / 2.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body =
|
||||||
.translation(vector![x * 2.0, 10.0 * (j as f32 + 1.0)]);
|
RigidBodyBuilder::dynamic().translation(vector![x * 2.0, 10.0 * (j as f32 + 1.0)]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::ball(rad).restitution((i as f32) / (num as f32));
|
let collider = ColliderBuilder::ball(rad).restitution((i as f32) / (num as f32));
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height);
|
||||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||||
@@ -35,7 +35,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = 3.0;
|
let y = 3.0;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -48,7 +48,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Rigid body so that the sensor can move.
|
// Rigid body so that the sensor can move.
|
||||||
let sensor = RigidBodyBuilder::new_dynamic().translation(vector![0.0, 10.0]);
|
let sensor = RigidBodyBuilder::dynamic().translation(vector![0.0, 10.0]);
|
||||||
let sensor_handle = bodies.insert(sensor);
|
let sensor_handle = bodies.insert(sensor);
|
||||||
|
|
||||||
// Solid cube attached to the sensor which
|
// Solid cube attached to the sensor which
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
let ground_size = 25.0;
|
let ground_size = 25.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![ground_size, ground_size]);
|
.translation(vector![ground_size, ground_size]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static()
|
let rigid_body = RigidBodyBuilder::fixed()
|
||||||
.rotation(std::f32::consts::FRAC_PI_2)
|
.rotation(std::f32::consts::FRAC_PI_2)
|
||||||
.translation(vector![-ground_size, ground_size]);
|
.translation(vector![-ground_size, ground_size]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
@@ -85,7 +85,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
|
|
||||||
for k in 0..5 {
|
for k in 0..5 {
|
||||||
let collider = ColliderBuilder::trimesh(vertices.clone(), indices.clone());
|
let collider = ColliderBuilder::trimesh(vertices.clone(), indices.clone());
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![ith as f32 * 8.0 - 20.0, 20.0 + k as f32 * 11.0])
|
.translation(vector![ith as f32 * 8.0 - 20.0, 20.0 + k as f32 * 11.0])
|
||||||
.rotation(angle);
|
.rotation(angle);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fn create_wall(
|
|||||||
- stack_height as f32 * half_extents.z;
|
- stack_height as f32 * half_extents.z;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
|
||||||
colliders.insert_with_parent(collider, handle, bodies);
|
colliders.insert_with_parent(collider, handle, bodies);
|
||||||
@@ -50,7 +50,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||||
@@ -93,7 +93,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
.density(10.0)
|
.density(10.0)
|
||||||
.sensor(true)
|
.sensor(true)
|
||||||
.active_events(ActiveEvents::INTERSECTION_EVENTS);
|
.active_events(ActiveEvents::INTERSECTION_EVENTS);
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.linvel(vector![1000.0, 0.0, 0.0])
|
.linvel(vector![1000.0, 0.0, 0.0])
|
||||||
.translation(vector![-20.0, shift_y + 2.0, 0.0])
|
.translation(vector![-20.0, shift_y + 2.0, 0.0])
|
||||||
.ccd_enabled(true);
|
.ccd_enabled(true);
|
||||||
@@ -102,7 +102,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
|
|
||||||
// Second rigid-body with CCD enabled.
|
// Second rigid-body with CCD enabled.
|
||||||
let collider = ColliderBuilder::ball(1.0).density(10.0);
|
let collider = ColliderBuilder::ball(1.0).density(10.0);
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.linvel(vector![1000.0, 0.0, 0.0])
|
.linvel(vector![1000.0, 0.0, 0.0])
|
||||||
.translation(vector![-20.0, shift_y + 2.0, shift_z])
|
.translation(vector![-20.0, shift_y + 2.0, shift_z])
|
||||||
.ccd_enabled(true);
|
.ccd_enabled(true);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 5.0;
|
let ground_size = 5.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let floor_handle = bodies.insert(rigid_body);
|
let floor_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, floor_handle, &mut bodies);
|
colliders.insert_with_parent(collider, floor_handle, &mut bodies);
|
||||||
@@ -73,7 +73,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
(BLUE_GROUP, [0.0, 0.0, 1.0])
|
(BLUE_GROUP, [0.0, 0.0, 1.0])
|
||||||
};
|
};
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad).collision_groups(group);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad).collision_groups(group);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -43,7 +43,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift * 2.0 - centerz + offset;
|
let z = k as f32 * shift * 2.0 - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
// First option: attach several colliders to a single rigid-body.
|
// First option: attach several colliders to a single rigid-body.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -86,7 +86,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let y = (igeom / width) as f32 * shift + 4.0;
|
let y = (igeom / width) as f32 * shift + 4.0;
|
||||||
let z = k as f32 * shift;
|
let z = k as f32 * shift;
|
||||||
|
|
||||||
let body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(body);
|
let handle = bodies.insert(body);
|
||||||
|
|
||||||
for shape in &shapes {
|
for shape in &shapes {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 40.0;
|
let ground_size = 40.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -52,7 +52,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::round_convex_hull(&points, border_rad).unwrap();
|
let collider = ColliderBuilder::round_convex_hull(&points, border_rad).unwrap();
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let (x, y) = (i as f32 * subdiv * std::f32::consts::PI * 2.0).sin_cos();
|
let (x, y) = (i as f32 * subdiv * std::f32::consts::PI * 2.0).sin_cos();
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rb = RigidBodyBuilder::new_dynamic()
|
let rb = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![x, y, 0.0])
|
.translation(vector![x, y, 0.0])
|
||||||
.linvel(vector![x * 10.0, y * 10.0, 0.0])
|
.linvel(vector![x * 10.0, y * 10.0, 0.0])
|
||||||
.angvel(Vector::z() * 100.0)
|
.angvel(Vector::z() * 100.0)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 3.0;
|
let ground_size = 3.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4);
|
||||||
let mut ground_collider_handle =
|
let mut ground_collider_handle =
|
||||||
@@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
* Rolling ball
|
* Rolling ball
|
||||||
*/
|
*/
|
||||||
let ball_rad = 0.1;
|
let ball_rad = 0.1;
|
||||||
let rb = RigidBodyBuilder::new_dynamic().translation(vector![0.0, 0.2, 0.0]);
|
let rb = RigidBodyBuilder::dynamic().translation(vector![0.0, 0.2, 0.0]);
|
||||||
let ball_handle = bodies.insert(rb);
|
let ball_handle = bodies.insert(rb);
|
||||||
let collider = ColliderBuilder::ball(ball_rad).density(100.0);
|
let collider = ColliderBuilder::ball(ball_rad).density(100.0);
|
||||||
colliders.insert_with_parent(collider, ball_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ball_handle, &mut bodies);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ fn create_ball_articulations(
|
|||||||
|
|
||||||
let status = if i == 0 {
|
let status = if i == 0 {
|
||||||
// && (k % 4 == 0 || k == num - 1) {
|
// && (k % 4 == 0 || k == num - 1) {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
@@ -74,7 +74,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
.rotation(vector![0.1, 0.0, 0.1]);
|
.rotation(vector![0.1, 0.0, 0.1]);
|
||||||
colliders.insert(collider);
|
colliders.insert(collider);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic();
|
let rigid_body = RigidBodyBuilder::dynamic();
|
||||||
let collider = ColliderBuilder::cuboid(30.0, 0.01, 30.0)
|
let collider = ColliderBuilder::cuboid(30.0, 0.01, 30.0)
|
||||||
.translation(vector![0.0, -3.0, 0.0])
|
.translation(vector![0.0, -3.0, 0.0])
|
||||||
.rotation(vector![0.1, 0.0, 0.1]);
|
.rotation(vector![0.1, 0.0, 0.1]);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Ground
|
* Ground
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let halfspace = SharedShape::new(HalfSpace::new(Vector::y_axis()));
|
let halfspace = SharedShape::new(HalfSpace::new(Vector::y_axis()));
|
||||||
let collider = ColliderBuilder::new(halfspace);
|
let collider = ColliderBuilder::new(halfspace);
|
||||||
@@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let curr_height = 0.1f32.min(curr_width);
|
let curr_height = 0.1f32.min(curr_width);
|
||||||
curr_y += curr_height * 4.0;
|
curr_y += curr_height * 4.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![0.0, curr_y, 0.0]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![0.0, curr_y, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(curr_width, curr_height, curr_width);
|
let collider = ColliderBuilder::cuboid(curr_width, curr_height, curr_width);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
for _ in 0..6 {
|
for _ in 0..6 {
|
||||||
let rigid_body =
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -26,7 +25,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
|
|
||||||
// Build the dynamic box rigid body.
|
// Build the dynamic box rigid body.
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![1.1, 0.0, 0.0])
|
.translation(vector![1.1, 0.0, 0.0])
|
||||||
// .rotation(vector![0.8, 0.2, 0.1])
|
// .rotation(vector![0.8, 0.2, 0.1])
|
||||||
.can_sleep(false);
|
.can_sleep(false);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.1;
|
let ground_size = 100.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -44,7 +44,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = -centerz + offset;
|
let z = -centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cylinder(rad, rad);
|
let collider = ColliderBuilder::cylinder(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 20.0;
|
let ground_size = 20.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4)
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4)
|
||||||
.friction(0.15)
|
.friction(0.15)
|
||||||
@@ -28,7 +28,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
* Rolling ball
|
* Rolling ball
|
||||||
*/
|
*/
|
||||||
let ball_rad = 0.1;
|
let ball_rad = 0.1;
|
||||||
let rb = RigidBodyBuilder::new_dynamic()
|
let rb = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 0.2, 0.0])
|
.translation(vector![0.0, 0.2, 0.0])
|
||||||
.linvel(vector![10.0, 0.0, 0.0]);
|
.linvel(vector![10.0, 0.0, 0.0]);
|
||||||
let ball_handle = bodies.insert(rb);
|
let ball_handle = bodies.insert(rb);
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.0;
|
let ground_size = 100.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).friction(1.5);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).friction(1.5);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
// Build a dynamic box rigid body.
|
// Build a dynamic box rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 1.1, 0.0])
|
.translation(vector![0.0, 1.1, 0.0])
|
||||||
.rotation(Vector::y() * 0.3);
|
.rotation(Vector::y() * 0.3);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|||||||
@@ -16,21 +16,21 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.1;
|
let ground_size = 100.1;
|
||||||
let ground_height = 2.1;
|
let ground_height = 2.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, 4.0, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, 4.0, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rad = 1.0;
|
let rad = 1.0;
|
||||||
// Build the dynamic box rigid body.
|
// Build the dynamic box rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 7.0 * rad, 0.0])
|
.translation(vector![0.0, 7.0 * rad, 0.0])
|
||||||
.can_sleep(false);
|
.can_sleep(false);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::ball(rad);
|
let collider = ColliderBuilder::ball(rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 2.0 * rad, 0.0])
|
.translation(vector![0.0, 2.0 * rad, 0.0])
|
||||||
.can_sleep(false);
|
.can_sleep(false);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ fn prismatic_repro(
|
|||||||
impulse_joints: &mut ImpulseJointSet,
|
impulse_joints: &mut ImpulseJointSet,
|
||||||
box_center: Point<f32>,
|
box_center: Point<f32>,
|
||||||
) {
|
) {
|
||||||
let box_rb = bodies.insert(RigidBodyBuilder::new_dynamic().translation(vector![
|
let box_rb = bodies.insert(RigidBodyBuilder::dynamic().translation(vector![
|
||||||
box_center.x,
|
box_center.x,
|
||||||
box_center.y,
|
box_center.y,
|
||||||
box_center.z
|
box_center.z
|
||||||
@@ -24,7 +24,7 @@ fn prismatic_repro(
|
|||||||
|
|
||||||
for pos in wheel_positions {
|
for pos in wheel_positions {
|
||||||
let wheel_pos_in_world = box_center + pos;
|
let wheel_pos_in_world = box_center + pos;
|
||||||
let wheel_rb = bodies.insert(RigidBodyBuilder::new_dynamic().translation(vector![
|
let wheel_rb = bodies.insert(RigidBodyBuilder::dynamic().translation(vector![
|
||||||
wheel_pos_in_world.x,
|
wheel_pos_in_world.x,
|
||||||
wheel_pos_in_world.y,
|
wheel_pos_in_world.y,
|
||||||
wheel_pos_in_world.z
|
wheel_pos_in_world.z
|
||||||
@@ -40,7 +40,7 @@ fn prismatic_repro(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// put a small box under one of the wheels
|
// put a small box under one of the wheels
|
||||||
let gravel = bodies.insert(RigidBodyBuilder::new_dynamic().translation(vector![
|
let gravel = bodies.insert(RigidBodyBuilder::dynamic().translation(vector![
|
||||||
box_center.x + 1.0,
|
box_center.x + 1.0,
|
||||||
box_center.y - 2.4,
|
box_center.y - 2.4,
|
||||||
-1.0
|
-1.0
|
||||||
@@ -63,7 +63,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 20.0;
|
let ground_size = 20.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4)
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 0.4)
|
||||||
.friction(0.15)
|
.friction(0.15)
|
||||||
@@ -28,7 +28,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
* Rolling ball
|
* Rolling ball
|
||||||
*/
|
*/
|
||||||
let ball_rad = 0.1;
|
let ball_rad = 0.1;
|
||||||
let rb = RigidBodyBuilder::new_dynamic()
|
let rb = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 0.2, 0.0])
|
.translation(vector![0.0, 0.2, 0.0])
|
||||||
.linvel(vector![10.0, 0.0, 0.0]);
|
.linvel(vector![10.0, 0.0, 0.0]);
|
||||||
let ball_handle = bodies.insert(rb);
|
let ball_handle = bodies.insert(rb);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 20.0;
|
let ground_size = 20.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size)
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size)
|
||||||
.friction(0.15)
|
.friction(0.15)
|
||||||
@@ -28,7 +28,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
* Rolling ball
|
* Rolling ball
|
||||||
*/
|
*/
|
||||||
let ball_rad = 0.1;
|
let ball_rad = 0.1;
|
||||||
let rb = RigidBodyBuilder::new_dynamic()
|
let rb = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 0.2, 0.0])
|
.translation(vector![0.0, 0.2, 0.0])
|
||||||
.linvel(vector![10.0, 0.0, 0.0]);
|
.linvel(vector![10.0, 0.0, 0.0]);
|
||||||
let ball_handle = bodies.insert(rb);
|
let ball_handle = bodies.insert(rb);
|
||||||
@@ -87,7 +87,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shiftz - centerz + offset;
|
let z = k as f32 * shiftz - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = match j % 5 {
|
let collider = match j % 5 {
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
point![0.0, 0.0, 10.0],
|
point![0.0, 0.0, 10.0],
|
||||||
];
|
];
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, 0.0, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, 0.0, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::triangle(vtx[0], vtx[1], vtx[2]);
|
let collider = ColliderBuilder::triangle(vtx[0], vtx[1], vtx[2]);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
// Dynamic box rigid body.
|
// Dynamic box rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![1.1, 0.01, 0.0])
|
.translation(vector![1.1, 0.01, 0.0])
|
||||||
// .rotation(Vector3::new(0.8, 0.2, 0.1))
|
// .rotation(Vector3::new(0.8, 0.2, 0.1))
|
||||||
.can_sleep(false);
|
.can_sleep(false);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Dynamic box rigid body.
|
// Dynamic box rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 35.0, 0.0])
|
.translation(vector![0.0, 35.0, 0.0])
|
||||||
// .rotation(Vector3::new(0.8, 0.2, 0.1))
|
// .rotation(Vector3::new(0.8, 0.2, 0.1))
|
||||||
.can_sleep(false);
|
.can_sleep(false);
|
||||||
@@ -46,7 +46,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let collider = ColliderBuilder::cuboid(1.0, 2.0, 1.0);
|
let collider = ColliderBuilder::cuboid(1.0, 2.0, 1.0);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, 0.0, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, 0.0, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::trimesh(vtx, idx);
|
let collider = ColliderBuilder::trimesh(vtx, idx);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -53,7 +53,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
Translation::new(x * curr_rad, width * 2.0 + ground_height, z * curr_rad)
|
Translation::new(x * curr_rad, width * 2.0 + ground_height, z * curr_rad)
|
||||||
* tilt
|
* tilt
|
||||||
* rot;
|
* rot;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().position(position);
|
let rigid_body = RigidBodyBuilder::dynamic().position(position);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(thickness, width * 2.0, width);
|
let collider = ColliderBuilder::cuboid(thickness, width * 2.0, width);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.1;
|
let ground_size = 100.1;
|
||||||
let ground_height = 2.1; // 16.0;
|
let ground_height = 2.1; // 16.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|
||||||
// Callback that will be executed on the main loop to handle proximities.
|
// Callback that will be executed on the main loop to handle proximities.
|
||||||
testbed.add_callback(move |mut graphics, physics, _, run_state| {
|
testbed.add_callback(move |mut graphics, physics, _, run_state| {
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![0.0, 10.0, 0.0]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![0.0, 10.0, 0.0]);
|
||||||
let handle = physics.bodies.insert(rigid_body);
|
let handle = physics.bodies.insert(rigid_body);
|
||||||
let collider = match run_state.timestep_id % 3 {
|
let collider = match run_state.timestep_id % 3 {
|
||||||
0 => ColliderBuilder::round_cylinder(rad, rad, rad / 10.0),
|
0 => ColliderBuilder::round_cylinder(rad, rad, rad / 10.0),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(harness: &mut Harness) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -43,7 +43,7 @@ pub fn init_world(harness: &mut Harness) {
|
|||||||
let z = k as f32 * shift - centerz + offset;
|
let z = k as f32 * shift - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::capsule_y(rad, rad);
|
let collider = ColliderBuilder::capsule_y(rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
let collider = ColliderBuilder::heightfield(heights, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = match j % 6 {
|
let collider = match j % 6 {
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ fn create_coupled_joints(
|
|||||||
origin: Point<f32>,
|
origin: Point<f32>,
|
||||||
use_articulations: bool,
|
use_articulations: bool,
|
||||||
) {
|
) {
|
||||||
let ground = bodies.insert(RigidBodyBuilder::new_static().translation(origin.coords));
|
let ground = bodies.insert(RigidBodyBuilder::fixed().translation(origin.coords));
|
||||||
let body1 = bodies.insert(
|
let body1 = bodies.insert(
|
||||||
RigidBodyBuilder::new_dynamic()
|
RigidBodyBuilder::dynamic()
|
||||||
.translation(origin.coords)
|
.translation(origin.coords)
|
||||||
.linvel(vector![5.0, 5.0, 5.0]),
|
.linvel(vector![5.0, 5.0, 5.0]),
|
||||||
);
|
);
|
||||||
@@ -42,15 +42,14 @@ fn create_prismatic_joints(
|
|||||||
let rad = 0.4;
|
let rad = 0.4;
|
||||||
let shift = 2.0;
|
let shift = 2.0;
|
||||||
|
|
||||||
let ground = RigidBodyBuilder::new_static().translation(vector![origin.x, origin.y, origin.z]);
|
let ground = RigidBodyBuilder::fixed().translation(vector![origin.x, origin.y, origin.z]);
|
||||||
let mut curr_parent = bodies.insert(ground);
|
let mut curr_parent = bodies.insert(ground);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_parent, bodies);
|
colliders.insert_with_parent(collider, curr_parent, bodies);
|
||||||
|
|
||||||
for i in 0..num {
|
for i in 0..num {
|
||||||
let z = origin.z + (i + 1) as f32 * shift;
|
let z = origin.z + (i + 1) as f32 * shift;
|
||||||
let rigid_body =
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![origin.x, origin.y, z]);
|
||||||
RigidBodyBuilder::new_dynamic().translation(vector![origin.x, origin.y, z]);
|
|
||||||
let curr_child = bodies.insert(rigid_body);
|
let curr_child = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_child, bodies);
|
colliders.insert_with_parent(collider, curr_child, bodies);
|
||||||
@@ -87,15 +86,14 @@ fn create_actuated_prismatic_joints(
|
|||||||
let rad = 0.4;
|
let rad = 0.4;
|
||||||
let shift = 2.0;
|
let shift = 2.0;
|
||||||
|
|
||||||
let ground = RigidBodyBuilder::new_static().translation(vector![origin.x, origin.y, origin.z]);
|
let ground = RigidBodyBuilder::fixed().translation(vector![origin.x, origin.y, origin.z]);
|
||||||
let mut curr_parent = bodies.insert(ground);
|
let mut curr_parent = bodies.insert(ground);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_parent, bodies);
|
colliders.insert_with_parent(collider, curr_parent, bodies);
|
||||||
|
|
||||||
for i in 0..num {
|
for i in 0..num {
|
||||||
let z = origin.z + (i + 1) as f32 * shift;
|
let z = origin.z + (i + 1) as f32 * shift;
|
||||||
let rigid_body =
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![origin.x, origin.y, z]);
|
||||||
RigidBodyBuilder::new_dynamic().translation(vector![origin.x, origin.y, z]);
|
|
||||||
let curr_child = bodies.insert(rigid_body);
|
let curr_child = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_child, bodies);
|
colliders.insert_with_parent(collider, curr_child, bodies);
|
||||||
@@ -153,7 +151,7 @@ fn create_revolute_joints(
|
|||||||
let rad = 0.4;
|
let rad = 0.4;
|
||||||
let shift = 2.0;
|
let shift = 2.0;
|
||||||
|
|
||||||
let ground = RigidBodyBuilder::new_static().translation(vector![origin.x, origin.y, 0.0]);
|
let ground = RigidBodyBuilder::fixed().translation(vector![origin.x, origin.y, 0.0]);
|
||||||
let mut curr_parent = bodies.insert(ground);
|
let mut curr_parent = bodies.insert(ground);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, curr_parent, bodies);
|
colliders.insert_with_parent(collider, curr_parent, bodies);
|
||||||
@@ -170,7 +168,7 @@ fn create_revolute_joints(
|
|||||||
|
|
||||||
let mut handles = [curr_parent; 4];
|
let mut handles = [curr_parent; 4];
|
||||||
for k in 0..4 {
|
for k in 0..4 {
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().position(positions[k]);
|
let rigid_body = RigidBodyBuilder::dynamic().position(positions[k]);
|
||||||
handles[k] = bodies.insert(rigid_body);
|
handles[k] = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, handles[k], bodies);
|
colliders.insert_with_parent(collider, handles[k], bodies);
|
||||||
@@ -210,14 +208,13 @@ fn create_revolute_joints_with_limits(
|
|||||||
origin: Point<f32>,
|
origin: Point<f32>,
|
||||||
use_articulations: bool,
|
use_articulations: bool,
|
||||||
) {
|
) {
|
||||||
let ground = bodies.insert(RigidBodyBuilder::new_static().translation(origin.coords));
|
let ground = bodies.insert(RigidBodyBuilder::fixed().translation(origin.coords));
|
||||||
|
|
||||||
let platform1 = bodies.insert(RigidBodyBuilder::new_dynamic().translation(origin.coords));
|
let platform1 = bodies.insert(RigidBodyBuilder::dynamic().translation(origin.coords));
|
||||||
colliders.insert_with_parent(ColliderBuilder::cuboid(4.0, 0.2, 2.0), platform1, bodies);
|
colliders.insert_with_parent(ColliderBuilder::cuboid(4.0, 0.2, 2.0), platform1, bodies);
|
||||||
|
|
||||||
let shift = vector![0.0, 0.0, 6.0];
|
let shift = vector![0.0, 0.0, 6.0];
|
||||||
let platform2 =
|
let platform2 = bodies.insert(RigidBodyBuilder::dynamic().translation(origin.coords + shift));
|
||||||
bodies.insert(RigidBodyBuilder::new_dynamic().translation(origin.coords + shift));
|
|
||||||
colliders.insert_with_parent(ColliderBuilder::cuboid(4.0, 0.2, 2.0), platform2, bodies);
|
colliders.insert_with_parent(ColliderBuilder::cuboid(4.0, 0.2, 2.0), platform2, bodies);
|
||||||
|
|
||||||
let z = Vector::z_axis();
|
let z = Vector::z_axis();
|
||||||
@@ -256,9 +253,8 @@ fn create_revolute_joints_with_limits(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Let’s add a couple of cuboids that will fall on the platforms, triggering the joint limits.
|
// Let’s add a couple of cuboids that will fall on the platforms, triggering the joint limits.
|
||||||
let cuboid_body1 = bodies.insert(
|
let cuboid_body1 = bodies
|
||||||
RigidBodyBuilder::new_dynamic().translation(origin.coords + vector![-2.0, 4.0, 0.0]),
|
.insert(RigidBodyBuilder::dynamic().translation(origin.coords + vector![-2.0, 4.0, 0.0]));
|
||||||
);
|
|
||||||
colliders.insert_with_parent(
|
colliders.insert_with_parent(
|
||||||
ColliderBuilder::cuboid(0.6, 0.6, 0.6).friction(1.0),
|
ColliderBuilder::cuboid(0.6, 0.6, 0.6).friction(1.0),
|
||||||
cuboid_body1,
|
cuboid_body1,
|
||||||
@@ -266,8 +262,7 @@ fn create_revolute_joints_with_limits(
|
|||||||
);
|
);
|
||||||
|
|
||||||
let cuboid_body2 = bodies.insert(
|
let cuboid_body2 = bodies.insert(
|
||||||
RigidBodyBuilder::new_dynamic()
|
RigidBodyBuilder::dynamic().translation(origin.coords + shift + vector![2.0, 16.0, 0.0]),
|
||||||
.translation(origin.coords + shift + vector![2.0, 16.0, 0.0]),
|
|
||||||
);
|
);
|
||||||
colliders.insert_with_parent(
|
colliders.insert_with_parent(
|
||||||
ColliderBuilder::cuboid(0.6, 0.6, 0.6).friction(1.0),
|
ColliderBuilder::cuboid(0.6, 0.6, 0.6).friction(1.0),
|
||||||
@@ -299,7 +294,7 @@ fn create_fixed_joints(
|
|||||||
// fixed bodies. Because physx will crash if we add
|
// fixed bodies. Because physx will crash if we add
|
||||||
// a joint between these.
|
// a joint between these.
|
||||||
let status = if i == 0 && (k % 4 == 0 && k != num - 2 || k == num - 1) {
|
let status = if i == 0 && (k % 4 == 0 && k != num - 2 || k == num - 1) {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
@@ -358,7 +353,7 @@ fn create_spherical_joints(
|
|||||||
let fi = i as f32;
|
let fi = i as f32;
|
||||||
|
|
||||||
let status = if i == 0 && (k % 4 == 0 || k == num - 1) {
|
let status = if i == 0 && (k % 4 == 0 || k == num - 1) {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
@@ -408,17 +403,16 @@ fn create_spherical_joints_with_limits(
|
|||||||
) {
|
) {
|
||||||
let shift = vector![0.0, 0.0, 3.0];
|
let shift = vector![0.0, 0.0, 3.0];
|
||||||
|
|
||||||
let ground = bodies.insert(RigidBodyBuilder::new_static().translation(origin.coords));
|
let ground = bodies.insert(RigidBodyBuilder::fixed().translation(origin.coords));
|
||||||
|
|
||||||
let ball1 = bodies.insert(
|
let ball1 = bodies.insert(
|
||||||
RigidBodyBuilder::new_dynamic()
|
RigidBodyBuilder::dynamic()
|
||||||
.translation(origin.coords + shift)
|
.translation(origin.coords + shift)
|
||||||
.linvel(vector![20.0, 20.0, 0.0]),
|
.linvel(vector![20.0, 20.0, 0.0]),
|
||||||
);
|
);
|
||||||
colliders.insert_with_parent(ColliderBuilder::cuboid(1.0, 1.0, 1.0), ball1, bodies);
|
colliders.insert_with_parent(ColliderBuilder::cuboid(1.0, 1.0, 1.0), ball1, bodies);
|
||||||
|
|
||||||
let ball2 =
|
let ball2 = bodies.insert(RigidBodyBuilder::dynamic().translation(origin.coords + shift * 2.0));
|
||||||
bodies.insert(RigidBodyBuilder::new_dynamic().translation(origin.coords + shift * 2.0));
|
|
||||||
colliders.insert_with_parent(ColliderBuilder::cuboid(1.0, 1.0, 1.0), ball2, bodies);
|
colliders.insert_with_parent(ColliderBuilder::cuboid(1.0, 1.0, 1.0), ball2, bodies);
|
||||||
|
|
||||||
let joint1 = SphericalJointBuilder::new()
|
let joint1 = SphericalJointBuilder::new()
|
||||||
@@ -465,7 +459,7 @@ fn create_actuated_revolute_joints(
|
|||||||
// fixed bodies. Because physx will crash if we add
|
// fixed bodies. Because physx will crash if we add
|
||||||
// a joint between these.
|
// a joint between these.
|
||||||
let status = if i == 0 {
|
let status = if i == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
@@ -533,7 +527,7 @@ fn create_actuated_spherical_joints(
|
|||||||
// fixed bodies. Because physx will crash if we add
|
// fixed bodies. Because physx will crash if we add
|
||||||
// a joint between these.
|
// a joint between these.
|
||||||
let status = if i == 0 {
|
let status = if i == 0 {
|
||||||
RigidBodyType::Static
|
RigidBodyType::Fixed
|
||||||
} else {
|
} else {
|
||||||
RigidBodyType::Dynamic
|
RigidBodyType::Dynamic
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub fn build_block(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
|
||||||
x + dim.x + shift.x,
|
x + dim.x + shift.x,
|
||||||
y + dim.y + shift.y,
|
y + dim.y + shift.y,
|
||||||
z + dim.z + shift.z
|
z + dim.z + shift.z
|
||||||
@@ -59,7 +59,7 @@ pub fn build_block(
|
|||||||
for i in 0..(block_width / (dim.x as f32 * 2.0)) as usize {
|
for i in 0..(block_width / (dim.x as f32 * 2.0)) as usize {
|
||||||
for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
|
for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
|
||||||
i as f32 * dim.x * 2.0 + dim.x + shift.x,
|
i as f32 * dim.x * 2.0 + dim.x + shift.x,
|
||||||
dim.y + shift.y + block_height,
|
dim.y + shift.y + block_height,
|
||||||
j as f32 * dim.z * 2.0 + dim.z + shift.z
|
j as f32 * dim.z * 2.0 + dim.z + shift.z
|
||||||
@@ -88,7 +88,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 50.0;
|
let ground_size = 50.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 5.0;
|
let ground_size = 5.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -27,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* A rectangle that only rotates along the `x` axis.
|
* A rectangle that only rotates along the `x` axis.
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 3.0, 0.0])
|
.translation(vector![0.0, 3.0, 0.0])
|
||||||
.lock_translations()
|
.lock_translations()
|
||||||
.restrict_rotations(true, false, false);
|
.restrict_rotations(true, false, false);
|
||||||
@@ -38,7 +38,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* A tilted capsule that cannot rotate.
|
* A tilted capsule that cannot rotate.
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::dynamic()
|
||||||
.translation(vector![0.0, 5.0, 0.0])
|
.translation(vector![0.0, 5.0, 0.0])
|
||||||
.rotation(Vector::x() * 1.0)
|
.rotation(Vector::x() * 1.0)
|
||||||
.lock_rotations();
|
.lock_rotations();
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Ground
|
* Ground
|
||||||
*/
|
*/
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = ColliderBuilder::cuboid(9.0, 0.5, 25.0)
|
let collider = ColliderBuilder::cuboid(9.0, 0.5, 25.0)
|
||||||
@@ -96,7 +96,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
if run_state.timestep_id % 50 == 0 && physics.bodies.len() <= 7 {
|
if run_state.timestep_id % 50 == 0 && physics.bodies.len() <= 7 {
|
||||||
// Spawn a new cube.
|
// Spawn a new cube.
|
||||||
let collider = ColliderBuilder::cuboid(1.0, 2.0, 1.5);
|
let collider = ColliderBuilder::cuboid(1.0, 2.0, 1.5);
|
||||||
let body = RigidBodyBuilder::new_dynamic().translation(vector![0.0, 6.0, 20.0]);
|
let body = RigidBodyBuilder::dynamic().translation(vector![0.0, 6.0, 20.0]);
|
||||||
let handle = physics.bodies.insert(body);
|
let handle = physics.bodies.insert(body);
|
||||||
physics
|
physics
|
||||||
.colliders
|
.colliders
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 10.0;
|
let ground_size = 10.0;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -40,7 +40,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -51,7 +51,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Setup a velocity-based kinematic rigid body.
|
* Setup a velocity-based kinematic rigid body.
|
||||||
*/
|
*/
|
||||||
let platform_body = RigidBodyBuilder::new_kinematic_velocity_based().translation(vector![
|
let platform_body = RigidBodyBuilder::kinematic_velocity_based().translation(vector![
|
||||||
0.0,
|
0.0,
|
||||||
1.5 + 0.8,
|
1.5 + 0.8,
|
||||||
-10.0 * rad
|
-10.0 * rad
|
||||||
@@ -63,7 +63,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
/*
|
/*
|
||||||
* Setup a position-based kinematic rigid body.
|
* Setup a position-based kinematic rigid body.
|
||||||
*/
|
*/
|
||||||
let platform_body = RigidBodyBuilder::new_kinematic_position_based().translation(vector![
|
let platform_body = RigidBodyBuilder::kinematic_position_based().translation(vector![
|
||||||
0.0,
|
0.0,
|
||||||
2.0 + 1.5 + 0.8,
|
2.0 + 1.5 + 0.8,
|
||||||
-10.0 * rad
|
-10.0 * rad
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 100.1;
|
let ground_size = 100.1;
|
||||||
let ground_height = 2.1;
|
let ground_height = 2.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -44,7 +44,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shiftz - centerz + offset;
|
let z = k as f32 * shiftz - centerz + offset;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = match j % 5 {
|
let collider = match j % 5 {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 20.;
|
let ground_size = 20.;
|
||||||
let ground_height = 1.0;
|
let ground_height = 1.0;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 2.0).restitution(1.0);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, 2.0).restitution(1.0);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -27,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
for j in 0..2 {
|
for j in 0..2 {
|
||||||
for i in 0..=num {
|
for i in 0..=num {
|
||||||
let x = (i as f32) - num as f32 / 2.0;
|
let x = (i as f32) - num as f32 / 2.0;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
|
||||||
x * 2.0,
|
x * 2.0,
|
||||||
10.0 * (j as f32 + 1.0),
|
10.0 * (j as f32 + 1.0),
|
||||||
0.0
|
0.0
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let ground_size = 200.1;
|
let ground_size = 200.1;
|
||||||
let ground_height = 0.1;
|
let ground_height = 0.1;
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static().translation(vector![0.0, -ground_height, 0.0]);
|
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||||
let ground_handle = bodies.insert(rigid_body);
|
let ground_handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||||
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
|
||||||
@@ -38,7 +38,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
let collider = ColliderBuilder::cuboid(rad, rad, rad);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -52,7 +52,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Rigid body so that the sensor can move.
|
// Rigid body so that the sensor can move.
|
||||||
let sensor = RigidBodyBuilder::new_dynamic().translation(vector![0.0, 5.0, 0.0]);
|
let sensor = RigidBodyBuilder::dynamic().translation(vector![0.0, 5.0, 0.0]);
|
||||||
let sensor_handle = bodies.insert(sensor);
|
let sensor_handle = bodies.insert(sensor);
|
||||||
|
|
||||||
// Solid cube attached to the sensor which
|
// Solid cube attached to the sensor which
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let heightfield = HeightField::new(heights, ground_size);
|
let heightfield = HeightField::new(heights, ground_size);
|
||||||
let (vertices, indices) = heightfield.to_trimesh();
|
let (vertices, indices) = heightfield.to_trimesh();
|
||||||
|
|
||||||
let rigid_body = RigidBodyBuilder::new_static();
|
let rigid_body = RigidBodyBuilder::fixed();
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
let collider = ColliderBuilder::trimesh(vertices, indices);
|
let collider = ColliderBuilder::trimesh(vertices, indices);
|
||||||
colliders.insert_with_parent(collider, handle, &mut bodies);
|
colliders.insert_with_parent(collider, handle, &mut bodies);
|
||||||
@@ -60,7 +60,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let z = k as f32 * shift - centerz;
|
let z = k as f32 * shift - centerz;
|
||||||
|
|
||||||
// Build the rigid body.
|
// Build the rigid body.
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic().translation(vector![x, y, z]);
|
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
|
||||||
let handle = bodies.insert(rigid_body);
|
let handle = bodies.insert(rigid_body);
|
||||||
|
|
||||||
let collider = match j % 6 {
|
let collider = match j % 6 {
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ impl CCDSolver {
|
|||||||
return PredictedImpacts::ImpactsAfterEndTime(min_overstep);
|
return PredictedImpacts::ImpactsAfterEndTime(min_overstep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: all static bodies (and kinematic bodies?) should be considered as "frozen", this
|
// NOTE: all fixed bodies (and kinematic bodies?) should be considered as "frozen", this
|
||||||
// may avoid some resweeps.
|
// may avoid some resweeps.
|
||||||
let mut pseudo_intersections_to_check = vec![];
|
let mut pseudo_intersections_to_check = vec![];
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ impl IslandManager {
|
|||||||
|
|
||||||
if rb_ids.active_set_timestamp == self.active_set_timestamp || !rb_status.is_dynamic() {
|
if rb_ids.active_set_timestamp == self.active_set_timestamp || !rb_status.is_dynamic() {
|
||||||
// We already visited this body and its neighbors.
|
// We already visited this body and its neighbors.
|
||||||
// Also, we don't propagate awake state through static bodies.
|
// Also, we don't propagate awake state through fixed bodies.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ impl RigidBody {
|
|||||||
self.changes.insert(RigidBodyChanges::TYPE);
|
self.changes.insert(RigidBodyChanges::TYPE);
|
||||||
self.rb_type = status;
|
self.rb_type = status;
|
||||||
|
|
||||||
if status == RigidBodyType::Static {
|
if status == RigidBodyType::Fixed {
|
||||||
self.rb_vels = RigidBodyVelocity::zero();
|
self.rb_vels = RigidBodyVelocity::zero();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,11 +372,11 @@ impl RigidBody {
|
|||||||
self.rb_type.is_kinematic()
|
self.rb_type.is_kinematic()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this rigid body static?
|
/// Is this rigid body fixed?
|
||||||
///
|
///
|
||||||
/// A static body cannot move and is not affected by forces.
|
/// A fixed body cannot move and is not affected by forces.
|
||||||
pub fn is_static(&self) -> bool {
|
pub fn is_fixed(&self) -> bool {
|
||||||
self.rb_type == RigidBodyType::Static
|
self.rb_type == RigidBodyType::Fixed
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The mass of this rigid body.
|
/// The mass of this rigid body.
|
||||||
@@ -487,7 +487,7 @@ impl RigidBody {
|
|||||||
/// Is this rigid body sleeping?
|
/// Is this rigid body sleeping?
|
||||||
pub fn is_sleeping(&self) -> bool {
|
pub fn is_sleeping(&self) -> bool {
|
||||||
// TODO: should we:
|
// TODO: should we:
|
||||||
// - return false for static bodies.
|
// - return false for fixed bodies.
|
||||||
// - return true for non-sleeping dynamic bodies.
|
// - return true for non-sleeping dynamic bodies.
|
||||||
// - return true only for kinematic bodies with non-zero velocity?
|
// - return true only for kinematic bodies with non-zero velocity?
|
||||||
self.rb_activation.sleeping
|
self.rb_activation.sleeping
|
||||||
@@ -531,7 +531,7 @@ impl RigidBody {
|
|||||||
RigidBodyType::KinematicVelocityBased => {
|
RigidBodyType::KinematicVelocityBased => {
|
||||||
self.rb_vels.linvel = linvel;
|
self.rb_vels.linvel = linvel;
|
||||||
}
|
}
|
||||||
RigidBodyType::Static | RigidBodyType::KinematicPositionBased => {}
|
RigidBodyType::Fixed | RigidBodyType::KinematicPositionBased => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -553,7 +553,7 @@ impl RigidBody {
|
|||||||
RigidBodyType::KinematicVelocityBased => {
|
RigidBodyType::KinematicVelocityBased => {
|
||||||
self.rb_vels.angvel = angvel;
|
self.rb_vels.angvel = angvel;
|
||||||
}
|
}
|
||||||
RigidBodyType::Static | RigidBodyType::KinematicPositionBased => {}
|
RigidBodyType::Fixed | RigidBodyType::KinematicPositionBased => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -575,7 +575,7 @@ impl RigidBody {
|
|||||||
RigidBodyType::KinematicVelocityBased => {
|
RigidBodyType::KinematicVelocityBased => {
|
||||||
self.rb_vels.angvel = angvel;
|
self.rb_vels.angvel = angvel;
|
||||||
}
|
}
|
||||||
RigidBodyType::Static | RigidBodyType::KinematicPositionBased => {}
|
RigidBodyType::Fixed | RigidBodyType::KinematicPositionBased => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -905,7 +905,7 @@ pub struct RigidBodyBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RigidBodyBuilder {
|
impl RigidBodyBuilder {
|
||||||
/// Initialize a new builder for a rigid body which is either static, dynamic, or kinematic.
|
/// Initialize a new builder for a rigid body which is either fixed, dynamic, or kinematic.
|
||||||
pub fn new(rb_type: RigidBodyType) -> Self {
|
pub fn new(rb_type: RigidBodyType) -> Self {
|
||||||
Self {
|
Self {
|
||||||
position: Isometry::identity(),
|
position: Isometry::identity(),
|
||||||
@@ -925,23 +925,39 @@ impl RigidBodyBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the builder of a new static rigid body.
|
/// Initializes the builder of a new fixed rigid body.
|
||||||
|
#[deprecated(note = "use `RigidBodyBuilder::fixed()` instead")]
|
||||||
pub fn new_static() -> Self {
|
pub fn new_static() -> Self {
|
||||||
Self::new(RigidBodyType::Static)
|
Self::fixed()
|
||||||
|
}
|
||||||
|
/// Initializes the builder of a new velocity-based kinematic rigid body.
|
||||||
|
#[deprecated(note = "use `RigidBodyBuilder::kinematic_velocity_based()` instead")]
|
||||||
|
pub fn new_kinematic_velocity_based() -> Self {
|
||||||
|
Self::kinematic_velocity_based()
|
||||||
|
}
|
||||||
|
/// Initializes the builder of a new position-based kinematic rigid body.
|
||||||
|
#[deprecated(note = "use `RigidBodyBuilder::kinematic_position_based()` instead")]
|
||||||
|
pub fn new_kinematic_position_based() -> Self {
|
||||||
|
Self::kinematic_position_based()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the builder of a new kinematic rigid body.
|
/// Initializes the builder of a new fixed rigid body.
|
||||||
pub fn new_kinematic_velocity_based() -> Self {
|
pub fn fixed() -> Self {
|
||||||
|
Self::new(RigidBodyType::Fixed)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initializes the builder of a new velocity-based kinematic rigid body.
|
||||||
|
pub fn kinematic_velocity_based() -> Self {
|
||||||
Self::new(RigidBodyType::KinematicVelocityBased)
|
Self::new(RigidBodyType::KinematicVelocityBased)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the builder of a new kinematic rigid body.
|
/// Initializes the builder of a new position-based kinematic rigid body.
|
||||||
pub fn new_kinematic_position_based() -> Self {
|
pub fn kinematic_position_based() -> Self {
|
||||||
Self::new(RigidBodyType::KinematicPositionBased)
|
Self::new(RigidBodyType::KinematicPositionBased)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the builder of a new dynamic rigid body.
|
/// Initializes the builder of a new dynamic rigid body.
|
||||||
pub fn new_dynamic() -> Self {
|
pub fn dynamic() -> Self {
|
||||||
Self::new(RigidBodyType::Dynamic)
|
Self::new(RigidBodyType::Dynamic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ pub type BodyStatus = RigidBodyType;
|
|||||||
pub enum RigidBodyType {
|
pub enum RigidBodyType {
|
||||||
/// A `RigidBodyType::Dynamic` body can be affected by all external forces.
|
/// A `RigidBodyType::Dynamic` body can be affected by all external forces.
|
||||||
Dynamic = 0,
|
Dynamic = 0,
|
||||||
/// A `RigidBodyType::Static` body cannot be affected by external forces.
|
/// A `RigidBodyType::Fixed` body cannot be affected by external forces.
|
||||||
Static = 1,
|
Fixed = 1,
|
||||||
/// A `RigidBodyType::KinematicPositionBased` body cannot be affected by any external forces but can be controlled
|
/// A `RigidBodyType::KinematicPositionBased` body cannot be affected by any external forces but can be controlled
|
||||||
/// by the user at the position level while keeping realistic one-way interaction with dynamic bodies.
|
/// by the user at the position level while keeping realistic one-way interaction with dynamic bodies.
|
||||||
///
|
///
|
||||||
@@ -73,14 +73,14 @@ pub enum RigidBodyType {
|
|||||||
/// cannot be pushed by anything. In other words, the trajectory of a kinematic body can only be
|
/// cannot be pushed by anything. In other words, the trajectory of a kinematic body can only be
|
||||||
/// modified by the user and is independent from any contact or joint it is involved in.
|
/// modified by the user and is independent from any contact or joint it is involved in.
|
||||||
KinematicVelocityBased = 3,
|
KinematicVelocityBased = 3,
|
||||||
// Semikinematic, // A kinematic that performs automatic CCD with the static environment to avoid traversing it?
|
// Semikinematic, // A kinematic that performs automatic CCD with the fixed environment to avoid traversing it?
|
||||||
// Disabled,
|
// Disabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RigidBodyType {
|
impl RigidBodyType {
|
||||||
/// Is this rigid-body static (i.e. cannot move)?
|
/// Is this rigid-body fixed (i.e. cannot move)?
|
||||||
pub fn is_static(self) -> bool {
|
pub fn is_fixed(self) -> bool {
|
||||||
self == RigidBodyType::Static
|
self == RigidBodyType::Fixed
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this rigid-body dynamic (i.e. can move and be affected by forces)?
|
/// Is this rigid-body dynamic (i.e. can move and be affected by forces)?
|
||||||
|
|||||||
@@ -93,20 +93,20 @@ impl ParallelInteractionGroups {
|
|||||||
.zip(self.interaction_colors.iter_mut())
|
.zip(self.interaction_colors.iter_mut())
|
||||||
{
|
{
|
||||||
let mut body_pair = interactions[*interaction_id].body_pair();
|
let mut body_pair = interactions[*interaction_id].body_pair();
|
||||||
let is_static1 = body_pair
|
let is_fixed1 = body_pair
|
||||||
.0
|
.0
|
||||||
.map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_static())
|
.map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_fixed())
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
let is_static2 = body_pair
|
let is_fixed2 = body_pair
|
||||||
.1
|
.1
|
||||||
.map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_static())
|
.map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_fixed())
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
|
|
||||||
let representative = |handle: RigidBodyHandle| {
|
let representative = |handle: RigidBodyHandle| {
|
||||||
if let Some(link) = multibodies.rigid_body_link(handle).copied() {
|
if let Some(link) = multibodies.rigid_body_link(handle).copied() {
|
||||||
let multibody = multibodies.get_multibody(link.multibody).unwrap();
|
let multibody = multibodies.get_multibody(link.multibody).unwrap();
|
||||||
multibody
|
multibody
|
||||||
.link(1) // Use the link 1 to cover the case where the multibody root is static.
|
.link(1) // Use the link 1 to cover the case where the multibody root is fixed.
|
||||||
.or(multibody.link(0)) // TODO: Never happens?
|
.or(multibody.link(0)) // TODO: Never happens?
|
||||||
.map(|l| l.rigid_body)
|
.map(|l| l.rigid_body)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -120,7 +120,7 @@ impl ParallelInteractionGroups {
|
|||||||
body_pair.1.map(representative),
|
body_pair.1.map(representative),
|
||||||
);
|
);
|
||||||
|
|
||||||
match (is_static1, is_static2) {
|
match (is_fixed1, is_fixed2) {
|
||||||
(false, false) => {
|
(false, false) => {
|
||||||
let rb_ids1: &RigidBodyIds = bodies.index(body_pair.0.unwrap().0);
|
let rb_ids1: &RigidBodyIds = bodies.index(body_pair.0.unwrap().0);
|
||||||
let rb_ids2: &RigidBodyIds = bodies.index(body_pair.1.unwrap().0);
|
let rb_ids2: &RigidBodyIds = bodies.index(body_pair.1.unwrap().0);
|
||||||
@@ -268,10 +268,10 @@ impl InteractionGroups {
|
|||||||
let (status2, ids2): (&RigidBodyType, &RigidBodyIds) =
|
let (status2, ids2): (&RigidBodyType, &RigidBodyIds) =
|
||||||
bodies.index_bundle(interaction.body2.0);
|
bodies.index_bundle(interaction.body2.0);
|
||||||
|
|
||||||
let is_static1 = !status1.is_dynamic();
|
let is_fixed1 = !status1.is_dynamic();
|
||||||
let is_static2 = !status2.is_dynamic();
|
let is_fixed2 = !status2.is_dynamic();
|
||||||
|
|
||||||
if is_static1 && is_static2 {
|
if is_fixed1 && is_fixed2 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,13 +334,13 @@ impl InteractionGroups {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: static bodies don't transmit forces. Therefore they don't
|
// NOTE: fixed bodies don't transmit forces. Therefore they don't
|
||||||
// imply any interaction conflicts.
|
// imply any interaction conflicts.
|
||||||
if !is_static1 {
|
if !is_fixed1 {
|
||||||
self.body_masks[i1] |= target_mask_bit;
|
self.body_masks[i1] |= target_mask_bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_static2 {
|
if !is_fixed2 {
|
||||||
self.body_masks[i2] |= target_mask_bit;
|
self.body_masks[i2] |= target_mask_bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,21 +431,21 @@ impl InteractionGroups {
|
|||||||
let data: (_, &RigidBodyIds) = bodies.index_bundle(rb1.0);
|
let data: (_, &RigidBodyIds) = bodies.index_bundle(rb1.0);
|
||||||
(*data.0, data.1.active_set_offset)
|
(*data.0, data.1.active_set_offset)
|
||||||
} else {
|
} else {
|
||||||
(RigidBodyType::Static, 0)
|
(RigidBodyType::Fixed, 0)
|
||||||
};
|
};
|
||||||
let (status2, active_set_offset2) = if let Some(rb2) = interaction.data.rigid_body2
|
let (status2, active_set_offset2) = if let Some(rb2) = interaction.data.rigid_body2
|
||||||
{
|
{
|
||||||
let data: (_, &RigidBodyIds) = bodies.index_bundle(rb2.0);
|
let data: (_, &RigidBodyIds) = bodies.index_bundle(rb2.0);
|
||||||
(*data.0, data.1.active_set_offset)
|
(*data.0, data.1.active_set_offset)
|
||||||
} else {
|
} else {
|
||||||
(RigidBodyType::Static, 0)
|
(RigidBodyType::Fixed, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_static1 = !status1.is_dynamic();
|
let is_fixed1 = !status1.is_dynamic();
|
||||||
let is_static2 = !status2.is_dynamic();
|
let is_fixed2 = !status2.is_dynamic();
|
||||||
|
|
||||||
// TODO: don't generate interactions between static bodies in the first place.
|
// TODO: don't generate interactions between fixed bodies in the first place.
|
||||||
if is_static1 && is_static2 {
|
if is_fixed1 && is_fixed2 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,13 +489,13 @@ impl InteractionGroups {
|
|||||||
occupied_mask = occupied_mask | target_mask_bit;
|
occupied_mask = occupied_mask | target_mask_bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: static bodies don't transmit forces. Therefore they don't
|
// NOTE: fixed bodies don't transmit forces. Therefore they don't
|
||||||
// imply any interaction conflicts.
|
// imply any interaction conflicts.
|
||||||
if !is_static1 {
|
if !is_fixed1 {
|
||||||
self.body_masks[i1] |= target_mask_bit;
|
self.body_masks[i1] |= target_mask_bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_static2 {
|
if !is_fixed2 {
|
||||||
self.body_masks[i2] |= target_mask_bit;
|
self.body_masks[i2] |= target_mask_bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ mod test {
|
|||||||
let mut multibody_joints = MultibodyJointSet::new();
|
let mut multibody_joints = MultibodyJointSet::new();
|
||||||
let mut islands = IslandManager::new();
|
let mut islands = IslandManager::new();
|
||||||
|
|
||||||
let rb = RigidBodyBuilder::new_dynamic().build();
|
let rb = RigidBodyBuilder::dynamic().build();
|
||||||
let co = ColliderBuilder::ball(0.5).build();
|
let co = ColliderBuilder::ball(0.5).build();
|
||||||
let hrb = bodies.insert(rb);
|
let hrb = bodies.insert(rb);
|
||||||
let coh = colliders.insert_with_parent(co, hrb, &mut bodies);
|
let coh = colliders.insert_with_parent(co, hrb, &mut bodies);
|
||||||
@@ -652,7 +652,7 @@ mod test {
|
|||||||
broad_phase.update(0.0, &mut colliders, &[], &[coh], &mut events);
|
broad_phase.update(0.0, &mut colliders, &[], &[coh], &mut events);
|
||||||
|
|
||||||
// Create another body.
|
// Create another body.
|
||||||
let rb = RigidBodyBuilder::new_dynamic().build();
|
let rb = RigidBodyBuilder::dynamic().build();
|
||||||
let co = ColliderBuilder::ball(0.5).build();
|
let co = ColliderBuilder::ball(0.5).build();
|
||||||
let hrb = bodies.insert(rb);
|
let hrb = bodies.insert(rb);
|
||||||
let coh = colliders.insert_with_parent(co, hrb, &mut bodies);
|
let coh = colliders.insert_with_parent(co, hrb, &mut bodies);
|
||||||
|
|||||||
@@ -285,18 +285,18 @@ bitflags::bitflags! {
|
|||||||
/// and another collider attached to a kinematic body.
|
/// and another collider attached to a kinematic body.
|
||||||
const DYNAMIC_KINEMATIC = 0b0000_0000_0000_1100;
|
const DYNAMIC_KINEMATIC = 0b0000_0000_0000_1100;
|
||||||
/// Enable collision-detection between a collider attached to a dynamic body
|
/// Enable collision-detection between a collider attached to a dynamic body
|
||||||
/// and another collider attached to a static body (or not attached to any body).
|
/// and another collider attached to a fixed body (or not attached to any body).
|
||||||
const DYNAMIC_STATIC = 0b0000_0000_0000_0010;
|
const DYNAMIC_STATIC = 0b0000_0000_0000_0010;
|
||||||
/// Enable collision-detection between a collider attached to a kinematic body
|
/// Enable collision-detection between a collider attached to a kinematic body
|
||||||
/// and another collider attached to a kinematic body.
|
/// and another collider attached to a kinematic body.
|
||||||
const KINEMATIC_KINEMATIC = 0b1100_1100_0000_0000;
|
const KINEMATIC_KINEMATIC = 0b1100_1100_0000_0000;
|
||||||
|
|
||||||
/// Enable collision-detection between a collider attached to a kinematic body
|
/// Enable collision-detection between a collider attached to a kinematic body
|
||||||
/// and another collider attached to a static body (or not attached to any body).
|
/// and another collider attached to a fixed body (or not attached to any body).
|
||||||
const KINEMATIC_STATIC = 0b0010_0010_0000_0000;
|
const KINEMATIC_STATIC = 0b0010_0010_0000_0000;
|
||||||
|
|
||||||
/// Enable collision-detection between a collider attached to a static body (or
|
/// Enable collision-detection between a collider attached to a fixed body (or
|
||||||
/// not attached to any body) and another collider attached to a static body (or
|
/// not attached to any body) and another collider attached to a fixed body (or
|
||||||
/// not attached to any body).
|
/// not attached to any body).
|
||||||
const STATIC_STATIC = 0b0000_0000_0010_0000;
|
const STATIC_STATIC = 0b0000_0000_0010_0000;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ impl NarrowPhase {
|
|||||||
// For each modified colliders, we need to wake-up the bodies it is in contact with
|
// For each modified colliders, we need to wake-up the bodies it is in contact with
|
||||||
// so that the narrow-phase properly takes into account the change in, e.g.,
|
// so that the narrow-phase properly takes into account the change in, e.g.,
|
||||||
// collision groups. Waking up the modified collider's parent isn't enough because
|
// collision groups. Waking up the modified collider's parent isn't enough because
|
||||||
// it could be a static or kinematic body which don't propagate the wake-up state.
|
// it could be a fixed or kinematic body which don't propagate the wake-up state.
|
||||||
|
|
||||||
let co_parent: Option<&ColliderParent> = colliders.get(handle.0);
|
let co_parent: Option<&ColliderParent> = colliders.get(handle.0);
|
||||||
let (co_changes, co_type): (&ColliderChanges, &ColliderType) =
|
let (co_changes, co_type): (&ColliderChanges, &ColliderType) =
|
||||||
@@ -740,8 +740,8 @@ impl NarrowPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: avoid lookup into bodies.
|
// TODO: avoid lookup into bodies.
|
||||||
let mut rb_type1 = RigidBodyType::Static;
|
let mut rb_type1 = RigidBodyType::Fixed;
|
||||||
let mut rb_type2 = RigidBodyType::Static;
|
let mut rb_type2 = RigidBodyType::Fixed;
|
||||||
|
|
||||||
if let Some(co_parent1) = co_parent1 {
|
if let Some(co_parent1) = co_parent1 {
|
||||||
rb_type1 = *bodies.index(co_parent1.handle.0);
|
rb_type1 = *bodies.index(co_parent1.handle.0);
|
||||||
@@ -865,8 +865,8 @@ impl NarrowPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: avoid lookup into bodies.
|
// TODO: avoid lookup into bodies.
|
||||||
let mut rb_type1 = RigidBodyType::Static;
|
let mut rb_type1 = RigidBodyType::Fixed;
|
||||||
let mut rb_type2 = RigidBodyType::Static;
|
let mut rb_type2 = RigidBodyType::Fixed;
|
||||||
|
|
||||||
if let Some(co_parent1) = co_parent1 {
|
if let Some(co_parent1) = co_parent1 {
|
||||||
rb_type1 = *bodies.index(co_parent1.handle.0);
|
rb_type1 = *bodies.index(co_parent1.handle.0);
|
||||||
@@ -1076,7 +1076,7 @@ impl NarrowPhase {
|
|||||||
bodies.index_bundle(handle1.0);
|
bodies.index_bundle(handle1.0);
|
||||||
(data.0.active_island_id, *data.1, data.2.sleeping)
|
(data.0.active_island_id, *data.1, data.2.sleeping)
|
||||||
} else {
|
} else {
|
||||||
(0, RigidBodyType::Static, true)
|
(0, RigidBodyType::Fixed, true)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (active_island_id2, rb_type2, sleeping2) =
|
let (active_island_id2, rb_type2, sleeping2) =
|
||||||
@@ -1085,7 +1085,7 @@ impl NarrowPhase {
|
|||||||
bodies.index_bundle(handle2.0);
|
bodies.index_bundle(handle2.0);
|
||||||
(data.0.active_island_id, *data.1, data.2.sleeping)
|
(data.0.active_island_id, *data.1, data.2.sleeping)
|
||||||
} else {
|
} else {
|
||||||
(0, RigidBodyType::Static, true)
|
(0, RigidBodyType::Fixed, true)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (rb_type1.is_dynamic() || rb_type2.is_dynamic())
|
if (rb_type1.is_dynamic() || rb_type2.is_dynamic())
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ mod test {
|
|||||||
use crate::prelude::MultibodyJointSet;
|
use crate::prelude::MultibodyJointSet;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn kinematic_and_static_contact_crash() {
|
fn kinematic_and_fixed_contact_crash() {
|
||||||
let mut colliders = ColliderSet::new();
|
let mut colliders = ColliderSet::new();
|
||||||
let mut impulse_joints = ImpulseJointSet::new();
|
let mut impulse_joints = ImpulseJointSet::new();
|
||||||
let mut multibody_joints = MultibodyJointSet::new();
|
let mut multibody_joints = MultibodyJointSet::new();
|
||||||
@@ -698,13 +698,13 @@ mod test {
|
|||||||
let mut bodies = RigidBodySet::new();
|
let mut bodies = RigidBodySet::new();
|
||||||
let mut islands = IslandManager::new();
|
let mut islands = IslandManager::new();
|
||||||
|
|
||||||
let rb = RigidBodyBuilder::new_static().build();
|
let rb = RigidBodyBuilder::fixed().build();
|
||||||
let h1 = bodies.insert(rb.clone());
|
let h1 = bodies.insert(rb.clone());
|
||||||
let co = ColliderBuilder::ball(10.0).build();
|
let co = ColliderBuilder::ball(10.0).build();
|
||||||
colliders.insert_with_parent(co.clone(), h1, &mut bodies);
|
colliders.insert_with_parent(co.clone(), h1, &mut bodies);
|
||||||
|
|
||||||
// The same but with a kinematic body.
|
// The same but with a kinematic body.
|
||||||
let rb = RigidBodyBuilder::new_kinematic_position_based().build();
|
let rb = RigidBodyBuilder::kinematic_position_based().build();
|
||||||
let h2 = bodies.insert(rb.clone());
|
let h2 = bodies.insert(rb.clone());
|
||||||
colliders.insert_with_parent(co, h2, &mut bodies);
|
colliders.insert_with_parent(co, h2, &mut bodies);
|
||||||
|
|
||||||
@@ -737,18 +737,18 @@ mod test {
|
|||||||
let mut bodies = RigidBodySet::new();
|
let mut bodies = RigidBodySet::new();
|
||||||
|
|
||||||
// Check that removing the body right after inserting it works.
|
// Check that removing the body right after inserting it works.
|
||||||
// We add two dynamic bodies, one kinematic body and one static body before removing
|
// We add two dynamic bodies, one kinematic body and one fixed body before removing
|
||||||
// them. This include a non-regression test where deleting a kimenatic body crashes.
|
// them. This include a non-regression test where deleting a kimenatic body crashes.
|
||||||
let rb = RigidBodyBuilder::new_dynamic().build();
|
let rb = RigidBodyBuilder::dynamic().build();
|
||||||
let h1 = bodies.insert(rb.clone());
|
let h1 = bodies.insert(rb.clone());
|
||||||
let h2 = bodies.insert(rb.clone());
|
let h2 = bodies.insert(rb.clone());
|
||||||
|
|
||||||
// The same but with a kinematic body.
|
// The same but with a kinematic body.
|
||||||
let rb = RigidBodyBuilder::new_kinematic_position_based().build();
|
let rb = RigidBodyBuilder::kinematic_position_based().build();
|
||||||
let h3 = bodies.insert(rb.clone());
|
let h3 = bodies.insert(rb.clone());
|
||||||
|
|
||||||
// The same but with a static body.
|
// The same but with a fixed body.
|
||||||
let rb = RigidBodyBuilder::new_static().build();
|
let rb = RigidBodyBuilder::fixed().build();
|
||||||
let h4 = bodies.insert(rb.clone());
|
let h4 = bodies.insert(rb.clone());
|
||||||
|
|
||||||
let to_delete = [h1, h2, h3, h4];
|
let to_delete = [h1, h2, h3, h4];
|
||||||
@@ -787,7 +787,7 @@ mod test {
|
|||||||
let mut islands = IslandManager::new();
|
let mut islands = IslandManager::new();
|
||||||
|
|
||||||
let mut bodies = RigidBodySet::new();
|
let mut bodies = RigidBodySet::new();
|
||||||
let rb = RigidBodyBuilder::new_dynamic().build();
|
let rb = RigidBodyBuilder::dynamic().build();
|
||||||
let h1 = bodies.insert(rb.clone());
|
let h1 = bodies.insert(rb.clone());
|
||||||
let h2 = bodies.insert(rb.clone());
|
let h2 = bodies.insert(rb.clone());
|
||||||
let h3 = bodies.insert(rb.clone());
|
let h3 = bodies.insert(rb.clone());
|
||||||
@@ -846,7 +846,7 @@ mod test {
|
|||||||
let physics_hooks = ();
|
let physics_hooks = ();
|
||||||
let event_handler = ();
|
let event_handler = ();
|
||||||
|
|
||||||
let body = RigidBodyBuilder::new_dynamic().build();
|
let body = RigidBodyBuilder::dynamic().build();
|
||||||
let b_handle = bodies.insert(body);
|
let b_handle = bodies.insert(body);
|
||||||
let collider = ColliderBuilder::ball(1.0).build();
|
let collider = ColliderBuilder::ball(1.0).build();
|
||||||
let c_handle = colliders.insert_with_parent(collider, b_handle, &mut bodies);
|
let c_handle = colliders.insert_with_parent(collider, b_handle, &mut bodies);
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ pub(crate) fn handle_user_changes_to_rigid_bodies<Bodies, Colliders>(
|
|||||||
islands.active_kinematic_set.push(*handle);
|
islands.active_kinematic_set.push(*handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RigidBodyType::Static => {}
|
RigidBodyType::Fixed => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,11 +170,11 @@ impl GraphicsManager {
|
|||||||
&mut self,
|
&mut self,
|
||||||
materials: &mut Assets<BevyMaterial>,
|
materials: &mut Assets<BevyMaterial>,
|
||||||
handle: RigidBodyHandle,
|
handle: RigidBodyHandle,
|
||||||
is_static: bool,
|
is_fixed: bool,
|
||||||
) -> Point3<f32> {
|
) -> Point3<f32> {
|
||||||
let mut color = self.ground_color;
|
let mut color = self.ground_color;
|
||||||
|
|
||||||
if !is_static {
|
if !is_fixed {
|
||||||
match self.b2color.get(&handle).cloned() {
|
match self.b2color.get(&handle).cloned() {
|
||||||
Some(c) => color = c,
|
Some(c) => color = c,
|
||||||
None => color = Self::gen_color(&mut self.rand),
|
None => color = Self::gen_color(&mut self.rand),
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ impl PhysxWorld {
|
|||||||
|
|
||||||
rapier2dynamic.insert(rapier_handle, actor);
|
rapier2dynamic.insert(rapier_handle, actor);
|
||||||
} else {
|
} else {
|
||||||
let actor = physics.create_static(pos, ()).unwrap();
|
let actor = physics.create_fixed(pos, ()).unwrap();
|
||||||
rapier2static.insert(rapier_handle, actor);
|
rapier2static.insert(rapier_handle, actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ impl PhysxWorld {
|
|||||||
let rb_handle = link.rigid_body_handle();
|
let rb_handle = link.rigid_body_handle();
|
||||||
let rb = bodies.get(rb_handle).unwrap();
|
let rb = bodies.get(rb_handle).unwrap();
|
||||||
|
|
||||||
if is_root && rb.is_static() {
|
if is_root && rb.is_fixed() {
|
||||||
articulation.set_articulation_flag(ArticulationFlag::FixBase, true);
|
articulation.set_articulation_flag(ArticulationFlag::FixBase, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ impl PhysxWorld {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for (_, actor) in rapier2static {
|
for (_, actor) in rapier2static {
|
||||||
scene.add_static_actor(actor);
|
scene.add_fixed_actor(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (_, actor) in rapier2dynamic {
|
for (_, actor) in rapier2dynamic {
|
||||||
@@ -712,7 +712,7 @@ type PxPhysicsFoundation = PhysicsFoundation<DefaultAllocator, PxShape>;
|
|||||||
type PxMaterial = physx::material::PxMaterial<()>;
|
type PxMaterial = physx::material::PxMaterial<()>;
|
||||||
type PxShape = physx::shape::PxShape<(), PxMaterial>;
|
type PxShape = physx::shape::PxShape<(), PxMaterial>;
|
||||||
type PxArticulationLink = physx::articulation_link::PxArticulationLink<RigidBodyHandle, PxShape>;
|
type PxArticulationLink = physx::articulation_link::PxArticulationLink<RigidBodyHandle, PxShape>;
|
||||||
type PxRigidStatic = physx::rigid_static::PxRigidStatic<(), PxShape>;
|
type PxRigidStatic = physx::rigid_fixed::PxRigidStatic<(), PxShape>;
|
||||||
type PxRigidDynamic = physx::rigid_dynamic::PxRigidDynamic<RigidBodyHandle, PxShape>;
|
type PxRigidDynamic = physx::rigid_dynamic::PxRigidDynamic<RigidBodyHandle, PxShape>;
|
||||||
type PxArticulation = physx::articulation::PxArticulation<(), PxArticulationLink>;
|
type PxArticulation = physx::articulation::PxArticulation<(), PxArticulationLink>;
|
||||||
type PxArticulationReducedCoordinate =
|
type PxArticulationReducedCoordinate =
|
||||||
|
|||||||
@@ -668,7 +668,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
|||||||
.physics
|
.physics
|
||||||
.bodies
|
.bodies
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|e| !e.1.is_static())
|
.filter(|e| !e.1.is_fixed())
|
||||||
.map(|e| e.0)
|
.map(|e| e.0)
|
||||||
.collect();
|
.collect();
|
||||||
let num_to_delete = (dynamic_bodies.len() / 10).max(1);
|
let num_to_delete = (dynamic_bodies.len() / 10).max(1);
|
||||||
@@ -773,7 +773,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
|||||||
//
|
//
|
||||||
// let collider = ColliderBuilder::cuboid(4.0, 2.0, 0.4).density(20.0).build();
|
// let collider = ColliderBuilder::cuboid(4.0, 2.0, 0.4).density(20.0).build();
|
||||||
// // let collider = ColliderBuilder::ball(2.0).density(1.0).build();
|
// // let collider = ColliderBuilder::ball(2.0).density(1.0).build();
|
||||||
// let body = RigidBodyBuilder::new_dynamic()
|
// let body = RigidBodyBuilder::dynamic()
|
||||||
// .position(cam_pos)
|
// .position(cam_pos)
|
||||||
// .linvel(vel.x, vel.y, vel.z)
|
// .linvel(vel.x, vel.y, vel.z)
|
||||||
// .ccd_enabled(true)
|
// .ccd_enabled(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user