aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/mass_properties_capsule.rs4
-rw-r--r--src/dynamics/mass_properties_cylinder.rs7
-rw-r--r--src/dynamics/mass_properties_polygon.rs2
-rw-r--r--src/geometry/collider.rs19
-rw-r--r--src/geometry/contact_generator/ball_convex_contact_generator.rs2
-rw-r--r--src/geometry/contact_generator/capsule_capsule_contact_generator.rs24
-rw-r--r--src/geometry/contact_generator/contact_dispatcher.rs8
-rw-r--r--src/geometry/contact_generator/contact_generator.rs8
-rw-r--r--src/geometry/contact_generator/cuboid_capsule_contact_generator.rs3
-rw-r--r--src/geometry/contact_generator/cuboid_cuboid_contact_generator.rs2
-rw-r--r--src/geometry/contact_generator/cuboid_triangle_contact_generator.rs2
-rw-r--r--src/geometry/contact_generator/heightfield_shape_contact_generator.rs6
-rw-r--r--src/geometry/contact_generator/polygon_polygon_contact_generator.rs4
-rw-r--r--src/geometry/contact_generator/trimesh_shape_contact_generator.rs2
-rw-r--r--src/geometry/polygonal_feature_map.rs2
-rw-r--r--src/geometry/polyhedron_feature3d.rs2
-rw-r--r--src/geometry/proximity_detector/ball_convex_proximity_detector.rs2
-rw-r--r--src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs2
-rw-r--r--src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs2
-rw-r--r--src/geometry/proximity_detector/polygon_polygon_proximity_detector.rs4
-rw-r--r--src/geometry/proximity_detector/proximity_detector.rs8
-rw-r--r--src/geometry/proximity_detector/proximity_dispatcher.rs2
-rw-r--r--src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs2
-rw-r--r--src/geometry/rounded.rs5
-rw-r--r--src/geometry/shape.rs25
-rw-r--r--src/geometry/trimesh.rs16
-rw-r--r--src/utils.rs1
27 files changed, 84 insertions, 82 deletions
diff --git a/src/dynamics/mass_properties_capsule.rs b/src/dynamics/mass_properties_capsule.rs
index c4e039c..cfd4345 100644
--- a/src/dynamics/mass_properties_capsule.rs
+++ b/src/dynamics/mass_properties_capsule.rs
@@ -1,7 +1,7 @@
use crate::dynamics::MassProperties;
+use crate::math::Point;
#[cfg(feature = "dim3")]
-use crate::geometry::Capsule;
-use crate::math::{Point, PrincipalAngularInertia, Rotation, Vector};
+use crate::math::Rotation;
impl MassProperties {
pub(crate) fn from_capsule(density: f32, half_height: f32, radius: f32) -> Self {
diff --git a/src/dynamics/mass_properties_cylinder.rs b/src/dynamics/mass_properties_cylinder.rs
index 66a1343..8d4f254 100644
--- a/src/dynamics/mass_properties_cylinder.rs
+++ b/src/dynamics/mass_properties_cylinder.rs
@@ -1,7 +1,10 @@
use crate::dynamics::MassProperties;
+use crate::math::{PrincipalAngularInertia, Vector};
#[cfg(feature = "dim3")]
-use crate::geometry::Capsule;
-use crate::math::{Point, PrincipalAngularInertia, Rotation, Vector};
+use {
+ crate::geometry::Capsule,
+ crate::math::{Point, Rotation},
+};
impl MassProperties {
pub(crate) fn cylinder_y_volume_unit_inertia(
diff --git a/src/dynamics/mass_properties_polygon.rs b/src/dynamics/mass_properties_polygon.rs
index c87e888..8b0b811 100644
--- a/src/dynamics/mass_properties_polygon.rs
+++ b/src/dynamics/mass_properties_polygon.rs
@@ -1,3 +1,5 @@
+#![allow(dead_code)] // TODO: remove this
+
use crate::dynamics::MassProperties;
use crate::math::Point;
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index 4b3b115..4785d62 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -1,18 +1,13 @@
use crate::dynamics::{MassProperties, RigidBodyHandle, RigidBodySet};
use crate::geometry::{
- Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, HeightField, InteractionGraph, Polygon,
- Proximity, Ray, RayIntersection, Rounded, Shape, ShapeType, Triangle, Trimesh,
+ Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, HeightField, InteractionGraph, Proximity,
+ Shape, ShapeType, Triangle, Trimesh,
};
#[cfg(feature = "dim3")]
-use crate::geometry::{Cone, Cylinder, PolygonalFeatureMap};
+use crate::geometry::{Cone, Cylinder, PolygonalFeatureMap, Rounded};
use crate::math::{AngVector, Isometry, Point, Rotation, Vector};
-use downcast_rs::{impl_downcast, DowncastSync};
-use erased_serde::Serialize;
use na::Point3;
-use ncollide::bounding_volume::{HasBoundingVolume, AABB};
-use ncollide::query::RayCast;
-use num::Zero;
-use std::any::Any;
+use ncollide::bounding_volume::AABB;
use std::ops::Deref;
use std::sync::Arc;
@@ -21,8 +16,8 @@ use std::sync::Arc;
pub struct ColliderShape(pub Arc<dyn Shape>);
impl Deref for ColliderShape {
- type Target = Shape;
- fn deref(&self) -> &Shape {
+ type Target = dyn Shape;
+ fn deref(&self) -> &dyn Shape {
&*self.0
}
}
@@ -257,7 +252,7 @@ impl Collider {
}
/// The geometric shape of this collider.
- pub fn shape(&self) -> &Shape {
+ pub fn shape(&self) -> &dyn Shape {
&*self.shape.0
}
diff --git a/src/geometry/contact_generator/ball_convex_contact_generator.rs b/src/geometry/contact_generator/ball_convex_contact_generator.rs
index 62ebfab..69bc5e3 100644
--- a/src/geometry/contact_generator/ball_convex_contact_generator.rs
+++ b/src/geometry/contact_generator/ball_convex_contact_generator.rs
@@ -1,5 +1,5 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
-use crate::geometry::{Ball, Contact, KinematicsCategory, Shape};
+use crate::geometry::{Ball, Contact, KinematicsCategory};
use crate::math::Isometry;
use na::Unit;
use ncollide::query::PointQuery;
diff --git a/src/geometry/contact_generator/capsule_capsule_contact_generator.rs b/src/geometry/contact_generator/capsule_capsule_contact_generator.rs
index 4d9bbc7..b24227a 100644
--- a/src/geometry/contact_generator/capsule_capsule_contact_generator.rs
+++ b/src/geometry/contact_generator/capsule_capsule_contact_generator.rs
@@ -1,11 +1,11 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
-use crate::geometry::{Capsule, Contact, ContactManifold, KinematicsCategory, Shape};
+use crate::geometry::{Capsule, Contact, ContactManifold, KinematicsCategory};
use crate::math::Isometry;
use crate::math::Vector;
use approx::AbsDiffEq;
use na::Unit;
#[cfg(feature = "dim2")]
-use ncollide::shape::{Segment, SegmentPointLocation};
+use ncollide::shape::SegmentPointLocation;
pub fn generate_contacts_capsule_capsule(ctxt: &mut PrimitiveContactGenerationContext) {
if let (Some(capsule1), Some(capsule2)) = (ctxt.shape1.as_capsule(), ctxt.shape2.as_capsule()) {
@@ -39,10 +39,11 @@ pub fn generate_contacts<'a>(
let pos12 = pos1.inverse() * pos2;
let pos21 = pos12.inverse();
- let capsule2_1 = capsule2.transform_by(&pos12);
+ let seg1 = capsule1.segment();
+ let seg2_1 = capsule2.segment().transformed(&pos12);
let (loc1, loc2) = ncollide::query::closest_points_segment_segment_with_locations_nD(
- (&capsule1.a, &capsule1.b),
- (&capsule2_1.a, &capsule2_1.b),
+ (&seg1.a, &seg1.b),
+ (&seg2_1.a, &seg2_1.b),
);
// We do this clone to perform contact tracking and transfer impulses.
@@ -65,8 +66,8 @@ pub fn generate_contacts<'a>(
let bcoords1 = loc1.barycentric_coordinates();
let bcoords2 = loc2.barycentric_coordinates();
- let local_p1 = capsule1.a * bcoords1[0] + capsule1.b.coords * bcoords1[1];
- let local_p2 = capsule2_1.a * bcoords2[0] + capsule2_1.b.coords * bcoords2[1];
+ let local_p1 = seg1.a * bcoords1[0] + seg1.b.coords * bcoords1[1];
+ let local_p2 = seg2_1.a * bcoords2[0] + seg2_1.b.coords * bcoords2[1];
let local_n1 =
Unit::try_new(local_p2 - local_p1, f32::default_epsilon()).unwrap_or(Vector::y_axis());
@@ -87,18 +88,15 @@ pub fn generate_contacts<'a>(
return;
}
- let seg1 = Segment::new(capsule1.a, capsule1.b);
- let seg2 = Segment::new(capsule2_1.a, capsule2_1.b);
-
- if let (Some(dir1), Some(dir2)) = (seg1.direction(), seg2.direction()) {
+ if let (Some(dir1), Some(dir2)) = (seg1.direction(), seg2_1.direction()) {
if dir1.dot(&dir2).abs() >= crate::utils::COS_FRAC_PI_8
&& dir1.dot(&local_n1).abs() < crate::utils::SIN_FRAC_PI_8
{
// Capsules axes are almost parallel and are almost perpendicular to the normal.
// Find a second contact point.
if let Some((clip_a, clip_b)) = crate::geometry::clip_segments_with_normal(
- (capsule1.a, capsule1.b),
- (capsule2_1.a, capsule2_1.b),
+ (seg1.a, seg1.b),
+ (seg2_1.a, seg2_1.b),
*local_n1,
) {
let contact =
diff --git a/src/geometry/contact_generator/contact_dispatcher.rs b/src/geometry/contact_generator/contact_dispatcher.rs
index 14b7f79..53165ee 100644
--- a/src/geometry/contact_generator/contact_dispatcher.rs
+++ b/src/geometry/contact_generator/contact_dispatcher.rs
@@ -1,9 +1,10 @@
+#[cfg(feature = "dim3")]
+use crate::geometry::contact_generator::PfmPfmContactManifoldGeneratorWorkspace;
use crate::geometry::contact_generator::{
ContactGenerator, ContactPhase, HeightFieldShapeContactGeneratorWorkspace,
- PfmPfmContactManifoldGeneratorWorkspace, PrimitiveContactGenerator,
- TrimeshShapeContactGeneratorWorkspace,
+ PrimitiveContactGenerator, TrimeshShapeContactGeneratorWorkspace,
};
-use crate::geometry::{Shape, ShapeType};
+use crate::geometry::ShapeType;
use std::any::Any;
/// Trait implemented by structures responsible for selecting a collision-detection algorithm
@@ -92,6 +93,7 @@ impl ContactDispatcher for DefaultContactDispatcher {
None,
)
}
+ #[cfg(feature = "dim3")]
(ShapeType::Cylinder, _)
| (_, ShapeType::Cylinder)
| (ShapeType::Cone, _)
diff --git a/src/geometry/contact_generator/contact_generator.rs b/src/geometry/contact_generator/contact_generator.rs
index 9dd0050..b034760 100644
--- a/src/geometry/contact_generator/contact_generator.rs
+++ b/src/geometry/contact_generator/contact_generator.rs
@@ -139,8 +139,8 @@ pub struct PrimitiveContactGenerationContext<'a> {
pub prediction_distance: f32,
pub collider1: &'a Collider,
pub collider2: &'a Collider,
- pub shape1: &'a Shape,
- pub shape2: &'a Shape,
+ pub shape1: &'a dyn Shape,
+ pub shape2: &'a dyn Shape,
pub position1: &'a Isometry<f32>,
pub position2: &'a Isometry<f32>,
pub manifold: &'a mut ContactManifold,
@@ -152,8 +152,8 @@ pub struct PrimitiveContactGenerationContextSimd<'a, 'b> {
pub prediction_distance: f32,
pub colliders1: [&'a Collider; SIMD_WIDTH],
pub colliders2: [&'a Collider; SIMD_WIDTH],
- pub shapes1: [&'a Shape; SIMD_WIDTH],
- pub shapes2: [&'a Shape; SIMD_WIDTH],
+ pub shapes1: [&'a dyn Shape; SIMD_WIDTH],
+ pub shapes2: [&'a dyn Shape; SIMD_WIDTH],
pub positions1: &'a Isometry<SimdFloat>,
pub positions2: &'a Isometry<SimdFloat>,
pub manifolds: &'a mut [&'b mut ContactManifold],
diff --git a/src/geometry/contact_generator/cuboid_capsule_contact_generator.rs b/src/geometry/contact_generator/cuboid_capsule_contact_generator.rs
index c3cf588..8650a78 100644
--- a/src/geometry/contact_generator/cuboid_capsule_contact_generator.rs
+++ b/src/geometry/contact_generator/cuboid_capsule_contact_generator.rs
@@ -1,12 +1,11 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
#[cfg(feature = "dim3")]
use crate::geometry::PolyhedronFace;
-use crate::geometry::{cuboid, sat, Capsule, ContactManifold, Cuboid, KinematicsCategory, Shape};
+use crate::geometry::{cuboid, sat, Capsule, ContactManifold, Cuboid, KinematicsCategory};
#[cfg(feature = "dim2")]
use crate::geometry::{CuboidFeature, CuboidFeatureFace};
use crate::math::Isometry;
use crate::math::Vector;
-use ncollide::shape::Segment;
pub fn generate_contacts_cuboid_capsule(ctxt: &mut PrimitiveContactGenerationContext) {
if let (Some(cube1), Some(capsule2)) = (ctxt.shape1.as_cuboid(), ctxt.shape2.as_capsule()) {
diff --git a/src/geometry/contact_generator/cuboid_cuboid_contact_generator.rs b/src/geometry/contact_generator/cuboid_cuboid_contact_generator.rs
index 596cfb1..5be5af3 100644
--- a/src/geometry/contact_generator/cuboid_cuboid_contact_generator.rs
+++ b/src/geometry/contact_generator/cuboid_cuboid_contact_generator.rs
@@ -1,5 +1,5 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
-use crate::geometry::{cuboid, sat, ContactManifold, CuboidFeature, KinematicsCategory, Shape};
+use crate::geometry::{cuboid, sat, ContactManifold, CuboidFeature, KinematicsCategory};
use crate::math::Isometry;
#[cfg(feature = "dim2")]
use crate::math::Vector;
diff --git a/src/geometry/contact_generator/cuboid_triangle_contact_generator.rs b/src/geometry/contact_generator/cuboid_triangle_contact_generator.rs
index 6744c0e..562d7d6 100644
--- a/src/geometry/contact_generator/cuboid_triangle_contact_generator.rs
+++ b/src/geometry/contact_generator/cuboid_triangle_contact_generator.rs
@@ -1,7 +1,7 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
#[cfg(feature = "dim3")]
use crate::geometry::PolyhedronFace;
-use crate::geometry::{cuboid, sat, ContactManifold, Cuboid, KinematicsCategory, Shape, Triangle};
+use crate::geometry::{cuboid, sat, ContactManifold, Cuboid, KinematicsCategory, Triangle};
use crate::math::Isometry;
#[cfg(feature = "dim2")]
use crate::{
diff --git a/src/geometry/contact_generator/heightfield_shape_contact_generator.rs b/src/geometry/contact_generator/heightfield_shape_contact_generator.rs
index f507caf..820caa3 100644
--- a/src/geometry/contact_generator/heightfield_shape_contact_generator.rs
+++ b/src/geometry/contact_generator/heightfield_shape_contact_generator.rs
@@ -3,7 +3,7 @@ use crate::geometry::contact_generator::{
};
#[cfg(feature = "dim2")]
use crate::geometry::Capsule;
-use crate::geometry::{Collider, ContactManifold, HeightField, Shape, ShapeType};
+use crate::geometry::{Collider, ContactManifold, HeightField, ShapeType};
use crate::ncollide::bounding_volume::BoundingVolume;
#[cfg(feature = "dim3")]
use crate::{geometry::Triangle, math::Point};
@@ -117,8 +117,8 @@ fn do_generate_contacts(
let position1 = *collider1.position();
#[cfg(feature = "dim2")]
let (position1, sub_shape1) = {
- let (dpos, height) = crate::utils::segment_to_capsule(&part1.a, &part1.b);
- (position1 * dpos, Capsule::new(height, 0.0));
+ let (dpos, half_height) = crate::utils::segment_to_capsule(&part1.a, &part1.b);
+ (position1 * dpos, Capsule::new(half_height, 0.0))
};
#[cfg(feature = "dim3")]
let sub_shape1 = *part1;
diff --git a/src/geometry/contact_generator/polygon_polygon_contact_generator.rs b/src/geometry/contact_generator/polygon_polygon_contact_generator.rs
index c150e83..e1e6e7e 100644
--- a/src/geometry/contact_generator/polygon_polygon_contact_generator.rs
+++ b/src/geometry/contact_generator/polygon_polygon_contact_generator.rs
@@ -1,10 +1,10 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
-use crate::geometry::{sat, Contact, ContactManifold, KinematicsCategory, Polygon, Shape};
+use crate::geometry::{sat, Contact, ContactManifold, KinematicsCategory, Polygon};
use crate::math::{Isometry, Point};
#[cfg(feature = "dim2")]
use crate::{math::Vector, utils};
-pub fn generate_contacts_polygon_polygon(ctxt: &mut PrimitiveContactGenerationContext) {
+pub fn generate_contacts_polygon_polygon(_ctxt: &mut PrimitiveContactGenerationContext) {
unimplemented!()
// if let (Shape::Polygon(polygon1), Shape::Polygon(polygon2)) = (ctxt.shape1, ctxt.shape2) {
// generate_contacts(
diff --git a/src/geometry/contact_generator/trimesh_shape_contact_generator.rs b/src/geometry/contact_generator/trimesh_shape_contact_generator.rs
index 49e9b40..502658d 100644
--- a/src/geometry/contact_generator/trimesh_shape_contact_generator.rs
+++ b/src/geometry/contact_generator/trimesh_shape_contact_generator.rs
@@ -1,7 +1,7 @@
use crate::geometry::contact_generator::{
ContactGenerationContext, PrimitiveContactGenerationContext,
};
-use crate::geometry::{Collider, ContactManifold, Shape, ShapeType, Trimesh};
+use crate::geometry::{Collider, ContactManifold, ShapeType, Trimesh};
use crate::ncollide::bounding_volume::{BoundingVolume, AABB};
pub struct TrimeshShapeContactGeneratorWorkspace {
diff --git a/src/geometry/polygonal_feature_map.rs b/src/geometry/polygonal_feature_map.rs
index fc5e066..2586826 100644
--- a/src/geometry/polygonal_feature_map.rs
+++ b/src/geometry/polygonal_feature_map.rs
@@ -2,7 +2,7 @@ use crate::geometry::PolyhedronFace;
use crate::geometry::{cuboid, Cone, Cuboid, Cylinder, Triangle};
use crate::math::{Point, Vector};
use approx::AbsDiffEq;
-use na::{Unit, Vector2, Vector3};
+use na::{Unit, Vector2};
use ncollide::shape::Segment;
use ncollide::shape::SupportMap;
diff --git a/src/geometry/polyhedron_feature3d.rs b/src/geometry/polyhedron_feature3d.rs
index 8f5de04..5a86ef2 100644
--- a/src/geometry/polyhedron_feature3d.rs
+++ b/src/geometry/polyhedron_feature3d.rs
@@ -387,8 +387,6 @@ impl PolyhedronFace {
/// Compute the barycentric coordinates of the intersection between the two given lines.
/// Returns `None` if the lines are parallel.
fn closest_points_line2d(edge1: [Point2<f32>; 2], edge2: [Point2<f32>; 2]) -> Option<(f32, f32)> {
- use approx::AbsDiffEq;
-
// Inspired by Real-time collision detection by Christer Ericson.
let dir1 = edge1[1] - edge1[0];
let dir2 = edge2[1] - edge2[0];
diff --git a/src/geometry/proximity_detector/ball_convex_proximity_detector.rs b/src/geometry/proximity_detector/ball_convex_proximity_detector.rs
index d7c5d02..eda6547 100644
--- a/src/geometry/proximity_detector/ball_convex_proximity_detector.rs
+++ b/src/geometry/proximity_detector/ball_convex_proximity_detector.rs
@@ -1,5 +1,5 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
-use crate::geometry::{Ball, Proximity, Shape};
+use crate::geometry::{Ball, Proximity};
use crate::math::Isometry;
use ncollide::query::PointQuery;
diff --git a/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs b/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs
index 2462fc9..ae885b3 100644
--- a/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs
+++ b/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs
@@ -1,5 +1,5 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
-use crate::geometry::{sat, Proximity, Shape};
+use crate::geometry::{sat, Proximity};
use crate::math::Isometry;
use ncollide::shape::Cuboid;
diff --git a/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs b/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs
index 45991c7..532ab36 100644
--- a/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs
+++ b/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs
@@ -1,5 +1,5 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
-use crate::geometry::{sat, Cuboid, Proximity, Shape, Triangle};
+use crate::geometry::{sat, Cuboid, Proximity, Triangle};
use crate::math::Isometry;
pub fn detect_proximity_cuboid_triangle(
diff --git a/src/geometry/proximity_detector/polygon_polygon_proximity_detector.rs b/src/geometry/proximity_detector/polygon_polygon_proximity_detector.rs
index 5b89dc5..30a02fa 100644
--- a/src/geometry/proximity_detector/polygon_polygon_proximity_detector.rs
+++ b/src/geometry/proximity_detector/polygon_polygon_proximity_detector.rs
@@ -1,9 +1,9 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
-use crate::geometry::{sat, Polygon, Proximity, Shape};
+use crate::geometry::{sat, Polygon, Proximity};
use crate::math::Isometry;
pub fn detect_proximity_polygon_polygon(
- ctxt: &mut PrimitiveProximityDetectionContext,
+ _ctxt: &mut PrimitiveProximityDetectionContext,
) -> Proximity {
unimplemented!()
// if let (Some(polygon1), Some(polygon2)) = (ctxt.shape1.as_polygon(), ctxt.shape2.as_polygon()) {
diff --git a/src/geometry/proximity_detector/proximity_detector.rs b/src/geometry/proximity_detector/proximity_detector.rs
index 76e8cd7..7c8ad20 100644
--- a/src/geometry/proximity_detector/proximity_detector.rs
+++ b/src/geometry/proximity_detector/proximity_detector.rs
@@ -120,8 +120,8 @@ pub struct PrimitiveProximityDetectionContext<'a> {
pub prediction_distance: f32,
pub collider1: &'a Collider,
pub collider2: &'a Collider,
- pub shape1: &'a Shape,
- pub shape2: &'a Shape,
+ pub shape1: &'a dyn Shape,
+ pub shape2: &'a dyn Shape,
pub position1: &'a Isometry<f32>,
pub position2: &'a Isometry<f32>,
pub workspace: Option<&'a mut (dyn Any + Send + Sync)>,
@@ -132,8 +132,8 @@ pub struct PrimitiveProximityDetectionContextSimd<'a, 'b> {
pub prediction_distance: f32,
pub colliders1: [&'a Collider; SIMD_WIDTH],
pub colliders2: [&'a Collider; SIMD_WIDTH],
- pub shapes1: [&'a Shape; SIMD_WIDTH],
- pub shapes2: [&'a Shape; SIMD_WIDTH],
+ pub shapes1: [&'a dyn Shape; SIMD_WIDTH],
+ pub shapes2: [&'a dyn Shape; SIMD_WIDTH],
pub positions1: &'a Isometry<SimdFloat>,
pub positions2: &'a Isometry<SimdFloat>,
pub workspaces: &'a mut [Option<&'b mut (dyn Any + Send + Sync)>],
diff --git a/src/geometry/proximity_detector/proximity_dispatcher.rs b/src/geometry/proximity_detector/proximity_dispatcher.rs
index 62f50f7..768aca6 100644
--- a/src/geometry/proximity_detector/proximity_dispatcher.rs
+++ b/src/geometry/proximity_detector/proximity_dispatcher.rs
@@ -2,7 +2,7 @@ use crate::geometry::proximity_detector::{
PrimitiveProximityDetector, ProximityDetector, ProximityPhase,
TrimeshShapeProximityDetectorWorkspace,
};
-use crate::geometry::{Shape, ShapeType};
+use crate::geometry::ShapeType;
use std::any::Any;
/// Trait implemented by structures responsible for selecting a collision-detection algorithm
diff --git a/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs b/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs
index cce46d2..b469637 100644
--- a/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs
+++ b/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs
@@ -1,7 +1,7 @@
use crate::geometry::proximity_detector::{
PrimitiveProximityDetectionContext, ProximityDetectionContext,
};
-use crate::geometry::{Collider, Proximity, Shape, ShapeType, Trimesh};
+use crate::geometry::{Collider, Proximity, ShapeType, Trimesh};
use crate::ncollide::bounding_volume::{BoundingVolume, AABB};
pub struct TrimeshShapeProximityDetectorWorkspace {
diff --git a/src/geometry/rounded.rs b/src/geometry/rounded.rs
index 59c6a72..ce3fc96 100644
--- a/src/geometry/rounded.rs
+++ b/src/geometry/rounded.rs
@@ -1,4 +1,6 @@
-use crate::geometry::{Cylinder, ShapeType};
+#[cfg(feature = "dim3")]
+use crate::geometry::Cylinder;
+use crate::geometry::ShapeType;
use crate::math::{Isometry, Point, Vector};
use na::Unit;
use ncollide::query::{
@@ -12,6 +14,7 @@ pub trait Roundable {
fn rounded_shape_type() -> ShapeType;
}
+#[cfg(feature = "dim3")]
impl Roundable for Cylinder {
fn rounded_shape_type() -> ShapeType {
ShapeType::RoundedCylinder
diff --git a/src/geometry/shape.rs b/src/geometry/shape.rs
index 822a5b0..b6350e9 100644
--- a/src/geometry/shape.rs
+++ b/src/geometry/shape.rs
@@ -1,19 +1,17 @@
-use crate::dynamics::{MassProperties, RigidBodyHandle, RigidBodySet};
-use crate::geometry::{
- Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, HeightField, InteractionGraph, Polygon,
- Proximity, Ray, RayIntersection, Roundable, Rounded, Triangle, Trimesh,
-};
-#[cfg(feature = "dim3")]
-use crate::geometry::{Cone, Cylinder, PolygonalFeatureMap};
-use crate::math::{AngVector, Isometry, Point, Rotation, Vector};
+use crate::dynamics::MassProperties;
+use crate::geometry::{Ball, Capsule, Cuboid, HeightField, Roundable, Rounded, Triangle, Trimesh};
+use crate::math::Isometry;
use downcast_rs::{impl_downcast, DowncastSync};
use erased_serde::Serialize;
-use na::Point3;
-use ncollide::bounding_volume::{BoundingVolume, HasBoundingVolume, AABB};
+use ncollide::bounding_volume::{HasBoundingVolume, AABB};
use ncollide::query::{PointQuery, RayCast};
use num::Zero;
use num_derive::FromPrimitive;
-use std::any::Any;
+#[cfg(feature = "dim3")]
+use {
+ crate::geometry::{Cone, Cylinder, PolygonalFeatureMap},
+ ncollide::bounding_volume::BoundingVolume,
+};
#[derive(Copy, Clone, Debug, FromPrimitive)]
/// Enum representing the type of a shape.
@@ -49,6 +47,7 @@ pub enum ShapeType {
// /// An heightfield with rounded corners.
// RoundedHeightField,
/// A cylinder with rounded corners.
+ #[cfg(feature = "dim3")]
RoundedCylinder,
// /// A cone with rounded corners.
// RoundedCone,
@@ -116,11 +115,13 @@ impl dyn Shape {
}
/// Converts this abstract shape to a cylinder, if it is one.
+ #[cfg(feature = "dim3")]
pub fn as_cylinder(&self) -> Option<&Cylinder> {
self.downcast_ref()
}
/// Converts this abstract shape to a cone, if it is one.
+ #[cfg(feature = "dim3")]
pub fn as_cone(&self) -> Option<&Cone> {
self.downcast_ref()
}
@@ -226,7 +227,7 @@ impl Shape for Triangle {
self.bounding_volume(position)
}
- fn mass_properties(&self, density: f32) -> MassProperties {
+ fn mass_properties(&self, _density: f32) -> MassProperties {
MassProperties::zero()
}
diff --git a/src/geometry/trimesh.rs b/src/geometry/trimesh.rs
index 38ce0a3..b4e8518 100644
--- a/src/geometry/trimesh.rs
+++ b/src/geometry/trimesh.rs
@@ -107,15 +107,15 @@ impl Trimesh {
}
impl PointQuery<f32> for Trimesh {
- fn project_point(&self, m: &Isometry<f32>, pt: &Point<f32>, solid: bool) -> PointProjection {
+ fn project_point(&self, _m: &Isometry<f32>, _pt: &Point<f32>, _solid: bool) -> PointProjection {
// TODO
unimplemented!()
}
fn project_point_with_feature(
&self,
- m: &Isometry<f32>,
- pt: &Point<f32>,
+ _m: &Isometry<f32>,
+ _pt: &Point<f32>,
) -> (PointProjection, FeatureId) {
// TODO
unimplemented!()
@@ -126,16 +126,16 @@ impl PointQuery<f32> for Trimesh {
impl RayCast<f32> for Trimesh {
fn toi_and_normal_with_ray(
&self,
- m: &Isometry<f32>,
- ray: &Ray,
- max_toi: f32,
- solid: bool,
+ _m: &Isometry<f32>,
+ _ray: &Ray,
+ _max_toi: f32,
+ _solid: bool,
) -> Option<RayIntersection> {
// TODO
None
}
- fn intersects_ray(&self, m: &Isometry<f32>, ray: &Ray, max_toi: f32) -> bool {
+ fn intersects_ray(&self, _m: &Isometry<f32>, _ray: &Ray, _max_toi: f32) -> bool {
// TODO
false
}
diff --git a/src/utils.rs b/src/utils.rs
index 48f4ef7..0bc9e17 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -20,6 +20,7 @@ use {
// pub(crate) const COS_10_DEGREES: f32 = 0.98480775301;
// pub(crate) const COS_45_DEGREES: f32 = 0.70710678118;
// pub(crate) const SIN_45_DEGREES: f32 = COS_45_DEGREES;
+#[cfg(feature = "dim3")]
pub(crate) const COS_1_DEGREES: f32 = 0.99984769515;
pub(crate) const COS_5_DEGREES: f32 = 0.99619469809;
// #[cfg(feature = "dim2")]