use crate::math::{interval::Interval, *}; #[derive(Debug, Clone, Copy)] pub struct Hit<'a, T> { pub position: Vec3, pub normal: Vec3, pub outside: bool, pub uv: Vec2, pub t: f64, pub object: &'a T, } impl<'a, T> Hit<'a, T> { pub fn set_object<'b, U>(&self, object: &'b U) -> Hit<'b, U> { Hit { position: self.position, normal: self.normal, outside: self.outside, uv: self.uv, t: self.t, object, } } } pub trait Intersect { type Object; fn intersect(&self, ray: &Ray, range: &Interval) -> Option>; fn does_intersect(&self, ray: &Ray, range: &Interval) -> bool; fn intersect_range(&self, ray: &Ray, range: &Interval) -> Option; } pub trait Bounded { fn get_box(&self) -> AABB; }