From b25a662f23090d18a9c63f687cd1bb54a67fe7d7 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 22 Jan 2013 14:25:59 -0500 Subject: [PATCH 1/3] mitsuba.desktop: bindings for further MIME types --- data/linux/mitsuba.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/linux/mitsuba.desktop b/data/linux/mitsuba.desktop index 80b80205..6da83eaf 100644 --- a/data/linux/mitsuba.desktop +++ b/data/linux/mitsuba.desktop @@ -10,5 +10,5 @@ Exec=mtsgui %U TryExec=mtsgui Terminal=false StartupNotify=true -MimeType=application/xml +MimeType=application/xml;image/x-exr;image/x-hdr; Icon=mitsuba48.png From 93ed76211eec2660c27b4e26d3099cb001f3529b Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 22 Jan 2013 19:33:08 -0500 Subject: [PATCH 2/3] make intersection routines more robust vs NaNs --- src/emitters/constant.cpp | 2 +- src/shapes/cylinder.cpp | 3 ++- src/shapes/disk.cpp | 2 +- src/shapes/hair.cpp | 4 ++-- src/shapes/rectangle.cpp | 2 +- src/shapes/sphere.cpp | 3 ++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/emitters/constant.cpp b/src/emitters/constant.cpp index 3c391bf2..f1909c2d 100644 --- a/src/emitters/constant.cpp +++ b/src/emitters/constant.cpp @@ -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); diff --git a/src/shapes/cylinder.cpp b/src/shapes/cylinder.cpp index 83af281a..27139b0a 100644 --- a/src/shapes/cylinder.cpp +++ b/src/shapes/cylinder.cpp @@ -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) { diff --git a/src/shapes/disk.cpp b/src/shapes/disk.cpp index e4b2d429..fac35568 100644 --- a/src/shapes/disk.cpp +++ b/src/shapes/disk.cpp @@ -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); diff --git a/src/shapes/hair.cpp b/src/shapes/hair.cpp index b98b0eae..411b7db0 100644 --- a/src/shapes/hair.cpp +++ b/src/shapes/hair.cpp @@ -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); diff --git a/src/shapes/rectangle.cpp b/src/shapes/rectangle.cpp index e5056a9e..553bbf17 100644 --- a/src/shapes/rectangle.cpp +++ b/src/shapes/rectangle.cpp @@ -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); diff --git a/src/shapes/sphere.cpp b/src/shapes/sphere.cpp index 0b644d19..522743e2 100644 --- a/src/shapes/sphere.cpp +++ b/src/shapes/sphere.cpp @@ -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; From 0f81f051941ac7464ff3998591e225e403d8af05 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 22 Jan 2013 20:39:39 -0500 Subject: [PATCH 3/3] further robustness improvements --- include/mitsuba/core/aabb.h | 14 ++++++-------- src/librender/skdtree.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/mitsuba/core/aabb.h b/include/mitsuba/core/aabb.h index 38396aae..3e9db7f4 100644 --- a/include/mitsuba/core/aabb.h +++ b/include/mitsuba/core/aabb.h @@ -289,19 +289,17 @@ template struct TAABB { Float t1 = (minVal - origin) * ray.dRcp[i]; Float t2 = (maxVal - origin) * ray.dRcp[i]; - if (t1 > t2) { - Float tmp = t1; - t1 = t2; - t2 = tmp; - } + if (t1 > t2) + std::swap(t1, t2); - nearT = std::max(nearT, t1); - farT = std::min(farT, t2); + nearT = std::max(t1, nearT); + farT = std::min(t2, farT); - if (nearT > farT) + if (!(nearT <= farT)) return false; } } + return true; } diff --git a/src/librender/skdtree.cpp b/src/librender/skdtree.cpp index 5de789e8..dcc01cfb 100644 --- a/src/librender/skdtree.cpp +++ b/src/librender/skdtree.cpp @@ -114,6 +114,12 @@ bool ShapeKDTree::rayIntersect(const Ray &ray, Intersection &its) const { its.t = std::numeric_limits::infinity(); 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; if (m_aabb.rayIntersect(ray, mint, maxt)) { /* Use an adaptive ray epsilon */