Skip to main content

voxel_light/
types.rs

1/// A pending light level change at a world-space position.
2#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3pub struct LightUpdate {
4    pub x: i32,
5    pub y: i32,
6    pub z: i32,
7    pub level: u8,
8}
9
10impl LightUpdate {
11    pub fn new(pos: [i32; 3], level: u8) -> Self {
12        Self {
13            x: pos[0],
14            y: pos[1],
15            z: pos[2],
16            level,
17        }
18    }
19
20    pub fn pos(&self) -> [i32; 3] {
21        [self.x, self.y, self.z]
22    }
23}
24
25#[derive(Clone, Copy, Debug)]
26pub(crate) struct LightNode {
27    pub x: i32,
28    pub y: i32,
29    pub z: i32,
30    pub level: u8,
31}
32
33#[derive(Clone, Copy, Debug)]
34pub(crate) struct RemovalNode {
35    pub x: i32,
36    pub y: i32,
37    pub z: i32,
38    pub old_level: u8,
39}
40
41pub(crate) const DIRECTIONS: [[i32; 3]; 6] = [
42    [1, 0, 0],
43    [-1, 0, 0],
44    [0, 1, 0],
45    [0, -1, 0],
46    [0, 0, 1],
47    [0, 0, -1],
48];