#include "common/utils/Face.h" Face Face::FACES[6] = { Face(0, 0, 1, 0, 1, "Up"), Face(1, 1, 0, 0, 2, "North"), Face(2, 0, 0, 1, 4, "East"), Face(3, 0, -1, 0, 8, "Down"), Face(4, -1, 0, 0, 16, "South"), Face(5, 0, 0, -1, 32, "West") }; Face& Face::UP = FACES[0]; Face& Face::DOWN = FACES[3]; Face& Face::NORTH = FACES[1]; Face& Face::SOUTH = FACES[4]; Face& Face::EAST = FACES[2]; Face& Face::WEST = FACES[5]; int Face::getCullData(bool up, bool down, bool north, bool south, bool east, bool west) { return (up * 1) | (down * 8) | (north * 2) | (south * 16) | (east * 4) | (west * 32); } Face::Face(int index, int offsetX, int offsetY, int offsetZ, int cullBit, const char* name) : index(index), offsetX(offsetX), offsetY(offsetY), offsetZ(offsetZ), cullBit(cullBit), name(name) { } int Face::getX() const { return offsetX; } int Face::getY() const { return offsetY; } int Face::getZ() const { return offsetZ; } Face& Face::getOpposite() const { return FACES[(index + 3) % 6]; } const char* Face::getName() const { return name; } int Face::getCullData() const { return cullBit; } void Face::forEach(void* data, void (*fun) (Face&, void*)) { for(int i = 0; i < 6; i++) { fun(FACES[i], data); } } bool operator==(const Face& l, const Face& r) { return &l == &r; } bool operator!=(const Face& l, const Face& r) { return &l != &r; } std::ostream& operator<<(std::ostream& os, const Face& f) { os << f.getName(); return os; }