//! Manages world objects, and implements intersection pub mod shapes; mod scene; pub mod container; mod hittable; pub use scene::*; pub use hittable::{Intersection, Hittable}; use std::sync::Arc; use crate::material::Material; use crate::core::{Bound3f, Ray}; pub struct Object { pub shape: Box, pub mat: Arc, } impl Object { pub fn new(mat: Arc, shape: Box) -> Self { Object { mat, shape, } } } impl Hittable for Object { fn intersect(&self, ray: &Ray) -> Option { self.shape.intersect(ray).map(|mut i| {i.m = Some(self.mat.as_ref()); i}) } fn bounding_box(&self) -> Bound3f { self.shape.bounding_box() } }