From 924cb7bbb9948248605eec26924e99af77dbed07 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 5 Jan 2021 16:13:02 +0100 Subject: Add compound shapes to the heightfield and trimesh demos. --- examples3d/heightfield3.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'examples3d/heightfield3.rs') diff --git a/examples3d/heightfield3.rs b/examples3d/heightfield3.rs index 6558614..bc2ac98 100644 --- a/examples3d/heightfield3.rs +++ b/examples3d/heightfield3.rs @@ -1,6 +1,6 @@ -use na::{ComplexField, DMatrix, Point3, Vector3}; +use na::{ComplexField, DMatrix, Isometry3, Point3, Vector3}; use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; -use rapier3d::geometry::{ColliderBuilder, ColliderSet}; +use rapier3d::geometry::{ColliderBuilder, ColliderSet, ColliderShape}; use rapier_testbed3d::Testbed; pub fn init_world(testbed: &mut Testbed) { @@ -58,14 +58,32 @@ pub fn init_world(testbed: &mut Testbed) { let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build(); let handle = bodies.insert(rigid_body); - let collider = match j % 5 { + let collider = match j % 6 { 0 => ColliderBuilder::cuboid(rad, rad, rad).build(), 1 => ColliderBuilder::ball(rad).build(), // Rounded cylinders are much more efficient that cylinder, even if the // rounding margin is small. 2 => ColliderBuilder::round_cylinder(rad, rad, rad / 10.0).build(), 3 => ColliderBuilder::cone(rad, rad).build(), - _ => ColliderBuilder::capsule_y(rad, rad).build(), + 4 => ColliderBuilder::capsule_y(rad, rad).build(), + _ => { + let shapes = vec![ + ( + Isometry3::identity(), + ColliderShape::cuboid(rad, rad / 2.0, rad / 2.0), + ), + ( + Isometry3::translation(rad, 0.0, 0.0), + ColliderShape::cuboid(rad / 2.0, rad, rad / 2.0), + ), + ( + Isometry3::translation(-rad, 0.0, 0.0), + ColliderShape::cuboid(rad / 2.0, rad, rad / 2.0), + ), + ]; + + ColliderBuilder::compound(shapes).build() + } }; colliders.insert(collider, handle, &mut bodies); -- cgit From aa838279a69cc287291d9079f1b82114f1339d7a Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Fri, 22 Jan 2021 16:11:10 +0100 Subject: Minor code simplification for the 3D heightfield example. --- examples3d/heightfield3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples3d/heightfield3.rs') diff --git a/examples3d/heightfield3.rs b/examples3d/heightfield3.rs index bc2ac98..7bf4061 100644 --- a/examples3d/heightfield3.rs +++ b/examples3d/heightfield3.rs @@ -27,7 +27,7 @@ pub fn init_world(testbed: &mut Testbed) { // NOTE: make sure we use the sin/cos from simba to ensure // cross-platform determinism of the example when the // enhanced_determinism feature is enabled. - ::sin(x) + ::cos(z) + ComplexField::sin(x) + ComplexField::cos(z) } }); -- cgit From 57072f3ba7664933a031d6f5e332db7c183ec39c Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Fri, 22 Jan 2021 18:10:54 +0100 Subject: Move ColliderShape out of Rapier. --- examples3d/heightfield3.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples3d/heightfield3.rs') diff --git a/examples3d/heightfield3.rs b/examples3d/heightfield3.rs index 7bf4061..f603bb1 100644 --- a/examples3d/heightfield3.rs +++ b/examples3d/heightfield3.rs @@ -1,6 +1,6 @@ use na::{ComplexField, DMatrix, Isometry3, Point3, Vector3}; use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; -use rapier3d::geometry::{ColliderBuilder, ColliderSet, ColliderShape}; +use rapier3d::geometry::{ColliderBuilder, ColliderSet, SharedShape}; use rapier_testbed3d::Testbed; pub fn init_world(testbed: &mut Testbed) { @@ -70,15 +70,15 @@ pub fn init_world(testbed: &mut Testbed) { let shapes = vec![ ( Isometry3::identity(), - ColliderShape::cuboid(rad, rad / 2.0, rad / 2.0), + SharedShape::cuboid(rad, rad / 2.0, rad / 2.0), ), ( Isometry3::translation(rad, 0.0, 0.0), - ColliderShape::cuboid(rad / 2.0, rad, rad / 2.0), + SharedShape::cuboid(rad / 2.0, rad, rad / 2.0), ), ( Isometry3::translation(-rad, 0.0, 0.0), - ColliderShape::cuboid(rad / 2.0, rad, rad / 2.0), + SharedShape::cuboid(rad / 2.0, rad, rad / 2.0), ), ]; -- cgit