Exclude unpopulated chunks from biome averaging

Avoids weirdly colored stripes at the edges of the map.
This commit is contained in:
Matthias Schiffer 2020-06-20 02:11:22 +02:00
parent eb831608e0
commit 03ae9cf302
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
2 changed files with 8 additions and 2 deletions

View file

@ -113,10 +113,16 @@ static Resource::Color collectColors(size_t x, size_t z, const World::Block &blo
uint8_t biome = e.first;
size_t count = e.second;
if (biome == 0xff)
continue;
c = c + count * block.getColor(biome);
total += count;
}
if (!total)
return block.getColor(0);
return (1.0f / total) * c;
}
@ -255,7 +261,7 @@ static void makeBiome(const std::string &regiondir, const std::string &outputdir
try {
std::unique_ptr<uint8_t[]> biomemap(new uint8_t[DIM*DIM]);
std::memset(biomemap.get(), 0, DIM*DIM);
std::memset(biomemap.get(), 0xff, DIM*DIM);
World::Region::visitChunks(input.c_str(), [&] (size_t X, size_t Z, const World::ChunkData *chunk) {
addChunkBiome(biomemap.get(), X, Z, chunk);

View file

@ -78,7 +78,7 @@ uint8_t Chunk::getBiome(size_t x, size_t y, size_t z) const {
else if (biomeBytes)
return biomeBytes->getValue(z*SIZE + x);
else
return 0;
return 0xff;
}
Block Chunk::getBlock(size_t x, Chunk::Height height, size_t z) const {