ncollide3d/pipeline/narrow_phase/proximity_detector/
proximity_detector.rs

1use crate::math::Isometry;
2use crate::query::Proximity;
3use crate::shape::Shape;
4use na::RealField;
5use std::any::Any;
6
7/// Trait implemented by algorithms that determine if two objects are in close proximity.
8pub trait ProximityDetector<N: RealField + Copy>: Any + Send + Sync {
9    /// Runs the proximity detection on two objects. It is assumed that the same proximity detector
10    /// (the same instance) is always used with the same pair of object.
11    fn update(
12        &mut self,
13        dispatcher: &dyn ProximityDispatcher<N>,
14        ma: &Isometry<N>,
15        a: &dyn Shape<N>,
16        mb: &Isometry<N>,
17        b: &dyn Shape<N>,
18        margin: N,
19    ) -> Option<Proximity>;
20}
21
22pub type ProximityAlgorithm<N> = Box<dyn ProximityDetector<N>>;
23
24pub trait ProximityDispatcher<N>: Any + Send + Sync {
25    /// Allocate a collision algorithm corresponding to the given pair of shapes.
26    fn get_proximity_algorithm(
27        &self,
28        a: &dyn Shape<N>,
29        b: &dyn Shape<N>,
30    ) -> Option<ProximityAlgorithm<N>>;
31}