aboutsummaryrefslogtreecommitdiff
path: root/benchmarks3d
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-01-06 12:22:46 +0100
committerCrozet Sébastien <developer@crozet.re>2021-01-06 12:22:46 +0100
commitd1ed279c4e70c46928c84cf9b7f4a1db539fd7cb (patch)
treec66a24ac2ca6ca2da383ca9d4dfd983d87f76477 /benchmarks3d
parent1e9a962d34fa5143404d1dae1bfa0243e3d8a6a0 (diff)
downloadrapier-d1ed279c4e70c46928c84cf9b7f4a1db539fd7cb.tar.gz
rapier-d1ed279c4e70c46928c84cf9b7f4a1db539fd7cb.tar.bz2
rapier-d1ed279c4e70c46928c84cf9b7f4a1db539fd7cb.zip
Tesbted physx backend: add heightfield, trimesh, and convex mesh support.
Diffstat (limited to 'benchmarks3d')
-rw-r--r--benchmarks3d/convex_polyhedron3.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/benchmarks3d/convex_polyhedron3.rs b/benchmarks3d/convex_polyhedron3.rs
index 07bfb98..30d77ac 100644
--- a/benchmarks3d/convex_polyhedron3.rs
+++ b/benchmarks3d/convex_polyhedron3.rs
@@ -1,4 +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 rapier_testbed3d::Testbed;
@@ -28,14 +30,19 @@ pub fn init_world(testbed: &mut Testbed) {
* Create the cubes
*/
let num = 8;
+ let scale = 2.0;
let rad = 1.0;
+ let border_rad = 0.1;
- let shift = rad * 2.0 + rad;
+ let shift = border_rad * 2.0 + scale;
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;
+ let mut offset = -(num as f32) * shift * 0.5;
+
+ let mut rng = StdRng::seed_from_u64(0);
+ let distribution = Standard;
for j in 0usize..47 {
for i in 0..num {
@@ -44,11 +51,16 @@ pub fn init_world(testbed: &mut Testbed) {
let y = j as f32 * shift + centery + 3.0;
let z = k as f32 * shift - centerz + offset;
+ let mut points = Vec::new();
+ for _ in 0..10 {
+ let pt: Point3<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 handle = bodies.insert(rigid_body);
- let cylinder = rapier3d::cdl::shape::Cylinder::new(rad, rad).to_trimesh(4);
- let collider = ColliderBuilder::round_convex_hull(&cylinder.0, 0.1)
+ let collider = ColliderBuilder::round_convex_hull(&points, border_rad)
.unwrap()
.build();
colliders.insert(collider, handle, &mut bodies);