blob: 6e4b2ced35556cc267462d73c901ecba7a2fc5f0 (
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
31
32
|
mod sphere;
mod rectangle;
pub use sphere::Sphere;
pub use rectangle::{Rect, Plane};
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)
}
}
|