diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-12-14 15:51:43 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-12-29 11:31:00 +0100 |
| commit | cc6d1b973002b4d366bc81ec6bf9e8240ad7b404 (patch) | |
| tree | 66827195ef82f22e545fc9ee4e0bade9baa8031b /src/geometry/proximity_detector | |
| parent | 9bf1321f8f1d2e116f44c2461a53f302c4ef4171 (diff) | |
| download | rapier-cc6d1b973002b4d366bc81ec6bf9e8240ad7b404.tar.gz rapier-cc6d1b973002b4d366bc81ec6bf9e8240ad7b404.tar.bz2 rapier-cc6d1b973002b4d366bc81ec6bf9e8240ad7b404.zip | |
Outsource the Shape trait, wquadtree, and shape types.
Diffstat (limited to 'src/geometry/proximity_detector')
5 files changed, 24 insertions, 24 deletions
diff --git a/src/geometry/proximity_detector/ball_ball_proximity_detector.rs b/src/geometry/proximity_detector/ball_ball_proximity_detector.rs index 2106c9f..65c141c 100644 --- a/src/geometry/proximity_detector/ball_ball_proximity_detector.rs +++ b/src/geometry/proximity_detector/ball_ball_proximity_detector.rs @@ -5,12 +5,12 @@ use crate::math::Point; #[cfg(feature = "simd-is-enabled")] use { crate::geometry::{proximity_detector::PrimitiveProximityDetectionContextSimd, WBall}, - crate::math::{SimdFloat, SIMD_WIDTH}, + crate::math::{SimdReal, SIMD_WIDTH}, simba::simd::SimdValue, }; #[cfg(feature = "simd-is-enabled")] -fn ball_distance_simd(ball1: &WBall, ball2: &WBall) -> SimdFloat { +fn ball_distance_simd(ball1: &WBall, ball2: &WBall) -> SimdReal { let dcenter = ball2.center - ball1.center; let center_dist = dcenter.magnitude(); center_dist - ball1.radius - ball2.radius @@ -22,9 +22,9 @@ pub fn detect_proximity_ball_ball_simd( ) -> [Proximity; SIMD_WIDTH] { let pos_ba = ctxt.positions2.inverse() * ctxt.positions1; let radii_a = - SimdFloat::from(array![|ii| ctxt.shapes1[ii].as_ball().unwrap().radius; SIMD_WIDTH]); + SimdReal::from(array![|ii| ctxt.shapes1[ii].as_ball().unwrap().radius; SIMD_WIDTH]); let radii_b = - SimdFloat::from(array![|ii| ctxt.shapes2[ii].as_ball().unwrap().radius; SIMD_WIDTH]); + SimdReal::from(array![|ii| ctxt.shapes2[ii].as_ball().unwrap().radius; SIMD_WIDTH]); let wball_a = WBall::new(Point::origin(), radii_a); let wball_b = WBall::new(pos_ba.inverse_transform_point(&Point::origin()), radii_b); diff --git a/src/geometry/proximity_detector/mod.rs b/src/geometry/proximity_detector/mod.rs index a99372f..fc904da 100644 --- a/src/geometry/proximity_detector/mod.rs +++ b/src/geometry/proximity_detector/mod.rs @@ -15,7 +15,7 @@ pub use self::proximity_detector::{ }; pub use self::proximity_dispatcher::{DefaultProximityDispatcher, ProximityDispatcher}; pub use self::trimesh_shape_proximity_detector::{ - detect_proximity_trimesh_shape, TrimeshShapeProximityDetectorWorkspace, + detect_proximity_trimesh_shape, TriMeshShapeProximityDetectorWorkspace, }; mod ball_ball_proximity_detector; diff --git a/src/geometry/proximity_detector/proximity_detector.rs b/src/geometry/proximity_detector/proximity_detector.rs index 7c8ad20..ea362de 100644 --- a/src/geometry/proximity_detector/proximity_detector.rs +++ b/src/geometry/proximity_detector/proximity_detector.rs @@ -3,7 +3,7 @@ use crate::geometry::{ }; use crate::math::Isometry; #[cfg(feature = "simd-is-enabled")] -use crate::math::{SimdFloat, SIMD_WIDTH}; +use crate::math::{SimdReal, SIMD_WIDTH}; use crate::pipeline::EventHandler; use std::any::Any; @@ -134,8 +134,8 @@ pub struct PrimitiveProximityDetectionContextSimd<'a, 'b> { pub colliders2: [&'a Collider; 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 positions1: &'a Isometry<SimdReal>, + pub positions2: &'a Isometry<SimdReal>, 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 768aca6..709521e 100644 --- a/src/geometry/proximity_detector/proximity_dispatcher.rs +++ b/src/geometry/proximity_detector/proximity_dispatcher.rs @@ -1,6 +1,6 @@ use crate::geometry::proximity_detector::{ PrimitiveProximityDetector, ProximityDetector, ProximityPhase, - TrimeshShapeProximityDetectorWorkspace, + TriMeshShapeProximityDetectorWorkspace, }; use crate::geometry::ShapeType; use std::any::Any; @@ -113,19 +113,19 @@ impl ProximityDispatcher for DefaultProximityDispatcher { shape2: ShapeType, ) -> (ProximityPhase, Option<Box<dyn Any + Send + Sync>>) { match (shape1, shape2) { - (ShapeType::Trimesh, _) => ( + (ShapeType::TriMesh, _) => ( ProximityPhase::NearPhase(ProximityDetector { detect_proximity: super::detect_proximity_trimesh_shape, ..ProximityDetector::default() }), - Some(Box::new(TrimeshShapeProximityDetectorWorkspace::new())), + Some(Box::new(TriMeshShapeProximityDetectorWorkspace::new())), ), - (_, ShapeType::Trimesh) => ( + (_, ShapeType::TriMesh) => ( ProximityPhase::NearPhase(ProximityDetector { detect_proximity: super::detect_proximity_trimesh_shape, ..ProximityDetector::default() }), - Some(Box::new(TrimeshShapeProximityDetectorWorkspace::new())), + Some(Box::new(TriMeshShapeProximityDetectorWorkspace::new())), ), _ => { let (gen, workspace) = self.dispatch_primitives(shape1, shape2); diff --git a/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs b/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs index 5366b39..dbb20f5 100644 --- a/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs +++ b/src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs @@ -2,15 +2,15 @@ use crate::buckler::bounding_volume::{BoundingVolume, AABB}; use crate::geometry::proximity_detector::{ PrimitiveProximityDetectionContext, ProximityDetectionContext, }; -use crate::geometry::{Collider, Proximity, ShapeType, Trimesh}; +use crate::geometry::{Collider, Proximity, ShapeType, TriMesh}; -pub struct TrimeshShapeProximityDetectorWorkspace { - interferences: Vec<usize>, +pub struct TriMeshShapeProximityDetectorWorkspace { + interferences: Vec<u32>, local_aabb2: AABB, - old_interferences: Vec<usize>, + old_interferences: Vec<u32>, } -impl TrimeshShapeProximityDetectorWorkspace { +impl TriMeshShapeProximityDetectorWorkspace { pub fn new() -> Self { Self { interferences: Vec::new(), @@ -34,18 +34,18 @@ pub fn detect_proximity_trimesh_shape(ctxt: &mut ProximityDetectionContext) -> P } fn do_detect_proximity( - trimesh1: &Trimesh, + trimesh1: &TriMesh, collider1: &Collider, collider2: &Collider, ctxt: &mut ProximityDetectionContext, ) -> Proximity { - let workspace: &mut TrimeshShapeProximityDetectorWorkspace = ctxt + let workspace: &mut TriMeshShapeProximityDetectorWorkspace = ctxt .pair .detector_workspace .as_mut() - .expect("The TrimeshShapeProximityDetectorWorkspace is missing.") + .expect("The TriMeshShapeProximityDetectorWorkspace is missing.") .downcast_mut() - .expect("Invalid workspace type, expected a TrimeshShapeProximityDetectorWorkspace."); + .expect("Invalid workspace type, expected a TriMeshShapeProximityDetectorWorkspace."); /* * Compute interferences. @@ -72,7 +72,7 @@ fn do_detect_proximity( workspace.interferences.clear(); trimesh1 - .waabbs() + .quadtree() .intersect_aabb(&local_aabb2, &mut workspace.interferences); workspace.local_aabb2 = local_aabb2; } @@ -86,7 +86,7 @@ fn do_detect_proximity( let shape_type2 = collider2.shape().shape_type(); for triangle_id in new_interferences.iter() { - if *triangle_id >= trimesh1.num_triangles() { + if *triangle_id >= trimesh1.num_triangles() as u32 { // Because of SIMD padding, the broad-phase may return tiangle indices greater // than the max. continue; |
