diff --git a/include/intersections.h b/include/intersections.h index 2e2cd57..2075c56 100644 --- a/include/intersections.h +++ b/include/intersections.h @@ -4,7 +4,7 @@ #include "ray.h" -constexpr float epsilon = std::numeric_limits().epsilon(); +constexpr float epsilon = std::numeric_limits::epsilon(); namespace intersections { inline bool ray_sphere(const Ray ray, const glm::vec4 sphere) { @@ -30,20 +30,20 @@ namespace intersections { float& t, float& u, float& v) { - glm::vec3 e1 = v1 - v0; - glm::vec3 e2 = v2 - v0; + const glm::vec3 e1 = v1 - v0; + const glm::vec3 e2 = v2 - v0; - glm::vec3 pvec = glm::cross(ray.direction, e2); - float det = glm::dot(e1, pvec); + const glm::vec3 pvec = glm::cross(ray.direction, e2); + const float det = glm::dot(e1, pvec); // if determinant is zero then ray is // parallel with the triangle plane if (det > -epsilon && det < epsilon) return false; - float invdet = 1.0 / det; + const float invdet = 1.0 / det; // calculate distance from m[0] to origin - glm::vec3 tvec = ray.origin - v0; + const glm::vec3 tvec = ray.origin - v0; // u and v are the barycentric coordinates // in triangle if u >= 0, v >= 0 and u + v <= 1 @@ -53,7 +53,7 @@ namespace intersections { if (u < 0.0 || u > 1.0) return false; - glm::vec3 qvec = glm::cross(tvec, e1); + const glm::vec3 qvec = glm::cross(tvec, e1); v = glm::dot(ray.direction, qvec) * invdet; // check against other edges