]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Chunk.hpp
make stderr visible in standalone test
[blank.git] / src / world / Chunk.hpp
index 045f58df7d6ac29f1140fea27849cc212aea5e30..97765677e021be36cc0f863af7ca882b973c6820 100644 (file)
@@ -5,10 +5,10 @@
 #include "BlockTypeRegistry.hpp"
 #include "../geometry/Location.hpp"
 #include "../geometry/primitive.hpp"
+#include "../graphics/glm.hpp"
 
 #include <set>
 #include <vector>
-#include <glm/glm.hpp>
 #include <glm/gtx/transform.hpp>
 
 
@@ -55,6 +55,9 @@ public:
                        pos.y >= 0 && pos.y < side &&
                        pos.z >= 0 && pos.z < side;
        }
+       static int ToIndex(const ExactLocation::Fine &pos) noexcept {
+               return ToIndex(RoughLocation::Fine(pos));
+       }
        static constexpr int ToIndex(const RoughLocation::Fine &pos) noexcept {
                return pos.x + pos.y * side + pos.z * side * side;
        }
@@ -144,6 +147,8 @@ public:
        /// get gravity for one unit mass at given point
        glm::vec3 GravityAt(const ExactLocation &) const noexcept;
 
+       /// check if given ray passes this chunk at all
+       /// given reference indicates the chunk offset of the ray in world space
        bool Intersection(
                const Ray &ray,
                const ExactLocation::Coarse &reference,
@@ -153,12 +158,13 @@ public:
        }
 
        /// check if given ray intersects any block of this chunk
-       /// given reference indicated the chunk offset of the ray in world space
+       /// given reference indicates the chunk offset of the ray in world space
        bool Intersection(
                const Ray &,
                const ExactLocation::Coarse &reference,
                WorldCollision &) noexcept;
 
+       /// get all blocks intersecting given box
        bool Intersection(
                const AABB &box,
                const glm::mat4 &Mbox,
@@ -175,7 +181,7 @@ public:
        const ExactLocation::Coarse &Position() const noexcept { return position; }
 
        glm::mat4 Transform(const ExactLocation::Coarse &offset) const noexcept {
-               return glm::translate((position - offset) * ExactLocation::Extent());
+               return glm::translate(ExactLocation::Fine((position - offset) * ExactLocation::Extent()));
        }
 
        void *BlockData() noexcept { return &blocks[0]; }