Tweaks to naming

master
Nicole Collings 2020-06-23 20:27:18 -07:00
parent 48c7a38763
commit eaa9aecb8f
3 changed files with 11 additions and 20 deletions

View File

@ -219,7 +219,7 @@ void LocalDimension::attemptMeshChunk(const std::shared_ptr<Chunk>& chunk, bool
if (!renderable) return;
if (!chunk->dirty) return;
if (!chunk->shouldHaveMesh) removeMeshChunk(chunk->pos);
if (!chunk->shouldRender) removeMeshChunk(chunk->pos);
pendingMesh.push_back(chunk->pos);

View File

@ -22,19 +22,11 @@ Chunk::Chunk(const std::vector<unsigned int>& blocks, const std::vector<unsigned
bool Chunk::setBlock(unsigned int ind, unsigned int blk) {
if (!RIE::write(ind, blk, blocks, 4096)) return false;
if (blk == DefinitionAtlas::AIR) {
if ((nonAirBlocks = fmax(nonAirBlocks - 1, 0)) == 0) {
empty = true;
shouldHaveMesh = false;
}
if (blk == DefinitionAtlas::AIR && !(renderableBlocks = std::max(renderableBlocks - 1, 0))) shouldRender = false;
else if (blk != DefinitionAtlas::AIR && getBlock(ind) == DefinitionAtlas::AIR) {
shouldRender = true;
renderableBlocks++;
}
else if (getBlock(ind) == DefinitionAtlas::AIR) {
shouldHaveMesh = true;
empty = false;
nonAirBlocks++;
}
return true;
}
@ -100,16 +92,16 @@ void Chunk::deserialize(PacketView& packet) {
}
void Chunk::recalculateRenderableBlocks() {
shouldHaveMesh = false;
nonAirBlocks = 0;
shouldRender = false;
renderableBlocks = 0;
for (unsigned int i = 0; i < blocks.size(); i += 2) {
unsigned int nInd = (i == blocks.size() - 2 ? 4095 : blocks[i + 2]);
unsigned int cInd = blocks[i];
if (blocks[i + 1] > DefinitionAtlas::AIR) {
nonAirBlocks += nInd - cInd;
shouldHaveMesh = true;
renderableBlocks += nInd - cInd;
shouldRender = true;
}
}
}

View File

@ -68,7 +68,7 @@ public:
bool generated = false;
bool dirty = true;
bool shouldHaveMesh = true;
bool shouldRender = true;
glm::ivec3 pos;
@ -79,8 +79,7 @@ private:
std::array<SunLight, 2048> sunLight {};
std::array<BlockLight, 4096> blockLight {};
bool empty = true;
unsigned short nonAirBlocks = 0;
unsigned short renderableBlocks = 0;
inline unsigned char getSunlight(unsigned int ind);
inline void setSunlight(unsigned int ind, unsigned char val);