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
use rand::rngs::StdRng;
use super::{HitRecord, Ray, Shape};
#[derive(Copy, Clone)]
pub struct Plane {
pub normal: glm::DVec3,
pub value: f64,
}
impl Shape for Plane {
fn intersect(&self, ray: &Ray, t_min: f64, record: &mut HitRecord) -> bool {
let cosine = self.normal.dot(&ray.dir);
if cosine.abs() < 1e-8 {
return false;
}
let time = (self.value - self.normal.dot(&ray.origin)) / cosine;
if time >= t_min && time < record.time {
record.time = time;
record.normal = -self.normal.normalize() * cosine.signum();
true
} else {
false
}
}
fn sample(&self, _target: &glm::DVec3, _rng: &mut StdRng) -> (glm::DVec3, glm::DVec3, f64) {
unimplemented!()
}
}