From d1ed279c4e70c46928c84cf9b7f4a1db539fd7cb Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Wed, 6 Jan 2021 12:22:46 +0100 Subject: Tesbted physx backend: add heightfield, trimesh, and convex mesh support. --- benchmarks3d/convex_polyhedron3.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'benchmarks3d') 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 = 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); -- cgit