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
49
|
use glm;
type ChunkPos = struct {
x: i32,
z: i32,
};
type SectionPos = union {
chunk: ChunkPos,
struct {
ChunkPos,
y: i8,
},
};
type BlockPos = struct {
x: i32,
y: i16,
z: i32,
};
type Dir = enum u8 {
WEST,
EAST,
DOWN,
UP,
NORTH,
SOUTH,
};
fn block_section(pos: BlockPos) SectionPos = {
return SectionPos {
x = pos.x >> 4,
y = (pos.y >> 4): i8,
z = pos.z >> 4,
};
};
fn section_origin(pos: SectionPos) glm::v3 = {
return glm::v3_new(
pos.x: f32 * 16.0,
pos.y: f32 * 16.0,
pos.z: f32 * 16.0,
);
};
fn block_origin(pos: BlockPos) glm::v3 = {
return glm::v3_new(pos.x: f32, pos.y: f32, pos.z: f32);
};
|