summary refs log tree commit diff
path: root/src/World/ChunkRegistry.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/ChunkRegistry.hpp')
-rw-r--r--src/World/ChunkRegistry.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/World/ChunkRegistry.hpp b/src/World/ChunkRegistry.hpp
new file mode 100644
index 0000000..86e5d06
--- /dev/null
+++ b/src/World/ChunkRegistry.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <optional>
+#include <unordered_map>
+#include "Chunk.hpp"
+#include "ChunkIndex.hpp"
+#include "Position.hpp"
+#include "../GFX/Binder.hpp"
+
+namespace MC::World {
+
+class ChunkRegistry {
+public:
+    enum class Status {
+        Empty,
+        WaitingForGeneration,
+        WaitingForReification,
+        Done
+    };
+
+    // I think a Chunk entity should just store all this by itself...
+    struct Data {
+        ChunkIndex index;
+        Status status;
+        std::optional<Chunk> chunk = {};
+
+        std::optional<GFX::Mesh> land_mesh_data = {};
+        std::optional<GFX::Mesh> water_mesh_data = {};
+
+        std::optional<GFX::BindableMesh> land_mesh = {};
+        std::optional<GFX::BindableMesh> water_mesh = {};
+    };
+
+    Data& get(ChunkIndex index);
+
+    Data& find(Position::BlockWorld pos);
+    Data& find(ChunkIndex chunk, Position::BlockLocal pos);
+private:
+    std::unordered_map<ChunkIndex, Data> m_chunks;
+};
+
+}