use std::marker::PhantomData; use math::{Isometry, Point}; use na; use geometry::shape::{Ball, Plane, Shape}; use geometry::query::algorithms::{JohnsonSimplex, VoronoiSimplex2, VoronoiSimplex3}; use narrow_phase::proximity_detector::{BallBallProximityDetector, CompositeShapeShapeProximityDetector, PlaneSupportMapProximityDetector, ProximityAlgorithm, ProximityDispatcher, ShapeCompositeShapeProximityDetector, SupportMapPlaneProximityDetector, SupportMapSupportMapProximityDetector}; /// Proximity dispatcher for shapes defined by `ncollide_entities`. pub struct DefaultProximityDispatcher { _point_type: PhantomData

, _matrix_type: PhantomData, } impl DefaultProximityDispatcher { /// Creates a new basic proximity dispatcher. pub fn new() -> DefaultProximityDispatcher { DefaultProximityDispatcher { _point_type: PhantomData, _matrix_type: PhantomData, } } } impl> ProximityDispatcher for DefaultProximityDispatcher { fn get_proximity_algorithm( &self, a: &Shape, b: &Shape, ) -> Option> { let a_is_ball = a.is_shape::>(); let b_is_ball = b.is_shape::>(); if a_is_ball && b_is_ball { Some(Box::new(BallBallProximityDetector::::new())) } else if a.is_shape::>() && b.is_support_map() { Some(Box::new(PlaneSupportMapProximityDetector::::new())) } else if b.is_shape::>() && a.is_support_map() { Some(Box::new(SupportMapPlaneProximityDetector::::new())) } else if a.is_support_map() && b.is_support_map() { if na::dimension::() == 2 { let simplex = VoronoiSimplex2::new(); Some(Box::new(SupportMapSupportMapProximityDetector::new( simplex, ))) } else if na::dimension::() == 3 { let simplex = VoronoiSimplex3::new(); Some(Box::new(SupportMapSupportMapProximityDetector::new( simplex, ))) } else { let simplex = JohnsonSimplex::new_w_tls(); Some(Box::new(SupportMapSupportMapProximityDetector::new( simplex, ))) } } else if a.is_composite_shape() { Some(Box::new( CompositeShapeShapeProximityDetector::::new(), )) } else if b.is_composite_shape() { Some(Box::new( ShapeCompositeShapeProximityDetector::::new(), )) } else { None } } }