fixed a rare corner case in the vMF sampling code

metadata
Wenzel Jakob 2012-10-12 18:54:57 -04:00
parent 5baddc030a
commit 4d2ff81b1a
2 changed files with 7 additions and 7 deletions

View File

@ -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),

View File

@ -128,11 +128,6 @@ bool ShapeKDTree::rayIntersect(const Ray &ray, Intersection &its) const {
if (EXPECT_TAKEN(maxt > mint)) {
if (rayIntersectHavran<false>(ray, mint, maxt, its.t, temp)) {
fillIntersectionRecord<true>(ray, temp, its);
if (std::isnan(its.t)) {
cout << ray.toString() << endl;
cout << its.toString() << endl;
Log(EError, "Whaat?!");
}
return true;
}
}