aboutsummaryrefslogtreecommitdiff
path: root/examples3d
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2020-09-28 10:58:35 +0200
committerGitHub <noreply@github.com>2020-09-28 10:58:35 +0200
commit90dffc59ed45e5b95c2a40699cb91d285a206e0e (patch)
treefa25c9c94bf4cd18a84f1a8c2bea327cd875af5f /examples3d
parent3080c6e7d2e7bad0ac55095ccc24b1ac8bd5449a (diff)
parente7466e2f6923d24e987a34f8ebaf839346af8d4e (diff)
downloadrapier-90dffc59ed45e5b95c2a40699cb91d285a206e0e.tar.gz
rapier-90dffc59ed45e5b95c2a40699cb91d285a206e0e.tar.bz2
rapier-90dffc59ed45e5b95c2a40699cb91d285a206e0e.zip
Merge pull request #20 from dimforge/benchbot
Split benchmarks from examples
Diffstat (limited to 'examples3d')
-rw-r--r--examples3d/add_remove3.rs2
-rw-r--r--examples3d/all_examples3.rs32
-rw-r--r--examples3d/balls3.rs29
-rw-r--r--examples3d/capsules3.rs69
-rw-r--r--examples3d/compound3.rs4
-rw-r--r--examples3d/debug_boxes3.rs2
-rw-r--r--examples3d/debug_triangle3.rs2
-rw-r--r--examples3d/domino3.rs4
-rw-r--r--examples3d/heightfield3.rs8
-rw-r--r--examples3d/joints3.rs4
-rw-r--r--examples3d/keva3.rs (renamed from examples3d/stress_keva3.rs)8
-rw-r--r--examples3d/platform3.rs (renamed from examples3d/kinematic3.rs)6
-rw-r--r--examples3d/primitives3.rs (renamed from examples3d/boxes3.rs)13
-rw-r--r--examples3d/pyramid3.rs85
-rw-r--r--examples3d/sensor3.rs6
-rw-r--r--examples3d/stacks3.rs36
-rw-r--r--examples3d/stress_joint_ball3.rs70
-rw-r--r--examples3d/stress_joint_fixed3.rs92
-rw-r--r--examples3d/stress_joint_prismatic3.rs81
-rw-r--r--examples3d/stress_joint_revolute3.rs89
-rw-r--r--examples3d/trimesh3.rs8
21 files changed, 45 insertions, 605 deletions
diff --git a/examples3d/add_remove3.rs b/examples3d/add_remove3.rs
index cf565e0..17aad44 100644
--- a/examples3d/add_remove3.rs
+++ b/examples3d/add_remove3.rs
@@ -15,7 +15,7 @@ pub fn init_world(testbed: &mut Testbed) {
.translation(0.0, 10.0, 0.0)
.build();
let handle = physics.bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
physics
.colliders
.insert(collider, handle, &mut physics.bodies);
diff --git a/examples3d/all_examples3.rs b/examples3d/all_examples3.rs
index 2b89efa..8b0a2fa 100644
--- a/examples3d/all_examples3.rs
+++ b/examples3d/all_examples3.rs
@@ -11,24 +11,17 @@ use rapier_testbed3d::Testbed;
use std::cmp::Ordering;
mod add_remove3;
-mod balls3;
-mod boxes3;
-mod capsules3;
mod compound3;
mod debug_boxes3;
mod debug_triangle3;
mod domino3;
mod heightfield3;
mod joints3;
-mod kinematic3;
-mod pyramid3;
+mod keva3;
+mod platform3;
+mod primitives3;
mod sensor3;
mod stacks3;
-mod stress_joint_ball3;
-mod stress_joint_fixed3;
-mod stress_joint_prismatic3;
-mod stress_joint_revolute3;
-mod stress_keva3;
mod trimesh3;
fn demo_name_from_command_line() -> Option<String> {
@@ -69,31 +62,18 @@ pub fn main() {
let mut builders: Vec<(_, fn(&mut Testbed))> = vec![
("Add remove", add_remove3::init_world),
- ("Balls", balls3::init_world),
- ("Boxes", boxes3::init_world),
- ("Capsules", capsules3::init_world),
+ ("Primitives", primitives3::init_world),
("Compound", compound3::init_world),
("Domino", domino3::init_world),
("Heightfield", heightfield3::init_world),
("Joints", joints3::init_world),
- ("Kinematic", kinematic3::init_world),
+ ("Platform", platform3::init_world),
("Stacks", stacks3::init_world),
- ("Pyramid", pyramid3::init_world),
("Sensor", sensor3::init_world),
("Trimesh", trimesh3::init_world),
+ ("Keva tower", keva3::init_world),
("(Debug) boxes", debug_boxes3::init_world),
("(Debug) triangle", debug_triangle3::init_world),
- ("(Stress test) joint ball", stress_joint_ball3::init_world),
- ("(Stress test) joint fixed", stress_joint_fixed3::init_world),
- (
- "(Stress test) joint revolute",
- stress_joint_revolute3::init_world,
- ),
- (
- "(Stress test) joint prismatic",
- stress_joint_prismatic3::init_world,
- ),
- ("(Stress test) keva tower", stress_keva3::init_world),
];
// Lexicographic sort, with stress tests moved at the end of the list.
diff --git a/examples3d/balls3.rs b/examples3d/balls3.rs
deleted file mode 100644
index df0c21c..0000000
--- a/examples3d/balls3.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
-use rapier_testbed3d::Testbed;
-
-pub fn init_world(testbed: &mut Testbed) {
- /*
- * World
- */
- let mut bodies = RigidBodySet::new();
- let mut colliders = ColliderSet::new();
- let joints = JointSet::new();
-
- let rb = RigidBodyBuilder::new_dynamic().build();
- let co = ColliderBuilder::cuboid(0.5, 0.5, 0.5).build();
- let h = bodies.insert(rb);
- colliders.insert(co, h, &mut bodies);
-
- /*
- * Set up the testbed.
- */
- testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
-}
-
-fn main() {
- let testbed = Testbed::from_builders(0, vec![("Balls", init_world)]);
- testbed.run()
-}
diff --git a/examples3d/capsules3.rs b/examples3d/capsules3.rs
deleted file mode 100644
index e6aad40..0000000
--- a/examples3d/capsules3.rs
+++ /dev/null
@@ -1,69 +0,0 @@
-use na::Point3;
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
-use rapier_testbed3d::Testbed;
-
-pub fn init_world(testbed: &mut Testbed) {
- /*
- * World
- */
- let mut bodies = RigidBodySet::new();
- let mut colliders = ColliderSet::new();
- let joints = JointSet::new();
-
- /*
- * Ground
- */
- let ground_size = 200.1;
- let ground_height = 0.1;
-
- let rigid_body = RigidBodyBuilder::new_static()
- .translation(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);
-
- /*
- * Create the cubes
- */
- let num = 8;
- let rad = 1.0;
-
- let shift = rad * 2.0 + rad;
- let shifty = rad * 4.0;
- let centerx = shift * (num / 2) as f32;
- let centery = shift / 2.0;
- let centerz = shift * (num / 2) as f32;
-
- let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5;
-
- for j in 0usize..47 {
- for i in 0..num {
- for k in 0usize..num {
- let x = i as f32 * shift - centerx + offset;
- let y = j as f32 * shifty + centery + 3.0;
- let z = k as f32 * shift - centerz + offset;
-
- // Build the rigid body.
- let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
- let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::capsule_y(rad, rad).density(1.0).build();
- colliders.insert(collider, handle, &mut bodies);
- }
- }
-
- offset -= 0.05 * rad * (num as f32 - 1.0);
- }
-
- /*
- * Set up the testbed.
- */
- testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
-}
-
-fn main() {
- let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
- testbed.run()
-}
diff --git a/examples3d/compound3.rs b/examples3d/compound3.rs
index a8a9939..34a654d 100644
--- a/examples3d/compound3.rs
+++ b/examples3d/compound3.rs
@@ -14,7 +14,7 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Ground
*/
- let ground_size = 200.1;
+ let ground_size = 50.0;
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
@@ -37,7 +37,7 @@ pub fn init_world(testbed: &mut Testbed) {
let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5;
- for j in 0usize..25 {
+ for j in 0usize..15 {
for i in 0..num {
for k in 0usize..num {
let x = i as f32 * shift * 5.0 - centerx + offset;
diff --git a/examples3d/debug_boxes3.rs b/examples3d/debug_boxes3.rs
index bd7c344..7237fd9 100644
--- a/examples3d/debug_boxes3.rs
+++ b/examples3d/debug_boxes3.rs
@@ -31,7 +31,7 @@ pub fn init_world(testbed: &mut Testbed) {
.can_sleep(false)
.build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(2.0, 0.1, 1.0).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(2.0, 0.1, 1.0).build();
colliders.insert(collider, handle, &mut bodies);
/*
diff --git a/examples3d/debug_triangle3.rs b/examples3d/debug_triangle3.rs
index c9d7751..42bd06c 100644
--- a/examples3d/debug_triangle3.rs
+++ b/examples3d/debug_triangle3.rs
@@ -32,7 +32,7 @@ pub fn init_world(testbed: &mut Testbed) {
.can_sleep(false)
.build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(20.0, 0.1, 1.0).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(20.0, 0.1, 1.0).build();
colliders.insert(collider, handle, &mut bodies);
/*
diff --git a/examples3d/domino3.rs b/examples3d/domino3.rs
index a62ba41..66d0f41 100644
--- a/examples3d/domino3.rs
+++ b/examples3d/domino3.rs
@@ -58,9 +58,7 @@ pub fn init_world(testbed: &mut Testbed) {
* rot;
let rigid_body = RigidBodyBuilder::new_dynamic().position(position).build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(thickness, width * 2.0, width)
- .density(1.0)
- .build();
+ let collider = ColliderBuilder::cuboid(thickness, width * 2.0, width).build();
colliders.insert(collider, handle, &mut bodies);
testbed.set_body_color(handle, colors[i % 2]);
} else {
diff --git a/examples3d/heightfield3.rs b/examples3d/heightfield3.rs
index f9d4e49..09df815 100644
--- a/examples3d/heightfield3.rs
+++ b/examples3d/heightfield3.rs
@@ -14,7 +14,7 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Ground
*/
- let ground_size = Vector3::new(200.0, 1.0, 200.0);
+ let ground_size = Vector3::new(100.0, 1.0, 100.0);
let nsubdivs = 20;
let heights = DMatrix::from_fn(nsubdivs + 1, nsubdivs + 1, |i, j| {
@@ -43,7 +43,7 @@ pub fn init_world(testbed: &mut Testbed) {
let centery = shift / 2.0;
let centerz = shift * (num / 2) as f32;
- for j in 0usize..47 {
+ for j in 0usize..20 {
for i in 0..num {
for k in 0usize..num {
let x = i as f32 * shift - centerx;
@@ -55,10 +55,10 @@ pub fn init_world(testbed: &mut Testbed) {
let handle = bodies.insert(rigid_body);
if j % 2 == 0 {
- let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
colliders.insert(collider, handle, &mut bodies);
} else {
- let collider = ColliderBuilder::ball(rad).density(1.0).build();
+ let collider = ColliderBuilder::ball(rad).build();
colliders.insert(collider, handle, &mut bodies);
}
}
diff --git a/examples3d/joints3.rs b/examples3d/joints3.rs
index c640770..d4a797a 100644
--- a/examples3d/joints3.rs
+++ b/examples3d/joints3.rs
@@ -150,7 +150,7 @@ fn create_fixed_joints(
.translation(origin.x + fk * shift, origin.y, origin.z + fi * shift)
.build();
let child_handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::ball(rad).density(1.0).build();
+ let collider = ColliderBuilder::ball(rad).build();
colliders.insert(collider, child_handle, bodies);
// Vertical joint.
@@ -205,7 +205,7 @@ fn create_ball_joints(
.translation(fk * shift, 0.0, fi * shift)
.build();
let child_handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::ball(rad).density(1.0).build();
+ let collider = ColliderBuilder::ball(rad).build();
colliders.insert(collider, child_handle, bodies);
// Vertical joint.
diff --git a/examples3d/stress_keva3.rs b/examples3d/keva3.rs
index 2a41e47..6862f25 100644
--- a/examples3d/stress_keva3.rs
+++ b/examples3d/keva3.rs
@@ -48,9 +48,7 @@ pub fn build_block(
)
.build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z)
- .density(1.0)
- .build();
+ let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z).build();
colliders.insert(collider, handle, bodies);
testbed.set_body_color(handle, color0);
@@ -73,9 +71,7 @@ pub fn build_block(
)
.build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z)
- .density(1.0)
- .build();
+ let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z).build();
colliders.insert(collider, handle, bodies);
testbed.set_body_color(handle, color0);
std::mem::swap(&mut color0, &mut color1);
diff --git a/examples3d/kinematic3.rs b/examples3d/platform3.rs
index a9adc8c..3836baf 100644
--- a/examples3d/kinematic3.rs
+++ b/examples3d/platform3.rs
@@ -45,7 +45,7 @@ pub fn init_world(testbed: &mut Testbed) {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
colliders.insert(collider, handle, &mut bodies);
}
}
@@ -58,9 +58,7 @@ pub fn init_world(testbed: &mut Testbed) {
.translation(0.0, 1.5 + 0.8, -10.0 * rad)
.build();
let platform_handle = bodies.insert(platform_body);
- let collider = ColliderBuilder::cuboid(rad * 10.0, rad, rad * 10.0)
- .density(1.0)
- .build();
+ let collider = ColliderBuilder::cuboid(rad * 10.0, rad, rad * 10.0).build();
colliders.insert(collider, platform_handle, &mut bodies);
/*
diff --git a/examples3d/boxes3.rs b/examples3d/primitives3.rs
index eb8a472..cf678b9 100644
--- a/examples3d/boxes3.rs
+++ b/examples3d/primitives3.rs
@@ -14,7 +14,7 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Ground
*/
- let ground_size = 200.1;
+ let ground_size = 100.1;
let ground_height = 0.1;
let rigid_body = RigidBodyBuilder::new_static()
@@ -37,7 +37,7 @@ pub fn init_world(testbed: &mut Testbed) {
let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5;
- for j in 0usize..47 {
+ for j in 0usize..20 {
for i in 0..num {
for k in 0usize..num {
let x = i as f32 * shift - centerx + offset;
@@ -47,7 +47,14 @@ pub fn init_world(testbed: &mut Testbed) {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build();
+
+ let collider = match j % 2 {
+ 0 => ColliderBuilder::cuboid(rad, rad, rad).build(),
+ 1 => ColliderBuilder::ball(rad).build(),
+ // 2 => ColliderBuilder::capsule_y(rad, rad).build(),
+ _ => unreachable!(),
+ };
+
colliders.insert(collider, handle, &mut bodies);
}
}
diff --git a/examples3d/pyramid3.rs b/examples3d/pyramid3.rs
deleted file mode 100644
index e2aae39..0000000
--- a/examples3d/pyramid3.rs
+++ /dev/null
@@ -1,85 +0,0 @@
-use na::{Point3, Vector3};
-use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
-use rapier_testbed3d::Testbed;
-
-fn create_pyramid(
- bodies: &mut RigidBodySet,
- colliders: &mut ColliderSet,
- offset: Vector3<f32>,
- stack_height: usize,
- half_extents: Vector3<f32>,
-) {
- let shift = half_extents * 2.5;
- for i in 0usize..stack_height {
- for j in i..stack_height {
- for k in i..stack_height {
- let fi = i as f32;
- let fj = j as f32;
- let fk = k as f32;
- let x = (fi * shift.x / 2.0) + (fk - fi) * shift.x + offset.x
- - stack_height as f32 * half_extents.x;
- let y = fi * shift.y + offset.y;
- let z = (fi * shift.z / 2.0) + (fj - fi) * shift.z + offset.z
- - 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_handle = bodies.insert(rigid_body);
-
- let collider =
- ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z)
- .density(1.0)
- .build();
- colliders.insert(collider, rigid_body_handle, bodies);
- }
- }
- }
-}
-
-pub fn init_world(testbed: &mut Testbed) {
- /*
- * World
- */
- let mut bodies = RigidBodySet::new();
- let mut colliders = ColliderSet::new();
- let joints = JointSet::new();
-
- /*
- * Ground
- */
- let ground_size = 50.0;
- let ground_height = 0.1;
-
- let rigid_body = RigidBodyBuilder::new_static()
- .translation(0.0, -ground_height, 0.0)
- .build();
- let ground_handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size).build();
- colliders.insert(collider, ground_handle, &mut bodies);
-
- /*
- * Create the cubes
- */
- let cube_size = 1.0;
- let hext = Vector3::repeat(cube_size);
- let bottomy = cube_size;
- create_pyramid(
- &mut bodies,
- &mut colliders,
- Vector3::new(0.0, bottomy, 0.0),
- 24,
- hext,
- );
-
- /*
- * Set up the testbed.
- */
- testbed.set_world(bodies, colliders, joints);
- testbed.look_at(Point3::new(100.0, 100.0, 100.0), Point3::origin());
-}
-
-fn main() {
- let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
- testbed.run()
-}
diff --git a/examples3d/sensor3.rs b/examples3d/sensor3.rs
index 598b0ad..7b218fe 100644
--- a/examples3d/sensor3.rs
+++ b/examples3d/sensor3.rs
@@ -43,7 +43,7 @@ pub fn init_world(testbed: &mut Testbed) {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
colliders.insert(collider, handle, &mut bodies);
testbed.set_body_color(handle, Point3::new(0.5, 0.5, 1.0));
@@ -56,13 +56,13 @@ pub fn init_world(testbed: &mut Testbed) {
// Rigid body so that the sensor can move.
let sensor = RigidBodyBuilder::new_dynamic()
- .translation(0.0, 10.0, 0.0)
+ .translation(0.0, 5.0, 0.0)
.build();
let sensor_handle = bodies.insert(sensor);
// Solid cube attached to the sensor which
// other colliders can touch.
- let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build();
+ let collider = ColliderBuilder::cuboid(rad, rad, rad).build();
colliders.insert(collider, sensor_handle, &mut bodies);
// We create a collider desc without density because we don't
diff --git a/examples3d/stacks3.rs b/examples3d/stacks3.rs
index fd2ae27..55d58bb 100644
--- a/examples3d/stacks3.rs
+++ b/examples3d/stacks3.rs
@@ -27,9 +27,8 @@ fn create_tower_circle(
// 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)
- .density(1.0)
- .build();
+ let collider =
+ ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
colliders.insert(collider, handle, bodies);
}
}
@@ -55,9 +54,8 @@ fn create_wall(
// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z)
- .density(1.0)
- .build();
+ let collider =
+ ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
colliders.insert(collider, handle, bodies);
}
}
@@ -88,9 +86,7 @@ fn create_pyramid(
let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build();
let handle = bodies.insert(rigid_body);
let collider =
- ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z)
- .density(1.0)
- .build();
+ ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z).build();
colliders.insert(collider, handle, bodies);
}
}
@@ -124,27 +120,7 @@ pub fn init_world(testbed: &mut Testbed) {
let cube_size = 1.0;
let hext = Vector3::repeat(cube_size);
let bottomy = cube_size * 50.0;
- create_pyramid(
- &mut bodies,
- &mut colliders,
- Vector3::new(-110.0, bottomy, 0.0),
- 12,
- hext,
- );
- create_pyramid(
- &mut bodies,
- &mut colliders,
- Vector3::new(-80.0, bottomy, 0.0),
- 12,
- hext,
- );
- create_pyramid(
- &mut bodies,
- &mut colliders,
- Vector3::new(-50.0, bottomy, 0.0),
- 12,
- hext,
- );
+
create_pyramid(
&mut bodies,
&mut colliders,
diff --git a/examples3d/stress_joint_ball3.rs b/examples3d/stress_joint_ball3.rs
deleted file mode 100644
index bbff217..0000000
--- a/examples3d/stress_joint_ball3.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-use na::Point3;
-use rapier3d::dynamics::{BallJoint, BodyStatus, JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
-use rapier_testbed3d::Testbed;
-
-pub fn init_world(testbed: &mut Testbed) {
- /*
- * World
- */
- let mut bodies = RigidBodySet::new();
- let mut colliders = ColliderSet::new();
- let mut joints = JointSet::new();
-
- let rad = 0.4;
- let num = 100;
- let shift = 1.0;
-
- let mut body_handles = Vec::new();
-
- for k in 0..num {
- for i in 0..num {
- let fk = k as f32;
- let fi = i as f32;
-
- let status = if i == 0 && (k % 4 == 0 || k == num - 1) {
- BodyStatus::Static
- } else {
- BodyStatus::Dynamic
- };
-
- let rigid_body = RigidBodyBuilder::new(status)
- .translation(fk * shift, 0.0, fi * shift)
- .build();
- let child_handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::ball(rad).density(1.0).build();
- colliders.insert(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));
- joints.insert(&mut bodies, parent_handle, child_handle, joint);
- }
-
- // Horizontal joint.
- 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));
- joints.insert(&mut bodies, parent_handle, child_handle, joint);
- }
-
- body_handles.push(child_handle);
- }
- }
-
- /*
- * 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),
- );
-}
-
-fn main() {
- let testbed = Testbed::from_builders(0, vec![("Joints", init_world)]);
- testbed.run()
-}
diff --git a/examples3d/stress_joint_fixed3.rs b/examples3d/stress_joint_fixed3.rs
deleted file mode 100644
index b85879d..0000000
--- a/examples3d/stress_joint_fixed3.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-use na::{Isometry3, Point3};
-use rapier3d::dynamics::{BodyStatus, FixedJoint, JointSet, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
-use rapier_testbed3d::Testbed;
-
-pub fn init_world(testbed: &mut Testbed) {
- /*
- * World
- */
- let mut bodies = RigidBodySet::new();
- let mut colliders = ColliderSet::new();
- let mut joints = JointSet::new();
-
- let rad = 0.4;
- let num = 5;
- let shift = 1.0;
-
- let mut body_handles = Vec::new();
-
- for m in 0..10 {
- let z = m as f32 * shift * (num as f32 + 2.0);
-
- for l in 0..10 {
- let y = l as f32 * shift * 3.0;
-
- for j in 0..5 {
- let x = j as f32 * shift * (num as f32) * 2.0;
-
- for k in 0..num {
- for i in 0..num {
- let fk = k as f32;
- let fi = i as f32;
-
- // NOTE: the num - 2 test is to avoid two consecutive
- // fixed bodies. Because physx will crash if we add
- // a joint between these.
-
- let status = if i == 0 && (k % 4 == 0 && k != num - 2 || k == num - 1) {
- BodyStatus::Static
- } else {
- BodyStatus::Dynamic
- };
-
- let rigid_body = RigidBodyBuilder::new(status)
- .translation(x + fk * shift, y, z + fi * shift)
- .build();
- let child_handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::ball(rad).density(1.0).build();
- colliders.insert(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),
- );
- joints.insert(&mut bodies, parent_handle, child_handle, joint);
- }
-
- // Horizontal joint.
- if k > 0 {
- 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),
- );
- joints.insert(&mut bodies, parent_handle, child_handle, joint);
- }
-
- body_handles.push(child_handle);
- }
- }
- }
- }
- }
-
- /*
- * 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),
- );
-}
-
-fn main() {
- let testbed = Testbed::from_builders(0, vec![("Joints", init_world)]);
- testbed.run()
-}
diff --git a/examples3d/stress_joint_prismatic3.rs b/examples3d/stress_joint_prismatic3.rs
deleted file mode 100644
index 3267ada..0000000
--- a/examples3d/stress_joint_prismatic3.rs
+++ /dev/null
@@ -1,81 +0,0 @@
-use na::{Point3, Unit, Vector3};
-use rapier3d::dynamics::{JointSet, PrismaticJoint, RigidBodyBuilder, RigidBodySet};
-use rapier3d::geometry::{ColliderBuilder, ColliderSet};
-use rapier_testbed3d::Testbed;
-
-pub fn init_world(testbed: &mut Testbed) {
- /*
- * World
- */
- let mut bodies = RigidBodySet::new();
- let mut colliders = ColliderSet::new();
- let mut joints = JointSet::new();
-
- let rad = 0.4;
- let num = 5;
- let shift = 1.0;
-
- for m in 0..8 {
- let z = m as f32 * shift * (num as f32 + 2.0);
-
- for l in 0..8 {
- let y = l as f32 * shift * (num as f32) * 2.0;
-
- for j in 0..50 {
- let x = j as f32 * shift * 4.0;
-
- let ground = RigidBodyBuilder::new_static().translation(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);
-
- for i in 0..num {
- let z = z + (i + 1) as f32 * shift;
- let density = 1.0;
- let rigid_body = RigidBodyBuilder::new_dyna