#ifndef TACOS_PHYSICS_RAY_HPP_
#define TACOS_PHYSICS_RAY_HPP_
+#include <limits>
#include <glm/glm.hpp>
glm::vec3 origin;
glm::vec3 direction;
+ glm::vec3 InverseDirection() const noexcept {
+ return glm::vec3(
+ std::fabs(direction.x) < std::numeric_limits<float>::epsilon()
+ ? std::numeric_limits<float>::infinity()
+ : 1.0f / direction.x,
+ std::fabs(direction.y) < std::numeric_limits<float>::epsilon()
+ ? std::numeric_limits<float>::infinity()
+ : 1.0f / direction.y,
+ std::fabs(direction.z) < std::numeric_limits<float>::epsilon()
+ ? std::numeric_limits<float>::infinity()
+ : 1.0f / direction.z);
+ }
+
};
+/// check whether given ray intersects with the triangle with vertices p0, p1, and p2
+/// point of intersection is writte to point if the result is positive
+bool TriangleIntersection(
+ const Ray &ray,
+ const glm::vec3 &p0,
+ const glm::vec3 &p1,
+ const glm::vec3 &p2,
+ glm::vec3 &point) noexcept;
+
}
#endif