From da1c3949a449f3fafe579c62ff6b14ffd993a197 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sun, 21 Feb 2021 18:01:56 +0100 Subject: Add 3d bounding box and merged SceneIntersection and Intersection --- src/world/mod.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/world/mod.rs') diff --git a/src/world/mod.rs b/src/world/mod.rs index f0ba8d2..43f7530 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -2,11 +2,15 @@ pub mod shapes; mod scene; +mod container; +mod hittable; pub use scene::*; +pub use hittable::{Intersection, Hittable}; +pub use container::HittableList; use std::sync::Arc; -use crate::core::Hittable; use crate::material::Material; +use crate::core::{Bound3f, Ray}; pub struct Object { pub shape: Box, @@ -21,3 +25,13 @@ impl Object { } } } + +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) -> Option { + self.shape.bounding_box() + } +} -- cgit v1.2.3