fix for ray-vs-AACubeShape intersection test

This commit is contained in:
Andrew Meadows 2014-09-12 08:40:48 -07:00
parent a9957ac7df
commit 825be3e1e7

View file

@ -36,11 +36,12 @@ bool AACubeShape::findRayIntersection(RayIntersectionInfo& intersection) const {
} }
// check for tuncated/short ray // check for tuncated/short ray
const float maxBA = glm::min(intersection._rayLength, intersection._hitDistance) + halfSide; // maxLength = maximum possible distance between rayStart and center of cube
if (maxBA * maxBA > a * a + b2) { const float maxLength = glm::min(intersection._rayLength, intersection._hitDistance) + r;
float maxBA2 = maxLength * maxLength;
if (a * a + b2 > maxLength * maxLength) {
// ray is not long enough to reach cube's bounding sphere // ray is not long enough to reach cube's bounding sphere
// NOTE: we don't fall in here when ray's length if FLT_MAX because maxBA^2 will be NaN // NOTE: we don't fall in here when ray's length if FLT_MAX because maxLength^2 will be inf or nan
// and all NaN comparisons are false
return false; return false;
} }