aboutsummaryrefslogtreecommitdiff
path: root/benchmarks3d
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-05-25 11:00:13 +0200
committerCrozet Sébastien <developer@crozet.re>2021-05-25 11:00:13 +0200
commit1bef66fea941307a7305ddaebdb0abe3d0cb281f (patch)
tree450bc3cd2fd611f91cb7d7809edcc4260f043b0b /benchmarks3d
parent47139323e01f978a94ed7aa2c33bbf63b00f4c30 (diff)
downloadrapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.tar.gz
rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.tar.bz2
rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.zip
Add prelude + use vectors for setting linvel/translation in builders
Diffstat (limited to 'benchmarks3d')
-rw-r--r--benchmarks3d/balls3.rs12
-rw-r--r--benchmarks3d/boxes3.rs16
-rw-r--r--benchmarks3d/capsules3.rs16
-rw-r--r--benchmarks3d/ccd3.rs16
-rw-r--r--benchmarks3d/compound3.rs24
-rw-r--r--benchmarks3d/convex_polyhedron3.rs18
-rw-r--r--benchmarks3d/heightfield3.rs19
-rw-r--r--benchmarks3d/joint_ball3.rs17
-rw-r--r--benchmarks3d/joint_fixed3.rs21
-rw-r--r--benchmarks3d/joint_prismatic3.rs31
-rw-r--r--benchmarks3d/joint_revolute3.rs37
-rw-r--r--benchmarks3d/keva3.rs38
-rw-r--r--benchmarks3d/pyramid3.rs24
-rw-r--r--benchmarks3d/stacks3.rs60
-rw-r--r--benchmarks3d/trimesh3.rs19
15 files changed, 176 insertions, 192 deletions
diff --git a/benchmarks3d/balls3.rs b/benchmarks3d/balls3.rs
index 492aeac..3f0bf36 100644
--- a/benchmarks3d/balls3.rs
+++ b/benchmarks3d/balls3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -37,10 +35,12 @@ pub fn init_world(testbed: &mut Testbed) {
let density = 0.477;
// Build the rigid body.
- let rigid_body = RigidBodyBuilder::new(status).translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new(status)
+ .translation(vector![x, y, z])
+ .build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::ball(rad).density(density).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
}
@@ -49,5 +49,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());
}
diff --git a/benchmarks3d/boxes3.rs b/benchmarks3d/boxes3.rs
index 86213af..9c7ed81 100644
--- a/benchmarks3d/boxes3.rs
+++ b/benchmarks3d/boxes3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -18,11 +16,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -45,10 +43,12 @@ pub fn init_world(testbed: &mut Testbed) {
let z = k as f32 * shift - centerz + offset;
// 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 = ColliderBuilder::cuboid(rad, rad, rad).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
@@ -59,5 +59,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());
}
diff --git a/benchmarks3d/capsules3.rs b/benchmarks3d/capsules3.rs
index edd6d57..8565503 100644
--- a/benchmarks3d/capsules3.rs
+++ b/benchmarks3d/capsules3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -18,11 +16,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -46,10 +44,12 @@ pub fn init_world(testbed: &mut Testbed) {
let z = k as f32 * shift - centerz + offset;
// 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 = ColliderBuilder::capsule_y(rad, rad).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
@@ -60,5 +60,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());
}
diff --git a/benchmarks3d/ccd3.rs b/benchmarks3d/ccd3.rs
index a496648..987aba6 100644
--- a/benchmarks3d/ccd3.rs
+++ b/benchmarks3d/ccd3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -18,11 +16,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -49,8 +47,8 @@ pub fn init_world(testbed: &mut Testbed) {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic()
- .translation(x, y, z)
- .linvel(0.0, -1000.0, 0.0)
+ .translation(vector![x, y, z])
+ .linvel(vector![0.0, -1000.0, 0.0])
.ccd_enabled(true)
.build();
let handle = bodies.insert(rigid_body);
@@ -65,7 +63,7 @@ pub fn init_world(testbed: &mut Testbed) {
_ => ColliderBuilder::capsule_y(rad, rad),
};
- colliders.insert(collider.build(), handle, &mut bodies);
+ colliders.insert_with_parent(collider.build(), handle, &mut bodies);
}
}
@@ -76,5 +74,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());
}
diff --git a/benchmarks3d/compound3.rs b/benchmarks3d/compound3.rs
index 3f82ca0..a914ce9 100644
--- a/benchmarks3d/compound3.rs
+++ b/benchmarks3d/compound3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -18,11 +16,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -45,18 +43,20 @@ pub fn init_world(testbed: &mut Testbed) {
let z = k as f32 * shift * 2.0 - centerz + offset;
// 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 collider1 = ColliderBuilder::cuboid(rad * 10.0, rad, rad).build();
let collider2 = ColliderBuilder::cuboid(rad, rad * 10.0, rad)
- .translation(rad * 10.0, rad * 10.0, 0.0)
+ .translation(vector![rad * 10.0, rad * 10.0, 0.0])
.build();
let collider3 = ColliderBuilder::cuboid(rad, rad * 10.0, rad)
- .translation(-rad * 10.0, rad * 10.0, 0.0)
+ .translation(vector![-rad * 10.0, rad * 10.0, 0.0])
.build();
- colliders.insert(collider1, handle, &mut bodies);
- colliders.insert(collider2, handle, &mut bodies);
- colliders.insert(collider3, handle, &mut bodies);
+ colliders.insert_with_parent(collider1, handle, &mut bodies);
+ colliders.insert_with_parent(collider2, handle, &mut bodies);
+ colliders.insert_with_parent(collider3, handle, &mut bodies);
}
}
@@ -67,5 +67,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());
}
diff --git a/benchmarks3d/convex_polyhedron3.rs b/benchmarks3d/convex_polyhedron3.rs
index 0e14782..7065cd5 100644
--- a/benchmarks3d/convex_polyhedron3.rs
+++ b/benchmarks3d/convex_polyhedron3.rs
@@ -1,8 +1,6 @@
-use na::Point3;
use rand::distributions::{Distribution, Standard};
use rand::{rngs::StdRng, SeedableRng};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -20,11 +18,11 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
@@ -53,17 +51,19 @@ pub fn init_world(testbed: &mut Testbed) {
let mut points = Vec::new();
for _ in 0..10 {
- let pt: Point3<f32> = distribution.sample(&mut rng);
+ let pt: Point<f32> = distribution.sample(&mut rng);
points.push(pt * scale);
}
// 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 = ColliderBuilder::round_convex_hull(&points, border_rad)
.unwrap()
.build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
@@ -74,5 +74,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());
}
diff --git a/benchmarks3d/heightfield3.rs b/benchmarks3d/heightfield3.rs
index 062e7c5..3ddc0ec 100644
--- a/benchmarks3d/heightfield3.rs
+++ b/benchmarks3d/heightfield3.rs
@@ -1,6 +1,5 @@
-use na::{ComplexField, DMatrix, Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+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(200.0, 1.0, 200.0);
+ let ground_size = vector![200.0, 1.0, 200.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,15 +54,17 @@ 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);
if j % 2 == 0 {
let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
} else {
let collider = ColliderBuilder::ball(rad).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
}
@@ -73,5 +74,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());
}
diff --git a/benchmarks3d/joint_ball3.rs b/benchmarks3d/joint_ball3.rs
index e7b3e3d..5e3eb10 100644
--- a/benchmarks3d/joint_ball3.rs
+++ b/benchmarks3d/joint_ball3.rs
@@ -1,6 +1,4 @@
-use na::Point3;
-use rapier3d::dynamics::{BallJoint, JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -29,16 +27,16 @@ pub fn init_world(testbed: &mut Testbed) {
};
let rigid_body = RigidBodyBuilder::new(status)
- .translation(fk * shift, 0.0, fi * shift)
+ .translation(vector![fk * shift, 0.0, fi * shift])
.build();
let child_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::ball(rad).build();
- colliders.insert(collider, child_handle, &mut bodies);
+ colliders.insert_with_parent(collider, child_handle, &mut bodies);
// Vertical joint.
if i > 0 {
let parent_handle = *body_handles.last().unwrap();
- let joint = BallJoint::new(Point3::origin(), Point3::new(0.0, 0.0, -shift));
+ let joint = BallJoint::new(Point::origin(), point![0.0, 0.0, -shift]);
joints.insert(&mut bodies, parent_handle, child_handle, joint);
}
@@ -46,7 +44,7 @@ pub fn init_world(testbed: &mut Testbed) {
if k > 0 {
let parent_index = body_handles.len() - num;
let parent_handle = body_handles[parent_index];
- let joint = BallJoint::new(Point3::origin(), Point3::new(-shift, 0.0, 0.0));
+ let joint = BallJoint::new(Point::origin(), point![-shift, 0.0, 0.0]);
joints.insert(&mut bodies, parent_handle, child_handle, joint);
}
@@ -58,8 +56,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(
- Point3::new(-110.0, -46.0, 170.0),
- Point3::new(54.0, -38.0, 29.0),
- );
+ testbed.look_at(point![-110.0, -46.0, 170.0], point![54.0, -38.0, 29.0]);
}
diff --git a/benchmarks3d/joint_fixed3.rs b/benchmarks3d/joint_fixed3.rs
index 0475258..5647dde 100644
--- a/benchmarks3d/joint_fixed3.rs
+++ b/benchmarks3d/joint_fixed3.rs
@@ -1,6 +1,4 @@
-use na::{Isometry3, Point3};
-use rapier3d::dynamics::{FixedJoint, JointSet, RigidBodyBuilder, RigidBodySet, RigidBodyType};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -42,18 +40,18 @@ pub fn init_world(testbed: &mut Testbed) {
};
let rigid_body = RigidBodyBuilder::new(status)
- .translation(x + fk * shift, y, z + fi * shift)
+ .translation(vector![x + fk * shift, y, z + fi * shift])
.build();
let child_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::ball(rad).build();
- colliders.insert(collider, child_handle, &mut bodies);
+ colliders.insert_with_parent(collider, child_handle, &mut bodies);
// Vertical joint.
if i > 0 {
let parent_handle = *body_handles.last().unwrap();
let joint = FixedJoint::new(
- Isometry3::identity(),
- Isometry3::translation(0.0, 0.0, -shift),
+ Isometry::identity(),
+ Isometry::translation(0.0, 0.0, -shift),
);
joints.insert(&mut bodies, parent_handle, child_handle, joint);
}
@@ -63,8 +61,8 @@ pub fn init_world(testbed: &mut Testbed) {
let parent_index = body_handles.len() - num;
let parent_handle = body_handles[parent_index];
let joint = FixedJoint::new(
- Isometry3::identity(),
- Isometry3::translation(-shift, 0.0, 0.0),
+ Isometry::identity(),
+ Isometry::translation(-shift, 0.0, 0.0),
);
joints.insert(&mut bodies, parent_handle, child_handle, joint);
}
@@ -80,8 +78,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(
- Point3::new(-38.0, 14.0, 108.0),
- Point3::new(46.0, 12.0, 23.0),
- );
+ testbed.look_at(point![-38.0, 14.0, 108.0], point![46.0, 12.0, 23.0]);
}
diff --git a/benchmarks3d/joint_prismatic3.rs b/benchmarks3d/joint_prismatic3.rs
index afc18fb..b310b14 100644
--- a/benchmarks3d/joint_prismatic3.rs
+++ b/benchmarks3d/joint_prismatic3.rs
@@ -1,6 +1,4 @@
-use na::{Point3, Unit, Vector3};
-use rapier3d::dynamics::{JointSet, PrismaticJoint, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -24,33 +22,37 @@ pub fn init_world(testbed: &mut Testbed) {
for j in 0..50 {
let x = j as f32 * shift * 4.0;
- let ground = RigidBodyBuilder::new_static().translation(x, y, z).build();
+ let ground = RigidBodyBuilder::new_static()
+ .translation(vector![x, y, z])
+ .build();
let mut curr_parent = bodies.insert(ground);
let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
- colliders.insert(collider, curr_parent, &mut bodies);
+ colliders.insert_with_parent(collider, curr_parent, &mut bodies);
for i in 0..num {
let z = z + (i + 1) as f32 * shift;
let density = 1.0;
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
+ let rigid_body = RigidBodyBuilder::new_dynamic()
+ .translation(vector![x, y, z])
+ .build();
let curr_child = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(rad, rad, rad)
.density(density)
.build();
- colliders.insert(collider, curr_child, &mut bodies);
+ colliders.insert_with_parent(collider, curr_child, &mut bodies);
let axis = if i % 2 == 0 {
- Unit::new_normalize(Vector3::new(1.0, 1.0, 0.0))
+ UnitVector::new_normalize(vector![1.0, 1.0, 0.0])
} else {
- Unit::new_normalize(Vector3::new(-1.0, 1.0, 0.0))
+ UnitVector::new_normalize(vector![-1.0, 1.0, 0.0])
};
- let z = Vector3::z();
+ let z = Vector::z();
let mut prism = PrismaticJoint::new(
- Point3::origin(),
+ Point::origin(),
axis,
z,
- Point3::new(0.0, 0.0, -shift),
+ point![0.0, 0.0, -shift],
axis,
z,
);
@@ -69,8 +71,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(
- Point3::new(262.0, 63.0, 124.0),
- Point3::new(101.0, 4.0, -3.0),
- );
+ testbed.look_at(point![262.0, 63.0, 124.0], point![101.0, 4.0, -3.0]);
}
diff --git a/benchmarks3d/joint_revolute3.rs b/benchmarks3d/joint_revolute3.rs
index 0c647a6..7c0f6cb 100644
--- a/benchmarks3d/joint_revolute3.rs
+++ b/benchmarks3d/joint_revolute3.rs
@@ -1,6 +1,4 @@
-use na::{Isometry3, Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RevoluteJoint, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -22,20 +20,20 @@ pub fn init_world(testbed: &mut Testbed) {
let x = j as f32 * shift * 4.0;
let ground = RigidBodyBuilder::new_static()
- .translation(x, y, 0.0)
+ .translation(vector![x, y, 0.0])
.build();
let mut curr_parent = bodies.insert(ground);
let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
- colliders.insert(collider, curr_parent, &mut bodies);
+ colliders.insert_with_parent(collider, curr_parent, &mut bodies);
for i in 0..num {
// Create four bodies.
let z = i as f32 * shift * 2.0 + shift;
let positions = [
- Isometry3::translation(x, y, z),
- Isometry3::translation(x + shift, y, z),
- Isometry3::translation(x + shift, y, z + shift),
- Isometry3::translation(x, y, z + shift),
+ Isometry::translation(x, y, z),
+ Isometry::translation(x + shift, y, z),
+ Isometry::translation(x + shift, y, z + shift),
+ Isometry::translation(x, y, z + shift),
];
let mut handles = [curr_parent; 4];
@@ -48,19 +46,19 @@ pub fn init_world(testbed: &mut Testbed) {
let collider = ColliderBuilder::cuboid(rad, rad, rad)
.density(density)
.build();
- colliders.insert(collider, handles[k], &mut bodies);
+ colliders.insert_with_parent(collider, handles[k], &mut bodies);
}
// Setup four joints.
- let o = Point3::origin();
- let x = Vector3::x_axis();
- let z = Vector3::z_axis();
+ let o = Point::origin();
+ let x = Vector::x_axis();
+ let z = Vector::z_axis();
let revs = [
- RevoluteJoint::new(o, z, Point3::new(0.0, 0.0, -shift), z),
- RevoluteJoint::new(o, x, Point3::new(-shift, 0.0, 0.0), x),
- RevoluteJoint::new(o, z, Point3::new(0.0, 0.0, -shift), z),
- RevoluteJoint::new(o, x, Point3::new(shift, 0.0, 0.0), x),
+ RevoluteJoint::new(o, z, point![0.0, 0.0, -shift], z),
+ RevoluteJoint::new(o, x, point![-shift, 0.0, 0.0], x),
+ RevoluteJoint::new(o, z, point![0.0, 0.0, -shift], z),
+ RevoluteJoint::new(o, x, point![shift, 0.0, 0.0], x),
];
joints.insert(&mut bodies, curr_parent, handles[0], revs[0]);
@@ -77,8 +75,5 @@ pub fn init_world(testbed: &mut Testbed) {
* Set up the testbed.
*/
testbed.set_world(bodies, colliders, joints);
- testbed.look_at(
- Point3::new(478.0, 83.0, 228.0),
- Point3::new(134.0, 83.0, -116.0),
- );
+ testbed.look_at(point![478.0, 83.0, 228.0], point![134.0, 83.0, -116.0]);
}
diff --git a/benchmarks3d/keva3.rs b/benchmarks3d/keva3.rs
index 9e6807a..38a0432 100644
--- a/benchmarks3d/keva3.rs
+++ b/benchmarks3d/keva3.rs
@@ -1,14 +1,12 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
pub fn build_block(
testbed: &mut Testbed,
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
- half_extents: Vector3<f32>,
- shift: Vector3<f32>,
+ half_extents: Vector<f32>,
+ shift: Vector<f32>,
mut numx: usize,
numy: usize,
mut numz: usize,
@@ -17,8 +15,8 @@ pub fn build_block(
let block_width = 2.0 * half_extents.z * numx as f32;
let block_height = 2.0 * half_extents.y * numy as f32;
let spacing = (half_extents.z * numx as f32 - half_extents.x) / (numz as f32 - 1.0);
- let mut color0 = Point3::new(0.7, 0.5, 0.9);
- let mut color1 = Point3::new(0.6, 1.0, 0.6);
+ let mut color0 = [0.7, 0.5, 0.9];
+ let mut color1 = [0.6, 1.0, 0.6];
for i in 0..numy {
std::mem::swap(&mut numx, &mut numz);
@@ -41,15 +39,15 @@ pub fn build_block(
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic()
- .translation(
+ .translation(vector![
x + dim.x + shift.x,
y + dim.y + shift.y,
- z + dim.z + shift.z,
- )
+ z + dim.z + shift.z
+ ])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z).build();
- colliders.insert(collider, handle, bodies);
+ colliders.insert_with_parent(collider, handle, bodies);
testbed.set_initial_body_color(handle, color0);
std::mem::swap(&mut color0, &mut color1);
@@ -64,15 +62,15 @@ pub fn build_block(
for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic()
- .translation(
+ .translation(vector![
i as f32 * dim.x * 2.0 + dim.x + shift.x,
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
+ ])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z).build();
- colliders.insert(collider, handle, bodies);
+ colliders.insert_with_parent(collider, handle, bodies);
testbed.set_initial_body_color(handle, color0);
std::mem::swap(&mut color0, &mut color1);
}
@@ -94,16 +92,16 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
+ .translation(vector![0.0, -ground_height, 0.0])
.build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, handle, &mut bodies);
+ colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
*/
- let half_extents = Vector3::new(0.02, 0.1, 0.4) / 2.0 * 10.0;
+ let half_extents = vector![0.02, 0.1, 0.4] / 2.0 * 10.0;
let mut block_height = 0.0;
// These should only be set to odd values otherwise
// the blocks won't align in the nicest way.
@@ -120,7 +118,7 @@ pub fn init_world(testbed: &mut Testbed) {
&mut bodies,
&mut colliders,
half_extents,
- Vector3::new(-block_width / 2.0, block_height, -block_width / 2.0),
+ vector![-block_width / 2.0, block_height, -block_width / 2.0],
numx,
numy,
numz,
@@ -135,5 +133,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());
}
diff --git a/benchmarks3d/pyramid3.rs b/benchmarks3d/pyramid3.rs
index 3b31eac..655ecb7 100644
--- a/benchmarks3d/pyramid3.rs
+++ b/benchmarks3d/pyramid3.rs
@@ -1,14 +1,12 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
fn create_pyramid(
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
- offset: Vector3<f32>,
+ offset: Vector<f32>,
stack_height: usize,
- half_extents: Vector3<f32>,
+ half_extents: Vector<f32>,
) {
let shift = half_extents * 2.5;
for i in 0usize..stack_height {
@@ -24,12 +22,14 @@ fn create_pyramid(
- stack_height as f32 * half_extents.z;
// 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 rigid_body_handle = bodies.insert(rigid_body);
let collider =
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_exte