use std::marker::PhantomData; use alga::linear::Translation; use math::{Isometry, Point}; use geometry::shape::{Ball, Shape}; use geometry::query::Proximity; use geometry::query::proximity_internal; use narrow_phase::{ProximityDetector, ProximityDispatcher}; /// Proximity detector between two balls. pub struct BallBallProximityDetector { proximity: Proximity, pt_type: PhantomData

, // FIXME: can we avoid this? mat_type: PhantomData, // FIXME: can we avoid this? } impl Clone for BallBallProximityDetector { fn clone(&self) -> BallBallProximityDetector { BallBallProximityDetector { proximity: self.proximity, pt_type: PhantomData, mat_type: PhantomData, } } } impl BallBallProximityDetector { /// Creates a new persistent collision detector between two balls. #[inline] pub fn new() -> BallBallProximityDetector { BallBallProximityDetector { proximity: Proximity::Disjoint, pt_type: PhantomData, mat_type: PhantomData, } } } impl> ProximityDetector for BallBallProximityDetector { fn update( &mut self, _: &ProximityDispatcher, ma: &M, a: &Shape, mb: &M, b: &Shape, margin: P::Real, ) -> bool { if let (Some(a), Some(b)) = (a.as_shape::>(), b.as_shape::>()) { self.proximity = proximity_internal::ball_against_ball( &P::from_coordinates(ma.translation().to_vector()), a, &P::from_coordinates(mb.translation().to_vector()), b, margin, ); true } else { false } } #[inline] fn proximity(&self) -> Proximity { self.proximity } }