make intersection routines more robust vs NaNs
parent
b25a662f23
commit
93ed76211e
|
@ -196,7 +196,7 @@ public:
|
|||
if (!m_sceneBSphere.rayIntersect(ray, nearT, farT))
|
||||
return Spectrum(0.0f);
|
||||
|
||||
if (nearT >= 0 || farT <= 0)
|
||||
if (!(nearT < 0 && farT > 0))
|
||||
return Spectrum(0.0f);
|
||||
|
||||
dRec.p = ray(farT);
|
||||
|
|
|
@ -145,11 +145,12 @@ public:
|
|||
if (!solveQuadratic(A, B, C, nearT, farT))
|
||||
return false;
|
||||
|
||||
if (nearT > maxt || farT < mint)
|
||||
if (!(nearT <= maxt && farT >= mint)) /* NaN-aware conditionals */
|
||||
return false;
|
||||
|
||||
const Float zPosNear = ray.o.z + ray.d.z * nearT;
|
||||
const Float zPosFar = ray.o.z + ray.d.z * farT;
|
||||
|
||||
if (zPosNear >= 0 && zPosNear <= m_length && nearT >= mint) {
|
||||
t = nearT;
|
||||
} else if (zPosFar >= 0 && zPosFar <= m_length) {
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
m_worldToObject.transformAffine(_ray, ray);
|
||||
Float hit = -ray.o.z / ray.d.z;
|
||||
|
||||
if (hit < mint || hit > maxt)
|
||||
if (!(hit >= mint && hit <= maxt))
|
||||
return false;
|
||||
|
||||
Point local = ray(hit);
|
||||
|
|
|
@ -504,7 +504,7 @@ public:
|
|||
if (!solveQuadraticDouble(A, B, C, nearT, farT))
|
||||
return false;
|
||||
|
||||
if (nearT > maxt || farT < mint)
|
||||
if (!(nearT <= maxt && farT >= mint)) /* NaN-aware conditionals */
|
||||
return false;
|
||||
|
||||
/* Next check the intersection points against the miter planes */
|
||||
|
@ -523,7 +523,7 @@ public:
|
|||
p = Point(rayO + rayD * nearT);
|
||||
t = (Float) nearT;
|
||||
} else if (dot(pointFar - v1, n1) >= 0 &&
|
||||
dot(pointFar - v2, n2) <= 0) {
|
||||
dot(pointFar - v2, n2) <= 0) {
|
||||
if (farT > maxt)
|
||||
return false;
|
||||
p = Point(rayO + rayD * nearT);
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
m_worldToObject.transformAffine(_ray, ray);
|
||||
Float hit = -ray.o.z / ray.d.z;
|
||||
|
||||
if (hit < mint || hit > maxt)
|
||||
if (!(hit >= mint && hit <= maxt))
|
||||
return false;
|
||||
|
||||
Point local = ray(hit);
|
||||
|
|
|
@ -172,8 +172,9 @@ public:
|
|||
if (!solveQuadraticDouble(A, B, C, nearT, farT))
|
||||
return false;
|
||||
|
||||
if (nearT > maxt || farT < mint)
|
||||
if (!(nearT <= maxt && farT >= mint)) /* NaN-aware conditionals */
|
||||
return false;
|
||||
|
||||
if (nearT < mint) {
|
||||
if (farT > maxt)
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue