1use rand::rngs::StdRng;
2
3use super::{HitRecord, Ray, Shape};
4
5#[derive(Copy, Clone)]
7pub struct Plane {
8 pub normal: glm::DVec3,
10
11 pub value: f64,
13}
14
15impl Shape for Plane {
16 fn intersect(&self, ray: &Ray, t_min: f64, record: &mut HitRecord) -> bool {
18 let cosine = self.normal.dot(&ray.dir);
19 if cosine.abs() < 1e-8 {
20 return false;
22 }
23
24 let time = (self.value - self.normal.dot(&ray.origin)) / cosine;
25 if time >= t_min && time < record.time {
26 record.time = time;
27 record.normal = -self.normal.normalize() * cosine.signum();
28 true
29 } else {
30 false
31 }
32 }
33
34 fn sample(&self, _target: &glm::DVec3, _rng: &mut StdRng) -> (glm::DVec3, glm::DVec3, f64) {
35 unimplemented!()
36 }
37}