X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgeometry%2Fprimitive.hpp;h=72da84749140ca6f2d6b2c71a069c3fd9c031199;hb=ab0ba4313c473378b4516e3702d524dc1d1fc5d4;hp=da4c37f1e03296d254d55f051d5e199f94132a9c;hpb=6513b55584093a86ce1e369e054263dd75c295c8;p=blank.git diff --git a/src/geometry/primitive.hpp b/src/geometry/primitive.hpp index da4c37f..72da847 100644 --- a/src/geometry/primitive.hpp +++ b/src/geometry/primitive.hpp @@ -31,13 +31,29 @@ struct AABB { std::ostream &operator <<(std::ostream &, const AABB &); +// TODO: this should really use setters/getters for dir and inv_dir so +// manipulating code doesn't "forget" to call Update() struct Ray { glm::vec3 orig; glm::vec3 dir; + + glm::vec3 inv_dir; + + void Update() noexcept { + inv_dir = 1.0f / dir; + } }; std::ostream &operator <<(std::ostream &, const Ray &); +/// axis aligned boolean ray/box intersection test +/// if true, dist constains distance from ray's origin to intersection point +bool Intersection( + const Ray &, + const AABB &, + float &dist) noexcept; + +/// detailed oriented ray/box intersection test bool Intersection( const Ray &, const AABB &,