summary refs log tree commit diff
path: root/src/World/ChunkIndex.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/ChunkIndex.hpp')
-rw-r--r--src/World/ChunkIndex.hpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/World/ChunkIndex.hpp b/src/World/ChunkIndex.hpp
index 7d6fdbf..ed3347b 100644
--- a/src/World/ChunkIndex.hpp
+++ b/src/World/ChunkIndex.hpp
@@ -1,6 +1,9 @@
 #pragma once
 
 #include "../Common/Sizes.hpp"
+#include "../Math/Vector.hpp"
+#include "ChunkDimensions.hpp"
+#include "Position.hpp"
 
 namespace MC::World {
 
@@ -9,7 +12,13 @@ struct ChunkIndex {
     ChunkIndex(I32 x, I32 y) : x(x), y(y) {}
 
     Vector<3> middle() const {
-        return {(x + 0.5f) * Chunk::Width, Chunk::Height / 2.0f, (y + 0.5f) * Chunk::Width};
+        using namespace ChunkDimensions;
+        return {(x + 0.5f) * Width, Height / 2.0f, (y + 0.5f) * Width};
+    }
+
+    Position::BlockWorld world(Position::BlockLocal local) const {
+        using namespace ChunkDimensions;
+        return {x * Width + local.x(), local.y(), y * Width + local.z()};
     }
 
     I32 x, y;