aboutsummaryrefslogtreecommitdiff
path: root/src/world/shapes
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-07-31 18:27:56 +0200
committerJulian T <julian@jtle.dk>2021-07-31 18:27:56 +0200
commitae460c3f34838e3baf0ffafe4ccbcf1fbfe03095 (patch)
treea2ff1092f5deb2d28f5196d69ba511487f0a4953 /src/world/shapes
parentcee9bcf4a2c8ffbfe6487f7886b2247eaba1c92c (diff)
Remove dynamic boxes from object and list implementation
Diffstat (limited to 'src/world/shapes')
-rw-r--r--src/world/shapes/mod.rs26
1 files changed, 26 insertions, 0 deletions
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<Intersection> {
+ match self {
+ Self::Sphere(sph) => sph.intersect(ray)
+ }
+ }
+
+ fn bounding_box(&self) -> Bound3f {
+ match self {
+ Self::Sphere(sph) => sph.bounding_box()
+ }
+ }
+}
+
+impl From<Sphere> for Shape {
+ fn from(s: Sphere) -> Self {
+ Self::Sphere(s)
+ }
+}