aboutsummaryrefslogtreecommitdiff
path: root/examples3d/heightfield3.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2021-01-29 14:42:32 +0100
committerGitHub <noreply@github.com>2021-01-29 14:42:32 +0100
commit7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c (patch)
tree3781b9d7c92a6a8111573ba4cae1c5d41435950e /examples3d/heightfield3.rs
parente6fc8f67faf3e37afe38d683cbd930d457f289be (diff)
parent825f33efaec4ce6a8903751e836a0ea9c466ff92 (diff)
downloadrapier-7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c.tar.gz
rapier-7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c.tar.bz2
rapier-7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c.zip
Merge pull request #79 from dimforge/split_geom
Move most of the geometric code to another crate.
Diffstat (limited to 'examples3d/heightfield3.rs')
-rw-r--r--examples3d/heightfield3.rs28
1 files changed, 23 insertions, 5 deletions
diff --git a/examples3d/heightfield3.rs b/examples3d/heightfield3.rs
index 6558614..f603bb1 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, SharedShape};
use rapier_testbed3d::Testbed;
pub fn init_world(testbed: &mut Testbed) {
@@ -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.
- <f32 as ComplexField>::sin(x) + <f32 as ComplexField>::cos(z)
+ ComplexField::sin(x) + ComplexField::cos(z)
}
});
@@ -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(),
+ SharedShape::cuboid(rad, rad / 2.0, rad / 2.0),
+ ),
+ (
+ Isometry3::translation(rad, 0.0, 0.0),
+ SharedShape::cuboid(rad / 2.0, rad, rad / 2.0),
+ ),
+ (
+ Isometry3::translation(-rad, 0.0, 0.0),
+ SharedShape::cuboid(rad / 2.0, rad, rad / 2.0),
+ ),
+ ];
+
+ ColliderBuilder::compound(shapes).build()
+ }
};
colliders.insert(collider, handle, &mut bodies);