use na::Translation; use math::{Point, Vector, Isometry}; use entities::shape::{Ball, Capsule, Compound, Cone, ConvexHull, Cuboid, Cylinder, TriMesh, Polyline, Plane, Segment, Triangle}; use entities::inspection::Repr; use point::PointQuery; macro_rules! dispatch( ($sself: ident.$name: ident($($argN: ident),*)) => { { let repr = $sself.repr(); if let Some(b) = repr.downcast_ref::::Scalar>>() { b.$name($($argN,)*) } else if let Some(c) = repr.downcast_ref::::Scalar>>() { c.$name($($argN,)*) } else if let Some(c) = repr.downcast_ref::>() { c.$name($($argN,)*) } else if let Some(c) = repr.downcast_ref::::Scalar>>() { c.$name($($argN,)*) } else if let Some(c) = repr.downcast_ref::>() { c.$name($($argN,)*) } else if let Some(c) = repr.downcast_ref::>() { c.$name($($argN,)*) } else if let Some(c) = repr.downcast_ref::::Scalar>>() { c.$name($($argN,)*) } else if let Some(t) = repr.downcast_ref::>() { t.$name($($argN,)*) } else if let Some(p) = repr.downcast_ref::>() { p.$name($($argN,)*) } else if let Some(p) = repr.downcast_ref::>() { p.$name($($argN,)*) } else if let Some(s) = repr.downcast_ref::>() { s.$name($($argN,)*) } else if let Some(t) = repr.downcast_ref::>() { t.$name($($argN,)*) } else { /* * XXX: dispatch by custom type. */ unimplemented!() } } } ); impl PointQuery for Repr where P: Point, M: Isometry + Translation { #[inline] fn project_point(&self, m: &M, pt: &P, solid: bool) -> P { dispatch!(self.project_point(m, pt, solid)) } #[inline] fn distance_to_point(&self, m: &M, pt: &P) -> ::Scalar { dispatch!(self.distance_to_point(m, pt)) } #[inline] fn contains_point(&self, m: &M, pt: &P) -> bool { dispatch!(self.contains_point(m, pt)) } }