VoxelEngine
 
Loading...
Searching...
No Matches
CoordUtils.h
1#pragma once
2
3#include <glm/glm.hpp>
4#include "level/World.h"
5
6namespace engine {
7
11 ChunkID extractChunkCoords(glm::vec3& pos);
12 ChunkID extractChunkCoords(glm::ivec3& pos);
13
18 ChunkID extractChunkCoords(glm::vec3& pos, const glm::ivec3& chunkDims);
19 ChunkID extractChunkCoords(glm::ivec3& pos, const glm::ivec3& chunkDims);
20
21 glm::ivec3 toChunkCoords(const ChunkID& chunkID, const glm::vec3& pos);
22 glm::ivec3 toChunkCoords(
23 const ChunkID& chunkID, const glm::vec3& pos, const glm::ivec3& chunkDims
24 );
25
26 ChunkID getChunkID(const glm::vec3& pos);
27 ChunkID getChunkID(const glm::vec3& pos, const glm::ivec3& chunkDims);
28
31 glm::ivec3 floorToInt(const glm::vec3& vec);
32
33 inline int floorDiv(int a, int b) {
34 return (a >= 0) ? (a / b) : ((a - b + 1) / b);
35 }
36
38 std::vector<glm::ivec3> traceLine(glm::vec3 start, glm::vec3 end);
39} // namespace engine