-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectional.rs
48 lines (40 loc) · 1.02 KB
/
directional.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
48
use glam::Vec3A;
use super::Light;
use crate::{colour::Colour, photonmap::Photon, Vertex};
#[derive(Clone, Debug, PartialEq)]
pub struct Directional {
pub direction: Vec3A,
pub intensity: Colour,
}
impl Default for Directional {
fn default() -> Self {
Self {
direction: Vec3A::default(),
intensity: Colour::default(),
}
}
}
impl Directional {
pub fn new(direction: Vec3A, intensity: Colour) -> Self {
Self {
direction: direction.normalize(),
intensity,
}
}
}
impl Light for Directional {
fn get_direction(&self, _surface: Vertex) -> (Vec3A, bool) {
(-self.direction, true)
}
fn get_position(&self) -> Option<Vertex> {
// directional lights have no position
None
}
fn get_intensity(&self, _surface: Vertex) -> Colour {
self.intensity
}
fn generate_photon(&self) -> Photon {
// cannot generate a photon an infinite distance away
unimplemented!()
}
}