use std::any::Any; use geometry::query::Proximity; use geometry::shape::Shape; use math::Point; /// Trait implemented by algorithms that determine if two objects are in close proximity. pub trait ProximityDetector: Any + Send + Sync { /// Runs the proximity detection on two objects. It is assumed that the same proximity detector /// (the same structure) is always used with the same pair of object. fn update( &mut self, dispatcher: &ProximityDispatcher, ma: &M, a: &Shape, mb: &M, b: &Shape, margin: P::Real, ) -> bool; /// The number of collision detected during the last update. fn proximity(&self) -> Proximity; } pub type ProximityAlgorithm = Box>; pub trait ProximityDispatcher: Any + Send + Sync { /// Allocate a collision algorithm corresponding to the given pair of shapes. fn get_proximity_algorithm( &self, a: &Shape, b: &Shape, ) -> Option>; }