X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgeometry%2Fprimitive.hpp;h=cdeae86e5c68b21303b7c27c775d9ff657df8924;hb=f5de855fbd4bf5b0df1cad950cbe9069e41369ca;hp=351a3a432e1c17d3662b9544012e5c997c22328c;hpb=4fbf5a3c1b0e530706023f5fc4be2f68d30ea645;p=blank.git diff --git a/src/geometry/primitive.hpp b/src/geometry/primitive.hpp index 351a3a4..cdeae86 100644 --- a/src/geometry/primitive.hpp +++ b/src/geometry/primitive.hpp @@ -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,