From f531af3e2dae42dbb2943a2917fd325cac089ba8 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 19 Oct 2010 19:19:12 +0200 Subject: [PATCH] fix fast-math kd-tree building problem on windows --- include/mitsuba/render/gkdtree.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/mitsuba/render/gkdtree.h b/include/mitsuba/render/gkdtree.h index 59a00cd2..e40ace7a 100644 --- a/include/mitsuba/render/gkdtree.h +++ b/include/mitsuba/render/gkdtree.h @@ -430,6 +430,10 @@ private: size_t m_bufferSize; }; +#if defined(WIN32) +#pragma float_control(precise, on) +#endif + /** * \brief SAH KD-tree acceleration data structure for fast ray-object * intersection computations. @@ -2694,7 +2698,7 @@ protected: /* Floating-point arithmetic.. - use both absolute and relative epsilons when looking for intersections in the subinterval */ #if defined(SINGLE_PRECISION) - const Float eps = 1e-3; + const Float eps = 1e-3f; #else const Float eps = 1e-5; #endif @@ -2825,7 +2829,7 @@ protected: } #if defined(SINGLE_PRECISION) - const Float eps = 1e-3; + const Float eps = 1e-3f; #else const Float eps = 1e-5; #endif @@ -3082,9 +3086,9 @@ template void GenericKDTree::findCosts( Point p2 = bsphere.center + squareToSphere(sample2) * bsphere.radius; Ray ray(p1, normalize(p2-p1)); Float mint, maxt, t; - if (ray.mint > mint) mint = ray.mint; - if (ray.maxt < maxt) maxt = ray.maxt; if (m_aabb.rayIntersect(ray, mint, maxt)) { + if (ray.mint > mint) mint = ray.mint; + if (ray.maxt < maxt) maxt = ray.maxt; if (EXPECT_TAKEN(maxt > mint)) { boost::tuple statistics = rayIntersectHavranCollectStatistics(ray, mint, maxt, t, temp); @@ -3159,6 +3163,11 @@ template const Class *GenericKDTree::getClass() cons return m_theClass; } +#if defined(WIN32) +#pragma float_control(precise, off) +#endif + + MTS_NAMESPACE_END #endif /* __KDTREE_GENERIC_H */