//! Trait used to implement the `time_of_impact` function. use std::sync::Arc; use na::Translate; use na; use entities::shape::{Ball, Plane, Cuboid, Capsule, Cone, Cylinder, ConvexHull, Compound, Mesh, Segment, Triangle}; use geometry::traits::Shape; use geometry::time_of_impact_internal; use math::{Scalar, Point, Vector, Isometry}; /// Trait implemented by object that can have their Time Of Impact under translational movement /// computed. pub trait TimeOfImpactWith for Sized? { /// Computes the Time Of Impact separating two shapes. /// /// Returns `None` if they never move. fn time_of_impact(m1: &M, vel1: &V, g1: &Self, m2: &M, vel2: &V, g2: &G) -> Option; } /// Computes the Time Of Impact separating two shapes under translational movement. pub fn time_of_impact(m1: &M, vel1: &V, g1: &G1, m2: &M, vel2: &V, g2: &G2) -> Option where N: Scalar, P: Point, V: Vector + Translate

, M: Isometry, G1: TimeOfImpactWith { TimeOfImpactWith::time_of_impact(m1, vel1, g1, m2, vel2, g2) } /* * * * Impls follow. * * */ macro_rules! impl_time_of_impact_with( ($name: ident | $g1: ty, $g2: ty) => { impl TimeOfImpactWith for $g1 where N: Scalar, P: Point, V: Vector + Translate

, M: Isometry { #[inline] fn time_of_impact(m1: &M, vel1: &V, g1: &$g1, m2: &M, vel2: &V, g2: &$g2) -> Option { time_of_impact_internal::$name(m1, vel1, g1, m2, vel2, g2) } } } ); apply_with_mixed_args!(impl_time_of_impact_with, plane_against_support_map | support_map_against_plane | support_map_against_support_map | concave_shape_against_shape | shape_against_concave_shape); impl TimeOfImpactWith> for Ball where N: Scalar, P: Point, V: Vector, M: Isometry { #[inline] fn time_of_impact(m1: &M, vel1: &V, g1: &Ball, m2: &M, vel2: &V, g2: &Ball) -> Option { let p1 = m1.translate(&na::origin()); let p2 = m2.translate(&na::origin()); time_of_impact_internal::ball_against_ball(&p1, vel1, g1, &p2, vel2, g2) } } /* FIXME: DST: ICE impl TimeOfImpactWith + Send + Sync> for Shape + Send + Sync where N: Scalar, P: Point, V: Vector + Translate

, M: Isometry { #[inline] fn time_of_impact(m1: &M, g1: &Shape + Send + Sync, m2: &M, g2: &Shape + Send + Sync) -> N { unimplemented!() // time_of_impact_internal::$name(m1, g1, m2, g2) } } */