mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
Chunk: replace withDepth argument with extensible flags field
This commit is contained in:
parent
fdce587c74
commit
38d8bd0738
3 changed files with 12 additions and 9 deletions
|
@ -56,7 +56,7 @@ static const size_t DIM = World::Region::SIZE*World::Chunk::SIZE;
|
|||
|
||||
static void addChunkBiome(uint8_t biomemap[DIM*DIM], size_t X, size_t Z, const World::ChunkData *data) {
|
||||
World::Chunk chunk(data);
|
||||
World::Chunk::Heightmap layer = chunk.getTopLayer(false);
|
||||
World::Chunk::Heightmap layer = chunk.getTopLayer(0);
|
||||
|
||||
for (size_t x = 0; x < World::Chunk::SIZE; x++) {
|
||||
for (size_t z = 0; z < World::Chunk::SIZE; z++) {
|
||||
|
@ -127,7 +127,7 @@ static void addChunk(Resource::Color image[DIM*DIM], uint8_t lightmap[2*DIM*DIM]
|
|||
const World::ChunkData *data, const std::unique_ptr<uint8_t[]> biomemaps[3][3]
|
||||
) {
|
||||
World::Chunk chunk(data);
|
||||
World::Chunk::Heightmap layer = chunk.getTopLayer(true);
|
||||
World::Chunk::Heightmap layer = chunk.getTopLayer(World::Chunk::WITH_DEPTH);
|
||||
|
||||
for (size_t x = 0; x < World::Chunk::SIZE; x++) {
|
||||
for (size_t z = 0; z < World::Chunk::SIZE; z++) {
|
||||
|
|
|
@ -101,11 +101,11 @@ Block Chunk::getBlock(size_t x, Chunk::Height height, size_t z) const {
|
|||
return block;
|
||||
}
|
||||
|
||||
bool Chunk::getHeight(Chunk::Height *height, const Section *section, size_t x, size_t y, size_t z, bool withDepth) const {
|
||||
bool Chunk::getHeight(Chunk::Height *height, const Section *section, size_t x, size_t y, size_t z, int flags) const {
|
||||
if (height->depth > 0)
|
||||
return false;
|
||||
|
||||
if (!withDepth && height->y > 0)
|
||||
if (!(flags & WITH_DEPTH) && height->y > 0)
|
||||
return false;
|
||||
|
||||
const Resource::BlockType *type = section->getBlockStateAt(x, y, z);
|
||||
|
@ -115,7 +115,7 @@ bool Chunk::getHeight(Chunk::Height *height, const Section *section, size_t x, s
|
|||
if (height->y == 0)
|
||||
height->y = SIZE*section->getY() + y;
|
||||
|
||||
if (!withDepth)
|
||||
if (!(flags & WITH_DEPTH))
|
||||
return true;
|
||||
|
||||
if (type->flags & BLOCK_WATER)
|
||||
|
@ -126,7 +126,7 @@ bool Chunk::getHeight(Chunk::Height *height, const Section *section, size_t x, s
|
|||
return true;
|
||||
}
|
||||
|
||||
Chunk::Heightmap Chunk::getTopLayer(bool withDepth) const {
|
||||
Chunk::Heightmap Chunk::getTopLayer(int flags) const {
|
||||
size_t done = 0;
|
||||
Heightmap ret = {};
|
||||
|
||||
|
@ -145,7 +145,7 @@ Chunk::Heightmap Chunk::getTopLayer(bool withDepth) const {
|
|||
|
||||
for (size_t z = 0; z < SIZE; z++) {
|
||||
for (size_t x = 0; x < SIZE; x++) {
|
||||
if (getHeight(&ret.v[x][z], section, x, y, z, withDepth))
|
||||
if (getHeight(&ret.v[x][z], section, x, y, z, flags))
|
||||
done++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
static const size_t BSIZE = SIZE / BGROUP;
|
||||
static const size_t BMAXY = MAXY / BGROUP;
|
||||
|
||||
// Flags
|
||||
static const int WITH_DEPTH = (1 << 0);
|
||||
|
||||
struct Height {
|
||||
unsigned y;
|
||||
unsigned depth;
|
||||
|
@ -67,7 +70,7 @@ private:
|
|||
std::shared_ptr<const NBT::IntArrayTag> biomeIntsPre115;
|
||||
std::shared_ptr<const NBT::IntArrayTag> biomeInts;
|
||||
|
||||
bool getHeight(Height *height, const Section *section, size_t x, size_t y, size_t z, bool withDepth) const;
|
||||
bool getHeight(Height *height, const Section *section, size_t x, size_t y, size_t z, int flags) const;
|
||||
|
||||
const Resource::BlockType * getBlockStateAt(size_t x, size_t y, size_t z) const {
|
||||
size_t Y = y / SIZE;
|
||||
|
@ -89,7 +92,7 @@ public:
|
|||
uint8_t getBiome(size_t x, size_t y, size_t z) const;
|
||||
Block getBlock(size_t x, Height y, size_t z) const;
|
||||
|
||||
Heightmap getTopLayer(bool withDepth) const;
|
||||
Heightmap getTopLayer(int flags) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue