better edge case handling
This commit is contained in:
@@ -49,11 +49,11 @@ float Distance(const Ray& ray, const AABB& aabb) {
|
||||
// (as a result of 0.0 / 0.0). If all coordinates are NAN, this means
|
||||
// that the box is reduced to a point and the ray has direction 0,
|
||||
// in which case this returns -1
|
||||
if (tmax < 0.0f || tmin > tmax) {
|
||||
return -1.0f;
|
||||
if (tmax >= 0.0f && tmin <= tmax) {
|
||||
return std::fmaxf(tmin, 0.0f);
|
||||
}
|
||||
|
||||
return std::fmaxf(tmin, 0.0f);
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
bool Intersects(const Ray& ray, const AABB& aabb) {
|
||||
|
||||
Reference in New Issue
Block a user