From ae460c3f34838e3baf0ffafe4ccbcf1fbfe03095 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 31 Jul 2021 18:27:56 +0200 Subject: Remove dynamic boxes from object and list implementation --- src/world/shapes/mod.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/world/shapes') diff --git a/src/world/shapes/mod.rs b/src/world/shapes/mod.rs index d7583ad..a11df5d 100644 --- a/src/world/shapes/mod.rs +++ b/src/world/shapes/mod.rs @@ -2,3 +2,29 @@ mod sphere; pub use sphere::Sphere; +use crate::world::{Hittable, Intersection}; +use crate::core::{Bound3f, Ray}; + +pub enum Shape { + Sphere(Sphere), +} + +impl Hittable for Shape { + fn intersect(&self, ray: &Ray) -> Option { + match self { + Self::Sphere(sph) => sph.intersect(ray) + } + } + + fn bounding_box(&self) -> Bound3f { + match self { + Self::Sphere(sph) => sph.bounding_box() + } + } +} + +impl From for Shape { + fn from(s: Sphere) -> Self { + Self::Sphere(s) + } +} -- cgit v1.2.3