-
Notifications
You must be signed in to change notification settings - Fork 1
/
shapes.rs
47 lines (44 loc) · 1.2 KB
/
shapes.rs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::hittable::Hittable;
pub mod quad;
pub mod quad_box;
pub mod sphere;
// are other shapes useful?
// possible SDF definitions?
// pub mod a_box;
// pub mod cylinder;
// pub mod rounded_box;
pub enum Shapes {
Sphere(sphere::Sphere),
Quad(quad::Quad),
QuadBox(quad_box::QuadBox),
// RoundedBox(rounded_box::RoundedBox),
// Box(a_box::Box),
// Cylinder(cylinder::Cylinder),
}
impl Hittable for Shapes {
fn hit(
&self,
ray: &crate::ray::Ray,
interval: std::ops::Range<f64>,
) -> Option<crate::hittable::HitRecord> {
match self {
Shapes::Sphere(object) => {
object.hit(ray, interval)
}
Shapes::Quad(object) => {
object.hit(ray, interval)
}
Shapes::QuadBox(object) => {
object.hit(ray, interval)
} // Shapes::RoundedBox(object) => {
// object.hit(ray, interval)
// }
// Shapes::Box(object) => {
// object.hit(ray, interval)
// }
// Shapes::Cylinder(object) => {
// object.hit(ray, interval)
// }
}
}
}