diff --git a/src/libcore/vmf.cpp b/src/libcore/vmf.cpp index 224a2512..8f1830df 100644 --- a/src/libcore/vmf.cpp +++ b/src/libcore/vmf.cpp @@ -45,8 +45,13 @@ Vector VonMisesFisherDistr::sample(const Point2 &sample) const { sample.x * std::sinh(m_kappa)) / m_kappa; #else /* Numerically stable version */ - Float cosTheta = 1 + (math::fastlog(sample.x) + math::fastlog( - 1 - math::fastexp(-2*m_kappa) * ((sample.x-1) / sample.x))) / m_kappa; + Float cosTheta; + if (sample.x > 0) { + cosTheta = 1 + (math::fastlog(sample.x) + math::fastlog( + 1 - math::fastexp(-2*m_kappa) * ((sample.x-1) / sample.x))) / m_kappa; + } else { + cosTheta = 1 + math::fastexp(-2*m_kappa) / m_kappa; + } #endif Float sinTheta = math::safe_sqrt(1-cosTheta*cosTheta), diff --git a/src/librender/skdtree.cpp b/src/librender/skdtree.cpp index 83fad551..236b72c0 100644 --- a/src/librender/skdtree.cpp +++ b/src/librender/skdtree.cpp @@ -128,11 +128,6 @@ bool ShapeKDTree::rayIntersect(const Ray &ray, Intersection &its) const { if (EXPECT_TAKEN(maxt > mint)) { if (rayIntersectHavran(ray, mint, maxt, its.t, temp)) { fillIntersectionRecord(ray, temp, its); - if (std::isnan(its.t)) { - cout << ray.toString() << endl; - cout << its.toString() << endl; - Log(EError, "Whaat?!"); - } return true; } }