diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-10-26 15:12:10 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-10-26 15:12:10 +0100 |
| commit | 3da333f11c93898808eb9233c0cf333743bbf906 (patch) | |
| tree | 0ef0972450f615125c64f4cc8742d5486ce71e45 /src_testbed/nphysics_backend.rs | |
| parent | e028f4504065b228bea8b736265e8b1bfb58f7f3 (diff) | |
| download | rapier-3da333f11c93898808eb9233c0cf333743bbf906.tar.gz rapier-3da333f11c93898808eb9233c0cf333743bbf906.tar.bz2 rapier-3da333f11c93898808eb9233c0cf333743bbf906.zip | |
Fix testbed compilation with other backends.
Diffstat (limited to 'src_testbed/nphysics_backend.rs')
| -rw-r--r-- | src_testbed/nphysics_backend.rs | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src_testbed/nphysics_backend.rs b/src_testbed/nphysics_backend.rs index c2a7fb1..b449c44 100644 --- a/src_testbed/nphysics_backend.rs +++ b/src_testbed/nphysics_backend.rs @@ -177,28 +177,36 @@ fn nphysics_collider_from_rapier_collider( ) -> Option<ColliderDesc<f32>> { let margin = ColliderDesc::<f32>::default_margin(); let mut pos = *collider.position_wrt_parent(); - - let shape = match collider.shape() { - Shape::Cuboid(cuboid) => { - ShapeHandle::new(Cuboid::new(cuboid.half_extents.map(|e| e - margin))) + let shape = collider.shape(); + + let shape = if let Some(cuboid) = shape.as_cuboid() { + ShapeHandle::new(Cuboid::new(cuboid.half_extents.map(|e| e - margin))) + } else if let Some(ball) = shape.as_ball() { + ShapeHandle::new(Ball::new(ball.radius - margin)) + } else if let Some(capsule) = shape.as_capsule() { + ShapeHandle::new(Capsule::new(capsule.half_height, capsule.radius)) + } else if let Some(heightfield) = shape.as_heightfield() { + ShapeHandle::new(heightfield.clone()) + } else { + #[cfg(feature = "dim3")] + if let Some(trimesh) = shape.as_trimesh() { + ShapeHandle::new(TriMesh::new( + trimesh.vertices().to_vec(), + trimesh + .indices() + .iter() + .map(|idx| na::convert(*idx)) + .collect(), + None, + )) + } else { + return None; } - Shape::Ball(ball) => ShapeHandle::new(Ball::new(ball.radius - margin)), - Shape::Capsule(capsule) => { - pos *= capsule.transform_wrt_y(); - ShapeHandle::new(Capsule::new(capsule.half_height(), capsule.radius)) + + #[cfg(feature = "dim2")] + { + return None; } - Shape::HeightField(heightfield) => ShapeHandle::new(heightfield.clone()), - #[cfg(feature = "dim3")] - Shape::Trimesh(trimesh) => ShapeHandle::new(TriMesh::new( - trimesh.vertices().to_vec(), - trimesh - .indices() - .iter() - .map(|idx| na::convert(*idx)) - .collect(), - None, - )), - _ => return None, }; let density = if is_dynamic { collider.density() } else { 0.0 }; |
