]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Block.hpp
some annotations
[blank.git] / src / world / Block.hpp
index 274e3d3c3120369eb8915c752db357c8b8b80b23..ea3de59b206e3ad7b90b9033db7506037bd24692 100644 (file)
@@ -11,7 +11,6 @@ namespace blank {
 struct Block {
 
        using Type = unsigned short;
-       using Pos = glm::vec3;
 
        enum Face {
                FACE_UP,
@@ -66,6 +65,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 +146,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 &);