parry3d/query/ray/
ray_cuboid.rs1use crate::bounding_volume::Aabb;
2use crate::math::{Point, Real};
3use crate::query::{Ray, RayCast, RayIntersection};
4use crate::shape::Cuboid;
5
6impl RayCast for Cuboid {
7 #[inline]
8 fn cast_local_ray(&self, ray: &Ray, max_time_of_impact: Real, solid: bool) -> Option<Real> {
9 let dl = Point::from(-self.half_extents);
10 let ur = Point::from(self.half_extents);
11 Aabb::new(dl, ur).cast_local_ray(ray, max_time_of_impact, solid)
12 }
13
14 #[inline]
15 fn cast_local_ray_and_get_normal(
16 &self,
17 ray: &Ray,
18 max_time_of_impact: Real,
19 solid: bool,
20 ) -> Option<RayIntersection> {
21 let dl = Point::from(-self.half_extents);
22 let ur = Point::from(self.half_extents);
23 Aabb::new(dl, ur).cast_local_ray_and_get_normal(ray, max_time_of_impact, solid)
24 }
25}