BlockType: replace list of booleans with flags bitfield

This commit is contained in:
Matthias Schiffer 2020-06-18 23:38:21 +02:00
parent 446e74791f
commit ef4b6eac02
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
8 changed files with 800 additions and 787 deletions

View file

@ -42,7 +42,7 @@ struct Block {
Resource::Color getColor() const {
if (!type || !type->opaque)
if (!type || !(type->flags & BLOCK_OPAQUE))
return Resource::Color {};
return (Resource::BIOMES[biome] ?: Resource::BIOME_DEFAULT)->getBlockColor(type, height);

View file

@ -84,7 +84,7 @@ bool Chunk::getBlock(Block *block, const Section *section, size_t x, size_t y, s
return false;
const Resource::BlockType *type = section->getBlockStateAt(x, y, z);
if (!type || !type->opaque)
if (!type || !(type->flags & BLOCK_OPAQUE))
return false;
if (!block->type) {
@ -93,7 +93,7 @@ bool Chunk::getBlock(Block *block, const Section *section, size_t x, size_t y, s
block->biome = getBiome(x, y, z);
}
if (type->blue)
if (type->flags & BLOCK_WATER)
return false;
block->height = SIZE*section->getY() + y;