chunk: store index in chunk itself

pull/10/head
EmaMaker 2023-10-03 22:32:16 +02:00
parent 490f207e39
commit 60bbc85682
2 changed files with 4 additions and 0 deletions

View File

@ -65,12 +65,15 @@ namespace Chunk
public: public:
GLuint VAO{0}, VBO{0}, extentsBuffer{0}, texinfoBuffer{0}, numVertices{0}; GLuint VAO{0}, VBO{0}, extentsBuffer{0}, texinfoBuffer{0}, numVertices{0};
std::atomic<float> unload_timer{0}; std::atomic<float> unload_timer{0};
chunk_index_t getIndex(){ return this->index; }
private: private:
glm::vec3 position{}; glm::vec3 position{};
IntervalMap<Block> blocks{}; IntervalMap<Block> blocks{};
std::atomic_uint8_t state{0}; std::atomic_uint8_t state{0};
chunk_index_t index;
}; };
}; };

View File

@ -29,6 +29,7 @@ namespace Chunk
this->position = pos; this->position = pos;
this->setState(CHUNK_STATE_EMPTY, true); this->setState(CHUNK_STATE_EMPTY, true);
this->setBlocks(0, CHUNK_MAX_INDEX, Block::AIR); this->setBlocks(0, CHUNK_MAX_INDEX, Block::AIR);
this->index = calculateIndex(pos);
} }
Chunk ::~Chunk() Chunk ::~Chunk()