diff --git a/src/medium/heterogeneous-flake.cpp b/src/medium/heterogeneous-flake.cpp index 55289f19..61b55ccf 100644 --- a/src/medium/heterogeneous-flake.cpp +++ b/src/medium/heterogeneous-flake.cpp @@ -395,7 +395,7 @@ public: } Float integrateDensities(Ray ray, Float length) const { - int nParts = (int) std::ceil(length/m_stepSize); + int nParts = std::max(1, (int) std::ceil(length/m_stepSize)); nParts += nParts % 2; const Float stepSize = length/nParts; const Vector increment = ray.d * stepSize; @@ -422,7 +422,7 @@ public: Spectrum ¤tAlbedo, Float desiredTau) const { - int nParts = (int) std::ceil(maxDist/m_stepSize); + int nParts = std::max(1, (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 f39cfbfe..b279e953 100644 --- a/src/medium/heterogeneous-stencil.cpp +++ b/src/medium/heterogeneous-stencil.cpp @@ -199,7 +199,7 @@ public: } Float integrateDensities(Ray ray, Float length) const { - int nParts = (int) std::ceil(length/m_stepSize); + int nParts = std::max(1, (int) std::ceil(length/m_stepSize)); nParts += nParts % 2; const Float stepSize = length/nParts; const Vector increment = ray.d * stepSize; @@ -225,8 +225,7 @@ public: Float ¤tSigmaT, Spectrum ¤tAlbedo, Float desiredTau) const { - - int nParts = (int) std::ceil(maxDist/m_stepSize); + int nParts = std::max(1, (int) std::ceil(maxDist/m_stepSize)); Float stepSize = maxDist/nParts; Vector fullIncrement = ray.d * stepSize, halfIncrement = fullIncrement * .5f;