]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Block.hpp
ubuntu latest and devel docker images
[blank.git] / src / world / Block.hpp
index 5f52d173882903af05a8346561842d0f77006f52..2eac5ff6ca13b688ad1892ec879181e87ce26bef 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef BLANK_WORLD_BLOCK_HPP_
 #define BLANK_WORLD_BLOCK_HPP_
 
+#include "../graphics/glm.hpp"
+
 #include <iosfwd>
-#include <glm/glm.hpp>
 
 
 namespace blank {
@@ -11,7 +12,6 @@ namespace blank {
 struct Block {
 
        using Type = unsigned short;
-       using Pos = glm::vec3;
 
        enum Face {
                FACE_UP,
@@ -66,12 +66,28 @@ 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];
        }
 
        static Face NormalFace(const glm::vec3 &norm) noexcept {
-               const glm::vec3 anorm(abs(norm));
+               const glm::vec3 anorm(glm::abs(norm));
                if (anorm.x > anorm.y) {
                        if (anorm.x > anorm.z) {
                                return norm.x > 0.0f ? FACE_RIGHT : FACE_LEFT;