Do not generate light data for invisible blocks

This commit is contained in:
Matthias Schiffer 2020-06-20 14:48:26 +02:00
parent 3c837bb92e
commit 98e21236d9
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -89,9 +89,6 @@ static uint8_t biomeAt(ssize_t x, ssize_t z, const std::unique_ptr<uint8_t[]> bi
}
static Resource::Color collectColors(size_t x, size_t z, const World::Block &block, const std::unique_ptr<uint8_t[]> biomemaps[3][3]) {
if (!block.isVisible())
return Resource::Color();
std::unordered_map<uint8_t, size_t> biomes;
for (int dx = -BIOME_SMOOTH; dx <= BIOME_SMOOTH; dx++) {
for (int dz = -BIOME_SMOOTH; dz <= BIOME_SMOOTH; dz++) {
@ -138,6 +135,9 @@ static void addChunk(Resource::Color image[DIM*DIM], uint8_t lightmap[2*DIM*DIM]
const World::Chunk::Height &height = layer.v[x][z];
World::Block block = chunk.getBlock(x, height, z);
if (!block.isVisible())
continue;
image[i] = collectColors(X*World::Chunk::SIZE+x, Z*World::Chunk::SIZE+z, block, biomemaps);
lightmap[2*i+1] = (1 - block.blockLight/15.f)*192;
}