mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 01:24:53 +01:00
Do not store biome in block structure
Use biome data from biome map.
This commit is contained in:
parent
a3cf5edda4
commit
50f798f89e
3 changed files with 9 additions and 7 deletions
|
@ -65,7 +65,9 @@ static void addChunkBiome(uint8_t biomemap[DIM*DIM], size_t X, size_t Z, const W
|
|||
}
|
||||
}
|
||||
|
||||
static void addChunk(Resource::Color image[DIM*DIM], uint8_t lightmap[2*DIM*DIM], size_t X, size_t Z, const World::ChunkData *data) {
|
||||
static void addChunk(Resource::Color image[DIM*DIM], uint8_t lightmap[2*DIM*DIM], size_t X, size_t Z,
|
||||
const World::ChunkData *data, const std::unique_ptr<uint8_t[]> biomemaps[3][3]
|
||||
) {
|
||||
World::Chunk chunk(data);
|
||||
World::Chunk::Heightmap layer = chunk.getTopLayer(true);
|
||||
|
||||
|
@ -73,9 +75,9 @@ static void addChunk(Resource::Color image[DIM*DIM], uint8_t lightmap[2*DIM*DIM]
|
|||
for (size_t z = 0; z < World::Chunk::SIZE; z++) {
|
||||
size_t i = (Z*World::Chunk::SIZE+z)*DIM + X*World::Chunk::SIZE+x;
|
||||
const World::Chunk::Height &height = layer.v[x][z];
|
||||
const World::Block block = chunk.getBlock(x, height, z);
|
||||
World::Block block = chunk.getBlock(x, height, z);
|
||||
|
||||
image[i] = block.getColor();
|
||||
image[i] = block.getColor(biomemaps[1][1].get()[i]);
|
||||
lightmap[2*i+1] = (1 - block.blockLight/15.f)*192;
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +264,9 @@ static void makeMap(const std::string ®iondir, const std::string &outputdir,
|
|||
std::unique_ptr<uint8_t[]> lightmap(new uint8_t[2*DIM*DIM]);
|
||||
std::memset(lightmap.get(), 0, 2*DIM*DIM);
|
||||
|
||||
World::Region::visitChunks(input.c_str(), [&] (size_t X, size_t Z, const World::ChunkData *chunk) { addChunk(image.get(), lightmap.get(), X, Z, chunk); });
|
||||
World::Region::visitChunks(input.c_str(), [&] (size_t X, size_t Z, const World::ChunkData *chunk) {
|
||||
addChunk(image.get(), lightmap.get(), X, Z, chunk, biomemaps);
|
||||
});
|
||||
|
||||
writeImage(output, reinterpret_cast<const uint8_t*>(image.get()), PNG::RGB_ALPHA, intime);
|
||||
writeImage(output_light, lightmap.get(), PNG::GRAY_ALPHA, intime);
|
||||
|
|
|
@ -38,10 +38,9 @@ struct Block {
|
|||
const Resource::BlockType *type;
|
||||
unsigned depth;
|
||||
uint8_t blockLight;
|
||||
uint8_t biome;
|
||||
|
||||
|
||||
Resource::Color getColor() const {
|
||||
Resource::Color getColor(uint8_t biome) const {
|
||||
if (!type || !(type->flags & BLOCK_OPAQUE))
|
||||
return Resource::Color {};
|
||||
|
||||
|
|
|
@ -85,7 +85,6 @@ Block Chunk::getBlock(size_t x, Chunk::Height height, size_t z) const {
|
|||
Block block = {};
|
||||
|
||||
block.depth = height.depth;
|
||||
block.biome = getBiome(x, height.y, z);
|
||||
|
||||
size_t Y = height.y / SIZE;
|
||||
size_t y = height.y % SIZE;
|
||||
|
|
Loading…
Add table
Reference in a new issue