Fixed wrong paths and added an outDistance to RayVsAABB.

This commit is contained in:
William Moberg
2015-12-03 17:24:53 +01:00
parent abb61d2cd6
commit af5b3a9302
4 changed files with 18 additions and 8 deletions
+7
View File
@@ -32,6 +32,12 @@ bool RayAABBIntr(const Ray& ray, const AABB& box)
}
bool RayVsAABB(const Ray& ray, const AABB& box)
{
float dummy;
return RayVsAABB(ray, box, dummy);
}
bool RayVsAABB(const Ray& ray, const AABB& box, float& outDistance)
{
glm::vec3 invdir = 1.0f / ray.Direction;
@@ -48,6 +54,7 @@ bool RayVsAABB(const Ray& ray, const AABB& box)
if (tmax < 0 || tmin > tmax)
return false;
outDistance = (tmin > 0) ? tmin : tmax;
return true;
}