From 60bbc8568246b601094bcc7fc48b30747ef8acdf Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Tue, 3 Oct 2023 22:32:16 +0200 Subject: [PATCH] chunk: store index in chunk itself --- include/chunk.hpp | 3 +++ src/chunk.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/include/chunk.hpp b/include/chunk.hpp index 5ecafe4..26a7f86 100644 --- a/include/chunk.hpp +++ b/include/chunk.hpp @@ -65,12 +65,15 @@ namespace Chunk public: GLuint VAO{0}, VBO{0}, extentsBuffer{0}, texinfoBuffer{0}, numVertices{0}; std::atomic unload_timer{0}; + chunk_index_t getIndex(){ return this->index; } private: glm::vec3 position{}; IntervalMap blocks{}; std::atomic_uint8_t state{0}; + + chunk_index_t index; }; }; diff --git a/src/chunk.cpp b/src/chunk.cpp index f7822e0..982edf8 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -29,6 +29,7 @@ namespace Chunk this->position = pos; this->setState(CHUNK_STATE_EMPTY, true); this->setBlocks(0, CHUNK_MAX_INDEX, Block::AIR); + this->index = calculateIndex(pos); } Chunk ::~Chunk()