diff options
| author | Mel <einebeere@gmail.com> | 2023-08-06 01:54:27 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-08-06 01:54:27 +0200 |
| commit | e6f5f9e03f673db796f1babb308609ca2576db2f (patch) | |
| tree | fbc7d9451ec943a107f0ab54b3de7a7bd25e656d /src/World/ChunkIndex.hpp | |
| parent | a627fb7038c94de9be9709ea88dcd1dddc95c5a3 (diff) | |
| download | meowcraft-e6f5f9e03f673db796f1babb308609ca2576db2f.tar.zst meowcraft-e6f5f9e03f673db796f1babb308609ca2576db2f.zip | |
Improve MC::Position and remove some redundant code
Diffstat (limited to 'src/World/ChunkIndex.hpp')
| -rw-r--r-- | src/World/ChunkIndex.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/World/ChunkIndex.hpp b/src/World/ChunkIndex.hpp index ed3347b..70de99f 100644 --- a/src/World/ChunkIndex.hpp +++ b/src/World/ChunkIndex.hpp @@ -16,11 +16,17 @@ struct ChunkIndex { return {(x + 0.5f) * Width, Height / 2.0f, (y + 0.5f) * Width}; } - Position::BlockWorld world(Position::BlockLocal local) const { + Position::BlockWorld local_to_world_position(Position::BlockLocal local) const { using namespace ChunkDimensions; return {x * Width + local.x(), local.y(), y * Width + local.z()}; } + static ChunkIndex from_position(Position::BlockWorld pos) { + I32 chunk_x = std::round(pos.x() / ChunkDimensions::Width); + I32 chunk_y = std::round(pos.z() / ChunkDimensions::Width); + return {chunk_x, chunk_y}; + } + I32 x, y; }; |
