ncollide3d/query/ray/
ray_shape.rs
1use crate::math::Isometry;
2use crate::query::{Ray, RayCast, RayIntersection};
3use crate::shape::Shape;
4use na::RealField;
5
6impl<N: RealField + Copy> RayCast<N> for dyn Shape<N> {
7 #[inline]
8 fn toi_with_ray(&self, m: &Isometry<N>, ray: &Ray<N>, max_toi: N, solid: bool) -> Option<N> {
9 self.as_ray_cast()
10 .expect("No RayCast implementation for the underlying shape.")
11 .toi_with_ray(m, ray, max_toi, solid)
12 }
13
14 #[inline]
15 fn toi_and_normal_with_ray(
16 &self,
17 m: &Isometry<N>,
18 ray: &Ray<N>,
19 max_toi: N,
20 solid: bool,
21 ) -> Option<RayIntersection<N>> {
22 self.as_ray_cast()
23 .expect("No RayCast implementation for the underlying shape.")
24 .toi_and_normal_with_ray(m, ray, max_toi, solid)
25 }
26
27 #[cfg(feature = "dim3")]
28 #[inline]
29 fn toi_and_normal_and_uv_with_ray(
30 &self,
31 m: &Isometry<N>,
32 ray: &Ray<N>,
33 max_toi: N,
34 solid: bool,
35 ) -> Option<RayIntersection<N>> {
36 self.as_ray_cast()
37 .expect("No RayCast implementation for the underlying shape.")
38 .toi_and_normal_and_uv_with_ray(m, ray, max_toi, solid)
39 }
40
41 #[inline]
42 fn intersects_ray(&self, m: &Isometry<N>, ray: &Ray<N>, max_toi: N) -> bool {
43 self.as_ray_cast()
44 .expect("No RayCast implementation for the underlying shape.")
45 .intersects_ray(m, ray, max_toi)
46 }
47}