aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/proximity_detector
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2020-12-08 17:31:49 +0100
committerCrozet Sébastien <developer@crozet.re>2020-12-29 11:31:00 +0100
commit9bf1321f8f1d2e116f44c2461a53f302c4ef4171 (patch)
tree8070529f4b48074fd40defb6062d6615dcdb61c5 /src/geometry/proximity_detector
parentfd3b4801b63fd56369ff37bdc2e5189db159e8ff (diff)
downloadrapier-9bf1321f8f1d2e116f44c2461a53f302c4ef4171.tar.gz
rapier-9bf1321f8f1d2e116f44c2461a53f302c4ef4171.tar.bz2
rapier-9bf1321f8f1d2e116f44c2461a53f302c4ef4171.zip
Outsource the contact manifold, SAT, and some shapes.
Diffstat (limited to 'src/geometry/proximity_detector')
-rw-r--r--src/geometry/proximity_detector/ball_convex_proximity_detector.rs11
-rw-r--r--src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs17
-rw-r--r--src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs8
-rw-r--r--src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs4
4 files changed, 18 insertions, 22 deletions
diff --git a/src/geometry/proximity_detector/ball_convex_proximity_detector.rs b/src/geometry/proximity_detector/ball_convex_proximity_detector.rs
index eda6547..5c1a105 100644
--- a/src/geometry/proximity_detector/ball_convex_proximity_detector.rs
+++ b/src/geometry/proximity_detector/ball_convex_proximity_detector.rs
@@ -1,7 +1,7 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
use crate::geometry::{Ball, Proximity};
use crate::math::Isometry;
-use ncollide::query::PointQuery;
+use buckler::query::PointQuery;
pub fn detect_proximity_ball_convex(ctxt: &mut PrimitiveProximityDetectionContext) -> Proximity {
if let Some(ball1) = ctxt.shape1.as_ball() {
@@ -13,7 +13,7 @@ pub fn detect_proximity_ball_convex(ctxt: &mut PrimitiveProximityDetectionContex
}
}
-fn do_detect_proximity<P: ?Sized + PointQuery<f32>>(
+fn do_detect_proximity<P: ?Sized + PointQuery>(
point_query1: &P,
ball2: &Ball,
ctxt: &PrimitiveProximityDetectionContext,
@@ -22,11 +22,8 @@ fn do_detect_proximity<P: ?Sized + PointQuery<f32>>(
.position1
.inverse_transform_point(&ctxt.position2.translation.vector.into());
- // TODO: add a `project_local_point` to the PointQuery trait to avoid
- // the identity isometry.
- let proj =
- point_query1.project_point(&Isometry::identity(), &local_p2_1, cfg!(feature = "dim3"));
- let dpos = local_p2_1 - proj.point;
+ let proj = point_query1.project_local_point(&local_p2_1, cfg!(feature = "dim3"));
+ let dpos = local_p2_1 - proj.local_point;
let dist = dpos.norm();
if proj.is_inside {
diff --git a/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs b/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs
index ae885b3..93a5103 100644
--- a/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs
+++ b/src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs
@@ -1,7 +1,8 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
-use crate::geometry::{sat, Proximity};
+use crate::geometry::Proximity;
use crate::math::Isometry;
-use ncollide::shape::Cuboid;
+use buckler::query::sat;
+use buckler::shape::Cuboid;
pub fn detect_proximity_cuboid_cuboid(ctxt: &mut PrimitiveProximityDetectionContext) -> Proximity {
if let (Some(cube1), Some(cube2)) = (ctxt.shape1.as_cuboid(), ctxt.shape2.as_cuboid()) {
@@ -19,9 +20,9 @@ pub fn detect_proximity_cuboid_cuboid(ctxt: &mut PrimitiveProximityDetectionCont
pub fn detect_proximity<'a>(
prediction_distance: f32,
- cube1: &'a Cuboid<f32>,
+ cube1: &'a Cuboid,
pos1: &'a Isometry<f32>,
- cube2: &'a Cuboid<f32>,
+ cube2: &'a Cuboid,
pos2: &'a Isometry<f32>,
) -> Proximity {
let pos12 = pos1.inverse() * pos2;
@@ -32,14 +33,12 @@ pub fn detect_proximity<'a>(
* Point-Face
*
*/
- let sep1 =
- sat::cuboid_cuboid_find_local_separating_normal_oneway(cube1, cube2, &pos12, &pos21).0;
+ let sep1 = sat::cuboid_cuboid_find_local_separating_normal_oneway(cube1, cube2, &pos12).0;
if sep1 > prediction_distance {
return Proximity::Disjoint;
}
- let sep2 =
- sat::cuboid_cuboid_find_local_separating_normal_oneway(cube2, cube1, &pos21, &pos12).0;
+ let sep2 = sat::cuboid_cuboid_find_local_separating_normal_oneway(cube2, cube1, &pos21).0;
if sep2 > prediction_distance {
return Proximity::Disjoint;
}
@@ -52,7 +51,7 @@ pub fn detect_proximity<'a>(
#[cfg(feature = "dim2")]
let sep3 = -f32::MAX; // This case does not exist in 2D.
#[cfg(feature = "dim3")]
- let sep3 = sat::cuboid_cuboid_find_local_separating_edge_twoway(cube1, cube2, &pos12, &pos21).0;
+ let sep3 = sat::cuboid_cuboid_find_local_separating_edge_twoway(cube1, cube2, &pos12).0;
if sep3 > prediction_distance {
return Proximity::Disjoint;
}
diff --git a/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs b/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs
index 532ab36..922855a 100644
--- a/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs
+++ b/src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs
@@ -1,6 +1,7 @@
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
-use crate::geometry::{sat, Cuboid, Proximity, Triangle};
+use crate::geometry::{Cuboid, Proximity, Triangle};
use crate::math::Isometry;
+use buckler::query::sat;
pub fn detect_proximity_cuboid_triangle(
ctxt: &mut PrimitiveProximityDetectionContext,
@@ -44,7 +45,7 @@ pub fn detect_proximity<'a>(
*
*/
let sep1 =
- sat::cube_support_map_find_local_separating_normal_oneway(cube1, triangle2, &pos12).0;
+ sat::cuboid_support_map_find_local_separating_normal_oneway(cube1, triangle2, &pos12).0;
if sep1 > prediction_distance {
return Proximity::Disjoint;
}
@@ -62,8 +63,7 @@ pub fn detect_proximity<'a>(
#[cfg(feature = "dim2")]
let sep3 = -f32::MAX; // This case does not exist in 2D.
#[cfg(feature = "dim3")]
- let sep3 =
- sat::cube_triangle_find_local_separating_edge_twoway(cube1, triangle2, &pos12, &pos21).0;
+ let sep3 = sat::cuboid_triangle_find_local_separating_edge_twoway(cube1, triangle2, &pos12).0;
if sep3 > prediction_distance {
return Proximity::Disjoint;
}
diff --git a/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs b/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs
index b469637..5366b39 100644
--- a/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs
+++ b/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs
@@ -1,12 +1,12 @@
+use crate::buckler::bounding_volume::{BoundingVolume, AABB};
use crate::geometry::proximity_detector::{
PrimitiveProximityDetectionContext, ProximityDetectionContext,
};
use crate::geometry::{Collider, Proximity, ShapeType, Trimesh};
-use crate::ncollide::bounding_volume::{BoundingVolume, AABB};
pub struct TrimeshShapeProximityDetectorWorkspace {
interferences: Vec<usize>,
- local_aabb2: AABB<f32>,
+ local_aabb2: AABB,
old_interferences: Vec<usize>,
}