Small optimizations.

This commit is contained in:
Quentin Bazin 2021-06-02 20:14:13 +02:00
parent a9657751ed
commit f30f2ca727
3 changed files with 3 additions and 8 deletions

View File

@ -45,9 +45,9 @@ struct ChunkData {
y = chunk.y();
z = chunk.z();
for (s8f x = -1 ; x <= CHUNK_WIDTH ; ++x) {
for (s8f z = -1 ; z <= CHUNK_HEIGHT ; ++z) {
for (s8f y = -1 ; y <= CHUNK_DEPTH ; ++y) {
for (s8f z = -1 ; z <= CHUNK_HEIGHT ; ++z) {
for (s8f x = -1 ; x <= CHUNK_WIDTH ; ++x) {
data[z + 1][y + 1][x + 1] = chunk.getFullBlock(x, y, z);
lightData[z + 1][y + 1][x + 1] = chunk.lightmap().getLightData(x, y, z);
}

View File

@ -51,11 +51,6 @@ u32 Chunk::getFullBlock(int x, int y, int z) const {
return m_data[z][y][x];
}
void Chunk::setDataRaw(u8 x, u8 y, u8 z, u32 data) {
m_data[z][y][x] = data;
m_hasChanged = true;
}
u16 Chunk::getBlock(int x, int y, int z) const {
if(x < 0) return m_surroundingChunks[0] ? m_surroundingChunks[0]->getBlock(x + Chunk::width, y, z) : 0;
if(x >= Chunk::width) return m_surroundingChunks[1] ? m_surroundingChunks[1]->getBlock(x - Chunk::width, y, z) : 0;

View File

@ -61,7 +61,7 @@ class Chunk : public gk::NonCopyable {
virtual void process() = 0;
u32 getFullBlock(int x, int y, int z) const;
void setDataRaw(u8 x, u8 y, u8 z, u32 data);
void setDataRaw(u8 x, u8 y, u8 z, u32 data) { m_data[z][y][x] = data; m_hasChanged = true; }
u16 getBlock(int x, int y, int z) const;
u16 getData(int x, int y, int z) const;