diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-05-25 11:00:13 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-05-25 11:00:13 +0200 |
| commit | 1bef66fea941307a7305ddaebdb0abe3d0cb281f (patch) | |
| tree | 450bc3cd2fd611f91cb7d7809edcc4260f043b0b /examples3d/heightfield3.rs | |
| parent | 47139323e01f978a94ed7aa2c33bbf63b00f4c30 (diff) | |
| download | rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.tar.gz rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.tar.bz2 rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.zip | |
Add prelude + use vectors for setting linvel/translation in builders
Diffstat (limited to 'examples3d/heightfield3.rs')
| -rw-r--r-- | examples3d/heightfield3.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/examples3d/heightfield3.rs b/examples3d/heightfield3.rs index 414ffdd..7f5979a 100644 --- a/examples3d/heightfield3.rs +++ b/examples3d/heightfield3.rs @@ -1,6 +1,5 @@ -use na::{ComplexField, DMatrix, Isometry3, Point3, Vector3}; -use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; -use rapier3d::geometry::{ColliderBuilder, ColliderSet, SharedShape}; +use na::ComplexField; +use rapier3d::prelude::*; use rapier_testbed3d::Testbed; pub fn init_world(testbed: &mut Testbed) { @@ -14,7 +13,7 @@ pub fn init_world(testbed: &mut Testbed) { /* * Ground */ - let ground_size = Vector3::new(100.0, 1.0, 100.0); + let ground_size = Vector::new(100.0, 1.0, 100.0); let nsubdivs = 20; let heights = DMatrix::from_fn(nsubdivs + 1, nsubdivs + 1, |i, j| { @@ -34,7 +33,7 @@ pub fn init_world(testbed: &mut Testbed) { let rigid_body = RigidBodyBuilder::new_static().build(); let handle = bodies.insert(rigid_body); let collider = ColliderBuilder::heightfield(heights, ground_size).build(); - colliders.insert(collider, handle, &mut bodies); + colliders.insert_with_parent(collider, handle, &mut bodies); /* * Create the cubes @@ -55,7 +54,9 @@ pub fn init_world(testbed: &mut Testbed) { let z = k as f32 * shift - centerz; // Build the rigid body. - let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build(); + let rigid_body = RigidBodyBuilder::new_dynamic() + .translation(vector![x, y, z]) + .build(); let handle = bodies.insert(rigid_body); let collider = match j % 6 { @@ -69,15 +70,15 @@ pub fn init_world(testbed: &mut Testbed) { _ => { let shapes = vec![ ( - Isometry3::identity(), + Isometry::identity(), SharedShape::cuboid(rad, rad / 2.0, rad / 2.0), ), ( - Isometry3::translation(rad, 0.0, 0.0), + Isometry::translation(rad, 0.0, 0.0), SharedShape::cuboid(rad / 2.0, rad, rad / 2.0), ), ( - Isometry3::translation(-rad, 0.0, 0.0), + Isometry::translation(-rad, 0.0, 0.0), SharedShape::cuboid(rad / 2.0, rad, rad / 2.0), ), ]; @@ -86,7 +87,7 @@ pub fn init_world(testbed: &mut Testbed) { } }; - colliders.insert(collider, handle, &mut bodies); + colliders.insert_with_parent(collider, handle, &mut bodies); } } } @@ -95,5 +96,5 @@ pub fn init_world(testbed: &mut Testbed) { * Set up the testbed. */ testbed.set_world(bodies, colliders, joints); - testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin()); + testbed.look_at(point![100.0, 100.0, 100.0], Point::origin()); } |
