ncollide3d/pipeline/narrow_phase/contact_generator/
contact_manifold_generator.rs1use crate::math::Isometry;
2use crate::query::ContactPreprocessor;
3use crate::query::{ContactManifold, ContactPrediction};
4use crate::shape::Shape;
5use na::RealField;
6use std::any::Any;
7
8pub trait ContactManifoldGenerator<N: RealField + Copy>: Any + Send + Sync {
11 fn generate_contacts(
20 &mut self,
21 dispatcher: &dyn ContactDispatcher<N>,
22 ma: &Isometry<N>,
23 a: &dyn Shape<N>,
24 proc1: Option<&dyn ContactPreprocessor<N>>,
25 mb: &Isometry<N>,
26 b: &dyn Shape<N>,
27 proc2: Option<&dyn ContactPreprocessor<N>>,
28 prediction: &ContactPrediction<N>,
29 manifold: &mut ContactManifold<N>,
30 ) -> bool;
31
32 fn init_manifold(&self) -> ContactManifold<N> {
34 ContactManifold::new()
35 }
36}
37
38pub type ContactAlgorithm<N> = Box<dyn ContactManifoldGenerator<N>>;
39
40pub trait ContactDispatcher<N>: Any + Send + Sync {
41 fn get_contact_algorithm(
43 &self,
44 a: &dyn Shape<N>,
45 b: &dyn Shape<N>,
46 ) -> Option<ContactAlgorithm<N>>;
47}