From 407879c389a4759d1fc386c44e42dfe888000f21 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 30 Nov 2010 22:46:28 +0100 Subject: [PATCH] bugfix attempt #2 for a corner-case in heterogeneous media --- src/medium/heterogeneous-flake.cpp | 8 ++++++-- src/medium/heterogeneous-stencil.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/medium/heterogeneous-flake.cpp b/src/medium/heterogeneous-flake.cpp index 61b55ccf..c0075b0d 100644 --- a/src/medium/heterogeneous-flake.cpp +++ b/src/medium/heterogeneous-flake.cpp @@ -395,7 +395,9 @@ public: } Float integrateDensities(Ray ray, Float length) const { - int nParts = std::max(1, (int) std::ceil(length/m_stepSize)); + if (length == 0) + return 0.0f; + int nParts = (int) std::ceil(length/m_stepSize); nParts += nParts % 2; const Float stepSize = length/nParts; const Vector increment = ray.d * stepSize; @@ -421,8 +423,10 @@ public: Float ¤tSigmaT, Spectrum ¤tAlbedo, Float desiredTau) const { + if (maxDist == 0) + return std::numeric_limits::infinity(); - int nParts = std::max(1, (int) std::ceil(maxDist/m_stepSize)); + int nParts = (int) std::ceil(maxDist/m_stepSize); Float stepSize = maxDist/nParts; Vector fullIncrement = ray.d * stepSize, halfIncrement = fullIncrement * .5f; diff --git a/src/medium/heterogeneous-stencil.cpp b/src/medium/heterogeneous-stencil.cpp index b279e953..8fc7b9e7 100644 --- a/src/medium/heterogeneous-stencil.cpp +++ b/src/medium/heterogeneous-stencil.cpp @@ -199,7 +199,9 @@ public: } Float integrateDensities(Ray ray, Float length) const { - int nParts = std::max(1, (int) std::ceil(length/m_stepSize)); + if (length == 0) + return 0.0f; + int nParts = (int) std::ceil(length/m_stepSize); nParts += nParts % 2; const Float stepSize = length/nParts; const Vector increment = ray.d * stepSize; @@ -225,7 +227,10 @@ public: Float ¤tSigmaT, Spectrum ¤tAlbedo, Float desiredTau) const { - int nParts = std::max(1, (int) std::ceil(maxDist/m_stepSize)); + if (maxDist == 0) + return std::numeric_limits::infinity(); + + int nParts = (int) std::ceil(maxDist/m_stepSize); Float stepSize = maxDist/nParts; Vector fullIncrement = ray.d * stepSize, halfIncrement = fullIncrement * .5f;