aboutsummaryrefslogtreecommitdiff
path: root/benchmarks3d/stacks3.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2021-06-02 17:15:46 +0200
committerGitHub <noreply@github.com>2021-06-02 17:15:46 +0200
commit6ba1c9dec184adcba2c68cc1851dc05587fd0bf0 (patch)
treeb672cfc4db1d2f426dad931d77098ecb4a600358 /benchmarks3d/stacks3.rs
parent3bac79ecacdeaa18de19127b7a6c82cbfab29d14 (diff)
parentbde6657287cd32a801abb996322c520673406418 (diff)
downloadrapier-6ba1c9dec184adcba2c68cc1851dc05587fd0bf0.tar.gz
rapier-6ba1c9dec184adcba2c68cc1851dc05587fd0bf0.tar.bz2
rapier-6ba1c9dec184adcba2c68cc1851dc05587fd0bf0.zip
Merge pull request #196 from dimforge/api_changes
More API changes
Diffstat (limited to 'benchmarks3d/stacks3.rs')
-rw-r--r--benchmarks3d/stacks3.rs60
1 files changed, 31 insertions, 29 deletions
diff --git a/benchmarks3d/stacks3.rs b/benchmarks3d/stacks3.rs
index 31dff0a..39386ea 100644
--- a/benchmarks3d/stacks3.rs
+++ b/benchmarks3d/stacks3.rs
@@ -1,15 +1,13 @@
-use na::{Point3, Translation3, UnitQuaternion, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
+use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
fn create_tower_circle(
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
- offset: Vector3<f32>,
+ offset: Vector<f32>,
stack_height: usize,
nsubdivs: usize,
- half_extents: Vector3<f32>,
+ half_extents: Vector<f32>,
) {
let ang_step = std::f32::consts::PI * 2.0 / nsubdivs as f32;
let radius = 1.3 * nsubdivs as f32 * half_extents.x / std::f32::consts::PI;
@@ -20,16 +18,16 @@ fn create_tower_circle(
let fj = j as f32;
let fi = i as f32;
let y = fi * shift.y;
- let pos = Translation3::from(offset)
- * UnitQuaternion::new(Vector3::y() * (fi / 2.0 + fj) * ang_step)
- * Translation3::new(0.0, y, radius);
+ let pos = Translation::from(offset)
+ * Rotation::new(Vector::y() * (fi / 2.0 + fj) * ang_step)
+ * Translation::new(0.0, y, radius);
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic().position(pos).build();
let handle = bodies.insert(rigid_body);
let collider =
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
- colliders.insert(collider, handle, bodies);
+ colliders.insert_with_parent(collider, handle, bodies);
}
}
}
@@ -37,9 +35,9 @@ fn create_tower_circle(
fn create_wall(
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.0;
for i in 0usize..stack_height {
@@ -52,11 +50,13 @@ fn create_wall(
- 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 handle = bodies.insert(rigid_body);
let collider =
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
- colliders.insert(collider, handle, bodies);
+ colliders.insert_with_parent(collider, handle, bodies);
}
}
}
@@ -64,9 +64,9 @@ fn create_wall(
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.0;
@@ -83,11 +83,13 @@ 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 handle = bodies.insert(rigid_body);
let collider =
ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
- colliders.insert(collider, handle, bodies);
+ colliders.insert_with_parent(collider, handle, bodies);
}
}
}
@@ -108,71 +110,71 @@ 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 cube_size = 1.0;
- let hext = Vector3::repeat(cube_size);
+ let hext = Vector::repeat(cube_size);
let bottomy = cube_size * 50.0;
create_pyramid(
&mut bodies,
&mut colliders,
- Vector3::new(-110.0, bottomy, 0.0),
+ vector![-110.0, bottomy, 0.0],
12,
hext,
);
create_pyramid(
&mut bodies,
&mut colliders,
- Vector3::new(-80.0, bottomy, 0.0),
+ vector![-80.0, bottomy, 0.0],
12,
hext,
);
create_pyramid(
&mut bodies,
&mut colliders,
- Vector3::new(-50.0, bottomy, 0.0),
+ vector![-50.0, bottomy, 0.0],
12,
hext,
);
create_pyramid(
&mut bodies,
&mut colliders,
- Vector3::new(-20.0, bottomy, 0.0),
+ vector![-20.0, bottomy, 0.0],
12,
hext,
);
create_wall(
&mut bodies,
&mut colliders,
- Vector3::new(-2.0, bottomy, 0.0),
+ vector![-2.0, bottomy, 0.0],
12,
hext,
);
create_wall(
&mut bodies,
&mut colliders,
- Vector3::new(4.0, bottomy, 0.0),
+ vector![4.0, bottomy, 0.0],
12,
hext,
);
create_wall(
&mut bodies,
&mut colliders,
- Vector3::new(10.0, bottomy, 0.0),
+ vector![10.0, bottomy, 0.0],
12,
hext,
);
create_tower_circle(
&mut bodies,
&mut colliders,
- Vector3::new(25.0, bottomy, 0.0),
+ vector![25.0, bottomy, 0.0],
8,
24,
hext,
@@ -182,5 +184,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());
}