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 ray::{RayCast, Ray, RayIntersection}; 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 RayCast for Repr where P: Point, M: Isometry { #[inline] fn toi_with_ray(&self, m: &M, ray: &Ray

, solid: bool) -> Option<::Scalar> { dispatch!(self.toi_with_ray(m, ray, solid)) } #[inline] fn toi_and_normal_with_ray(&self, m: &M, ray: &Ray

, solid: bool) -> Option> { dispatch!(self.toi_and_normal_with_ray(m, ray, solid)) } #[inline] fn toi_and_normal_and_uv_with_ray(&self, m: &M, ray: &Ray

, solid: bool) -> Option> { dispatch!(self.toi_and_normal_and_uv_with_ray(m, ray, solid)) } #[inline] fn intersects_ray(&self, m: &M, ray: &Ray

) -> bool { dispatch!(self.intersects_ray(m, ray)) } }