]> git.localhorst.tv Git - blank.git/blobdiff - src/geometry/primitive.hpp
fix box/box normal
[blank.git] / src / geometry / primitive.hpp
index 351a3a432e1c17d3662b9544012e5c997c22328c..cdeae86e5c68b21303b7c27c775d9ff657df8924 100644 (file)
@@ -20,6 +20,12 @@ struct AABB {
        glm::vec3 Center() const noexcept {
                return min + (max - min) * 0.5f;
        }
+
+       /// return distance between origin and farthest vertex
+       float OriginRadius() const noexcept {
+               glm::vec3 high(glm::max(abs(min), abs(max)));
+               return length(high);
+       }
 };
 
 struct Ray {
@@ -34,6 +40,8 @@ bool Intersection(
        float *dist = nullptr,
        glm::vec3 *normal = nullptr) noexcept;
 
+/// matrices may translate and rotate, but must not scale/shear/etc
+/// (basically the first three columns must have unit length)
 bool Intersection(
        const AABB &a_box,
        const glm::mat4 &a_m,