aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples3d/heightfield3.rs26
-rw-r--r--examples3d/trimesh3.rs26
2 files changed, 44 insertions, 8 deletions
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);
diff --git a/examples3d/trimesh3.rs b/examples3d/trimesh3.rs
index d753988..e03ec6d 100644
--- a/examples3d/trimesh3.rs
+++ b/examples3d/trimesh3.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, HeightField};
+use rapier3d::geometry::{ColliderBuilder, ColliderSet, ColliderShape, HeightField};
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -63,14 +63,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);