chunk: store index in chunk itself
parent
490f207e39
commit
60bbc85682
|
@ -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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue