ncollide3d/query/ray/
ray_cuboid.rs
1use crate::bounding_volume::AABB;
2use crate::math::{Isometry, Point};
3use crate::query::{Ray, RayCast, RayIntersection};
4use crate::shape::Cuboid;
5use na::RealField;
6
7impl<N: RealField + Copy> RayCast<N> for Cuboid<N> {
8 #[inline]
9 fn toi_with_ray(&self, m: &Isometry<N>, ray: &Ray<N>, max_toi: N, solid: bool) -> Option<N> {
10 let dl = Point::from(-self.half_extents);
11 let ur = Point::from(self.half_extents);
12 AABB::new(dl, ur).toi_with_ray(m, ray, max_toi, solid)
13 }
14
15 #[inline]
16 fn toi_and_normal_with_ray(
17 &self,
18 m: &Isometry<N>,
19 ray: &Ray<N>,
20 max_toi: N,
21 solid: bool,
22 ) -> Option<RayIntersection<N>> {
23 let dl = Point::from(-self.half_extents);
24 let ur = Point::from(self.half_extents);
25 AABB::new(dl, ur).toi_and_normal_with_ray(m, ray, max_toi, solid)
26 }
27
28 #[cfg(feature = "dim3")]
29 #[inline]
30 fn toi_and_normal_and_uv_with_ray(
31 &self,
32 m: &Isometry<N>,
33 ray: &Ray<N>,
34 max_toi: N,
35 solid: bool,
36 ) -> Option<RayIntersection<N>> {
37 let dl = Point::from(-self.half_extents);
38 let ur = Point::from(self.half_extents);
39 AABB::new(dl, ur).toi_and_normal_and_uv_with_ray(m, ray, max_toi, solid)
40 }
41}