Merge with upstream

metadata
Edgar Velazquez-Armendariz 2013-01-23 16:45:27 -05:00
commit f824e5861d
9 changed files with 22 additions and 16 deletions

View File

@ -10,5 +10,5 @@ Exec=mtsgui %U
TryExec=mtsgui TryExec=mtsgui
Terminal=false Terminal=false
StartupNotify=true StartupNotify=true
MimeType=application/xml MimeType=application/xml;image/x-exr;image/x-hdr;
Icon=mitsuba48.png Icon=mitsuba48.png

View File

@ -289,19 +289,17 @@ template <typename T> struct TAABB {
Float t1 = (minVal - origin) * ray.dRcp[i]; Float t1 = (minVal - origin) * ray.dRcp[i];
Float t2 = (maxVal - origin) * ray.dRcp[i]; Float t2 = (maxVal - origin) * ray.dRcp[i];
if (t1 > t2) { if (t1 > t2)
Float tmp = t1; std::swap(t1, t2);
t1 = t2;
t2 = tmp;
}
nearT = std::max(nearT, t1); nearT = std::max(t1, nearT);
farT = std::min(farT, t2); farT = std::min(t2, farT);
if (nearT > farT) if (!(nearT <= farT))
return false; return false;
} }
} }
return true; return true;
} }

View File

@ -196,7 +196,7 @@ public:
if (!m_sceneBSphere.rayIntersect(ray, nearT, farT)) if (!m_sceneBSphere.rayIntersect(ray, nearT, farT))
return Spectrum(0.0f); return Spectrum(0.0f);
if (nearT >= 0 || farT <= 0) if (!(nearT < 0 && farT > 0))
return Spectrum(0.0f); return Spectrum(0.0f);
dRec.p = ray(farT); dRec.p = ray(farT);

View File

@ -114,6 +114,12 @@ bool ShapeKDTree::rayIntersect(const Ray &ray, Intersection &its) const {
its.t = std::numeric_limits<Float>::infinity(); its.t = std::numeric_limits<Float>::infinity();
Float mint, maxt; Float mint, maxt;
#if defined(MTS_FP_DEBUG_STRICT)
Assert(
std::isfinite(ray.o.x) && std::isfinite(ray.o.y) && std::isfinite(ray.o.z) &&
std::isfinite(ray.d.x) && std::isfinite(ray.d.y) && std::isfinite(ray.d.z));
#endif
++raysTraced; ++raysTraced;
if (m_aabb.rayIntersect(ray, mint, maxt)) { if (m_aabb.rayIntersect(ray, mint, maxt)) {
/* Use an adaptive ray epsilon */ /* Use an adaptive ray epsilon */

View File

@ -145,11 +145,12 @@ public:
if (!solveQuadratic(A, B, C, nearT, farT)) if (!solveQuadratic(A, B, C, nearT, farT))
return false; return false;
if (nearT > maxt || farT < mint) if (!(nearT <= maxt && farT >= mint)) /* NaN-aware conditionals */
return false; return false;
const Float zPosNear = ray.o.z + ray.d.z * nearT; const Float zPosNear = ray.o.z + ray.d.z * nearT;
const Float zPosFar = ray.o.z + ray.d.z * farT; const Float zPosFar = ray.o.z + ray.d.z * farT;
if (zPosNear >= 0 && zPosNear <= m_length && nearT >= mint) { if (zPosNear >= 0 && zPosNear <= m_length && nearT >= mint) {
t = nearT; t = nearT;
} else if (zPosFar >= 0 && zPosFar <= m_length) { } else if (zPosFar >= 0 && zPosFar <= m_length) {

View File

@ -136,7 +136,7 @@ public:
m_worldToObject.transformAffine(_ray, ray); m_worldToObject.transformAffine(_ray, ray);
Float hit = -ray.o.z / ray.d.z; Float hit = -ray.o.z / ray.d.z;
if (hit < mint || hit > maxt) if (!(hit >= mint && hit <= maxt))
return false; return false;
Point local = ray(hit); Point local = ray(hit);

View File

@ -504,7 +504,7 @@ public:
if (!solveQuadraticDouble(A, B, C, nearT, farT)) if (!solveQuadraticDouble(A, B, C, nearT, farT))
return false; return false;
if (nearT > maxt || farT < mint) if (!(nearT <= maxt && farT >= mint)) /* NaN-aware conditionals */
return false; return false;
/* Next check the intersection points against the miter planes */ /* Next check the intersection points against the miter planes */
@ -523,7 +523,7 @@ public:
p = Point(rayO + rayD * nearT); p = Point(rayO + rayD * nearT);
t = (Float) nearT; t = (Float) nearT;
} else if (dot(pointFar - v1, n1) >= 0 && } else if (dot(pointFar - v1, n1) >= 0 &&
dot(pointFar - v2, n2) <= 0) { dot(pointFar - v2, n2) <= 0) {
if (farT > maxt) if (farT > maxt)
return false; return false;
p = Point(rayO + rayD * nearT); p = Point(rayO + rayD * nearT);

View File

@ -127,7 +127,7 @@ public:
m_worldToObject.transformAffine(_ray, ray); m_worldToObject.transformAffine(_ray, ray);
Float hit = -ray.o.z / ray.d.z; Float hit = -ray.o.z / ray.d.z;
if (hit < mint || hit > maxt) if (!(hit >= mint && hit <= maxt))
return false; return false;
Point local = ray(hit); Point local = ray(hit);

View File

@ -172,8 +172,9 @@ public:
if (!solveQuadraticDouble(A, B, C, nearT, farT)) if (!solveQuadraticDouble(A, B, C, nearT, farT))
return false; return false;
if (nearT > maxt || farT < mint) if (!(nearT <= maxt && farT >= mint)) /* NaN-aware conditionals */
return false; return false;
if (nearT < mint) { if (nearT < mint) {
if (farT > maxt) if (farT > maxt)
return false; return false;