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

@ -99,11 +99,11 @@ Color Biome::getBlockColor(const BlockType *type, unsigned height) const {
float t = clamp(temp - std::max(0.0f, (height-64)/600.0f), 0, 1);
float r = clamp(rain, 0, 1) * t;
if (type->grass)
if (type->flags & BLOCK_GRASS)
c *= getGrassColor(t, r);
if (type->foliage)
if (type->flags & BLOCK_FOLIAGE)
c *= getFoliageColor(t, r);
if (type->blue)
if (type->flags & BLOCK_WATER)
c *= getWaterColor(t, r);
float h = 0.5f + height * 0.005f;

View file

@ -33,6 +33,11 @@
namespace MinedMap {
namespace Resource {
#define BLOCK_OPAQUE (1u << 0)
#define BLOCK_GRASS (1u << 1)
#define BLOCK_FOLIAGE (1u << 2)
#define BLOCK_WATER (1u << 3)
struct BlockType {
private:
static const std::unordered_map<std::string, BlockType> Types;
@ -40,10 +45,7 @@ private:
public:
static const BlockType * lookup(const std::string &name);
bool opaque;
bool grass;
bool foliage;
bool blue;
uint8_t flags;
struct {
uint8_t r, g, b;
} color;

File diff suppressed because it is too large Load diff