use std::any::Any; use geometry::shape::Shape; use geometry::query::{Contact, ContactPrediction}; use math::Point; /// Trait implemented algorithms that compute contact points, normals and penetration depths. pub trait ContactGenerator: Any + Send + Sync { /// Runs the collision detection on two objects. It is assumed that the same /// collision detector (the same structure) is always used with the same /// pair of object. fn update( &mut self, dispatcher: &ContactDispatcher, ma: &M, a: &Shape, mb: &M, b: &Shape, prediction: &ContactPrediction, ) -> bool; /// The number of contacts generated the last update. fn num_contacts(&self) -> usize; /// Collects the contacts generated during the last update. fn contacts(&self, &mut Vec>); } pub type ContactAlgorithm = Box>; pub trait ContactDispatcher: Any + Send + Sync { /// Allocate a collision algorithm corresponding to the given pair of shapes. fn get_contact_algorithm( &self, a: &Shape, b: &Shape, ) -> Option>; }