1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-19 15:39:49 +00:00

Fix double precision bound issues in std::max/std::clamp

This commit is contained in:
Alexei Dobrohotov 2022-02-02 16:57:59 +03:00
parent aaea2bc0f6
commit 142b6fdf2f
2 changed files with 6 additions and 3 deletions

View file

@ -460,8 +460,10 @@ void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell)
yOffset++;
mBounds.yMin() = fog->mBounds.mMinY - yOffset * mMapWorldSize;
}
mBounds.xMax() = std::max(mBounds.xMax(), fog->mBounds.mMaxX);
mBounds.yMax() = std::max(mBounds.yMax(), fog->mBounds.mMaxY);
if (fog->mBounds.mMaxX > mBounds.xMax())
mBounds.xMax() = fog->mBounds.mMaxX;
if (fog->mBounds.mMaxY > mBounds.yMax())
mBounds.yMax() = fog->mBounds.mMaxY;
if(xOffset != 0 || yOffset != 0)
Log(Debug::Warning) << "Warning: expanding fog by " << xOffset << ", " << yOffset;

View file

@ -1109,7 +1109,8 @@ namespace SceneUtil
if (transform.mLightSource->getLastAppliedFrame() != frameNum && mPointLightFadeEnd != 0.f)
{
const float fadeDelta = mPointLightFadeEnd - mPointLightFadeStart;
float fade = 1 - std::clamp((viewBound.center().length() - mPointLightFadeStart) / fadeDelta, 0.f, 1.f);
const float viewDelta = viewBound.center().length() - mPointLightFadeStart;
float fade = 1 - std::clamp(viewDelta / fadeDelta, 0.f, 1.f);
if (fade == 0.f)
continue;