1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
use bounding_volume::{self, BoundingSphere, AABB}; use query::{PointQuery, RayCast}; use shape::{Ball, CompositeShape, Compound, Cone, ConvexHull, Cuboid, Cylinder, Plane, Polyline, Segment, Shape, SupportMap, TriMesh, Triangle}; use math::{Isometry, Point}; macro_rules! impl_as_support_map( () => { #[inline] fn as_support_map(&self) -> Option<&SupportMap<P, M>> { Some(self) } #[inline] fn is_support_map(&self) -> bool { true } } ); macro_rules! impl_as_composite_shape( () => { #[inline] fn as_composite_shape(&self) -> Option<&CompositeShape<P, M>> { Some(self) } #[inline] fn is_composite_shape(&self) -> bool { true } } ); macro_rules! impl_shape_common( () => { #[inline] fn aabb(&self, m: &M) -> AABB<P> { bounding_volume::aabb(self, m) } #[inline] fn bounding_sphere(&self, m: &M) -> BoundingSphere<P> { bounding_volume::bounding_sphere(self, m) } #[inline] fn as_ray_cast(&self) -> Option<&RayCast<P, M>> { Some(self) } #[inline] fn as_point_query(&self) -> Option<&PointQuery<P, M>> { Some(self) } } ); impl<P: Point, M: Isometry<P>> Shape<P, M> for Triangle<P> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Segment<P> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Ball<P::Real> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Cuboid<P::Vector> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Cylinder<P::Real> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Cone<P::Real> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for ConvexHull<P> { impl_shape_common!(); impl_as_support_map!(); } impl<P: Point, M: 'static + Send + Sync + Isometry<P>> Shape<P, M> for Compound<P, M> { impl_shape_common!(); impl_as_composite_shape!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for TriMesh<P> { impl_shape_common!(); impl_as_composite_shape!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Polyline<P> { impl_shape_common!(); impl_as_composite_shape!(); } impl<P: Point, M: Isometry<P>> Shape<P, M> for Plane<P::Vector> { impl_shape_common!(); }