aboutsummaryrefslogtreecommitdiff
path: root/src/world/shapes/mod.rs
blob: a11df5dcb479780fcaca55d1966da83968471bf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)
    }
}