X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FBlock.hpp;h=4b4ea210596bbd8d3c6adb0f63e5131cf6065708;hb=dbfcb12348b80e2582f710acb1e4ed0011889ba2;hp=274e3d3c3120369eb8915c752db357c8b8b80b23;hpb=549646ac3e5bede5e77031f773649edf8de83608;p=blank.git diff --git a/src/world/Block.hpp b/src/world/Block.hpp index 274e3d3..4b4ea21 100644 --- a/src/world/Block.hpp +++ b/src/world/Block.hpp @@ -66,6 +66,22 @@ struct Block { } } + /// returns 1 for pro-axis, -1 for retro-axis, 0 for invalid faces + static int Direction(Face f) noexcept { + switch (f) { + case FACE_RIGHT: + case FACE_UP: + case FACE_FRONT: + return 1; + case FACE_LEFT: + case FACE_DOWN: + case FACE_BACK: + return -1; + default: + return 0; + } + } + static glm::ivec3 FaceNormal(Face face) noexcept { return face2normal[face]; } @@ -131,7 +147,13 @@ private: }; -bool operator ==(const Block &, const Block &); +inline bool operator ==(const Block &a, const Block &b) { + return a.type == b.type && a.orient == b.orient; +} + +inline bool operator !=(const Block &a, const Block &b) { + return !(a == b); +} std::ostream &operator <<(std::ostream &, const Block &); std::ostream &operator <<(std::ostream &, const Block::Face &);