mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
Exclude unpopulated chunks from biome averaging
Avoids weirdly colored stripes at the edges of the map.
This commit is contained in:
parent
eb831608e0
commit
03ae9cf302
2 changed files with 8 additions and 2 deletions
|
@ -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 ®iondir, 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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue