use crate::aabb::AABB; use crate::hitable::Hit; use crate::hitable::HitRecord; use crate::ray::Ray; pub struct FlipNormals where H: Hit, { hitable: H, } impl FlipNormals where H: Hit, { pub fn new(hitable: H) -> FlipNormals { FlipNormals { hitable } } } impl Hit for FlipNormals where H: Hit, { fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option { if let Some(rec) = self.hitable.hit(r, t_min, t_max) { return Some(HitRecord { normal: -rec.normal, ..rec }); }; None } fn bounding_box(&self, t_min: f32, t_max: f32) -> Option { self.hitable.bounding_box(t_min, t_max) } }