]> git.localhorst.tv Git - blank.git/blobdiff - src/model/geometry.hpp
figure out depth and normal in box/box test
[blank.git] / src / model / geometry.hpp
index f4498f5fa743ec734edc84aa90a87eb1d55757ab..df45fff2f2a2797d789b06b9bd2ad71feb3c6464 100644 (file)
@@ -22,6 +22,10 @@ struct AABB {
                if (max.y < min.y) std::swap(max.y, min.y);
                if (max.z < min.z) std::swap(max.z, min.z);
        }
+
+       glm::vec3 Center() const noexcept {
+               return min + (max - min) * 0.5f;
+       }
 };
 
 struct Ray {
@@ -40,7 +44,9 @@ bool Intersection(
        const AABB &a_box,
        const glm::mat4 &a_m,
        const AABB &b_box,
-       const glm::mat4 &b_m) noexcept;
+       const glm::mat4 &b_m,
+       float &depth,
+       glm::vec3 &normal) noexcept;
 
 bool CullTest(const AABB &box, const glm::mat4 &MVP) noexcept;