}
+namespace {
+
+const Block::Face face_map[Block::FACE_COUNT * Block::TURN_COUNT][Block::FACE_COUNT] = {
+ { Block::FACE_UP, Block::FACE_DOWN, Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_FRONT, Block::FACE_BACK, }, // face: up, turn: none x
+ { Block::FACE_UP, Block::FACE_DOWN, Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_LEFT, Block::FACE_RIGHT, }, // face: up, turn: left
+ { Block::FACE_UP, Block::FACE_DOWN, Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_BACK, Block::FACE_FRONT, }, // face: up, turn: around
+ { Block::FACE_UP, Block::FACE_DOWN, Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_RIGHT, Block::FACE_LEFT, }, // face: up, turn: right
+ { Block::FACE_DOWN, Block::FACE_UP, Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_BACK, Block::FACE_FRONT, }, // face: down, turn: none
+ { Block::FACE_DOWN, Block::FACE_UP, Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_LEFT, Block::FACE_RIGHT, }, // face: down, turn: left
+ { Block::FACE_DOWN, Block::FACE_UP, Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_FRONT, Block::FACE_BACK, }, // face: down, turn: around
+ { Block::FACE_DOWN, Block::FACE_UP, Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_RIGHT, Block::FACE_LEFT, }, // face: down, turn: right
+ { Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_UP, Block::FACE_DOWN, Block::FACE_FRONT, Block::FACE_BACK, }, // face: right, turn: none
+ { Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_DOWN, Block::FACE_UP, }, // face: right, turn: left
+ { Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_DOWN, Block::FACE_UP, Block::FACE_BACK, Block::FACE_FRONT, }, // face: right, turn: around
+ { Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_UP, Block::FACE_DOWN, }, // face: right, turn: right
+ { Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_DOWN, Block::FACE_UP, Block::FACE_FRONT, Block::FACE_BACK, }, // face: left, turn: none
+ { Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_UP, Block::FACE_DOWN, }, // face: left, turn: left
+ { Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_UP, Block::FACE_DOWN, Block::FACE_BACK, Block::FACE_FRONT, }, // face: left, turn: around
+ { Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_DOWN, Block::FACE_UP, }, // face: left, turn: right
+ { Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_UP, Block::FACE_DOWN, }, // face: front, turn: none
+ { Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_UP, Block::FACE_DOWN, Block::FACE_LEFT, Block::FACE_RIGHT, }, // face: front, turn: left
+ { Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_DOWN, Block::FACE_UP, }, // face: front, turn: around
+ { Block::FACE_BACK, Block::FACE_FRONT, Block::FACE_DOWN, Block::FACE_UP, Block::FACE_RIGHT, Block::FACE_LEFT, }, // face: front, turn: right
+ { Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_RIGHT, Block::FACE_LEFT, Block::FACE_DOWN, Block::FACE_UP, }, // face: back, turn: none
+ { Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_DOWN, Block::FACE_UP, Block::FACE_LEFT, Block::FACE_RIGHT, }, // face: back, turn: left
+ { Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_LEFT, Block::FACE_RIGHT, Block::FACE_UP, Block::FACE_DOWN, }, // face: back, turn: around
+ { Block::FACE_FRONT, Block::FACE_BACK, Block::FACE_UP, Block::FACE_DOWN, Block::FACE_RIGHT, Block::FACE_LEFT, }, // face: back, turn: right
+};
+
+}
+
+bool BlockType::FaceFilled(const Block &block, Block::Face face) const {
+ return fill[face_map[block.orient][face]];
+}
+
void BlockType::FillModel(
Model::Buffer &buf,
const glm::mat4 &transform,
// invisible blocks must have their fill set to 6x false
// (the default, so should be okay)
- const BlockType &right = Type(blocks[idx + 1]);
- if (!right.fill.left) return false;
+ const Block &right = blocks[idx + 1];
+ if (!Type(right).FaceFilled(right, Block::FACE_LEFT)) return false;
- const BlockType &left = Type(blocks[idx - 1]);
- if (!left.fill.right) return false;
+ const Block &left = blocks[idx - 1];
+ if (!Type(left).FaceFilled(left, Block::FACE_RIGHT)) return false;
- const BlockType &up = Type(blocks[idx + Width()]);
- if (!up.fill.down) return false;
+ const Block &up = blocks[idx + Width()];
+ if (!Type(up).FaceFilled(up, Block::FACE_DOWN)) return false;
- const BlockType &down = Type(blocks[idx - Width()]);
- if (!down.fill.up) return false;
+ const Block &down = blocks[idx - Width()];
+ if (!Type(down).FaceFilled(down, Block::FACE_UP)) return false;
- const BlockType &front = Type(blocks[idx + Width() * Height()]);
- if (!front.fill.back) return false;
+ const Block &front = blocks[idx + Width() * Height()];
+ if (!Type(front).FaceFilled(front, Block::FACE_BACK)) return false;
- const BlockType &back = Type(blocks[idx - Width() * Height()]);
- if (!back.fill.front) return false;
+ const Block &back = blocks[idx - Width() * Height()];
+ if (!Type(back).FaceFilled(back, Block::FACE_FRONT)) return false;
return true;
}