diff options
Diffstat (limited to 'position.ha')
-rw-r--r-- | position.ha | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/position.ha b/position.ha new file mode 100644 index 0000000..aa0e36d --- /dev/null +++ b/position.ha @@ -0,0 +1,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); +}; |