1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-05 05:45:37 +00:00

Merge branch 'absoluteprecision' into 'master'

Fix compilation errors with double precision bound types (bug #6579)

Closes #6579

See merge request OpenMW/openmw!1619
This commit is contained in:
psi29a 2022-02-02 21:03:29 +00:00
commit fb99ed78d5
5 changed files with 38 additions and 35 deletions

View file

@ -100,6 +100,7 @@
Bug #6519: Effects tooltips for ingredients work incorrectly Bug #6519: Effects tooltips for ingredients work incorrectly
Bug #6523: Disintegrate Weapon is resisted by Resist Magicka instead of Sanctuary Bug #6523: Disintegrate Weapon is resisted by Resist Magicka instead of Sanctuary
Bug #6544: Far from world origin objects jitter when camera is still Bug #6544: Far from world origin objects jitter when camera is still
Bug #6579: OpenMW compilation error when using OSG doubles for BoundingSphere
Feature #890: OpenMW-CS: Column filtering Feature #890: OpenMW-CS: Column filtering
Feature #1465: "Reset" argument for AI functions Feature #1465: "Reset" argument for AI functions
Feature #2554: Modifying an object triggers the instances table to scroll to the corresponding record Feature #2554: Modifying an object triggers the instances table to scroll to the corresponding record

View file

@ -460,8 +460,10 @@ void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell)
yOffset++; yOffset++;
mBounds.yMin() = fog->mBounds.mMinY - yOffset * mMapWorldSize; mBounds.yMin() = fog->mBounds.mMinY - yOffset * mMapWorldSize;
} }
mBounds.xMax() = std::max(mBounds.xMax(), fog->mBounds.mMaxX); if (fog->mBounds.mMaxX > mBounds.xMax())
mBounds.yMax() = std::max(mBounds.yMax(), fog->mBounds.mMaxY); mBounds.xMax() = fog->mBounds.mMaxX;
if (fog->mBounds.mMaxY > mBounds.yMax())
mBounds.yMax() = fog->mBounds.mMaxY;
if(xOffset != 0 || yOffset != 0) if(xOffset != 0 || yOffset != 0)
Log(Debug::Warning) << "Warning: expanding fog by " << xOffset << ", " << yOffset; 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) if (transform.mLightSource->getLastAppliedFrame() != frameNum && mPointLightFadeEnd != 0.f)
{ {
const float fadeDelta = mPointLightFadeEnd - mPointLightFadeStart; 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) if (fade == 0.f)
continue; continue;

View file

@ -188,37 +188,6 @@ private:
osg::ref_ptr<osg::FrameBufferObject> mMsaaFbo; osg::ref_ptr<osg::FrameBufferObject> mMsaaFbo;
}; };
void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphere& bsphere)
{
osg::BoundingSphere::vec_type xdash = bsphere._center;
xdash.x() += bsphere._radius;
xdash = xdash*matrix;
osg::BoundingSphere::vec_type ydash = bsphere._center;
ydash.y() += bsphere._radius;
ydash = ydash*matrix;
osg::BoundingSphere::vec_type zdash = bsphere._center;
zdash.z() += bsphere._radius;
zdash = zdash*matrix;
bsphere._center = bsphere._center*matrix;
xdash -= bsphere._center;
osg::BoundingSphere::value_type sqrlen_xdash = xdash.length2();
ydash -= bsphere._center;
osg::BoundingSphere::value_type sqrlen_ydash = ydash.length2();
zdash -= bsphere._center;
osg::BoundingSphere::value_type sqrlen_zdash = zdash.length2();
bsphere._radius = sqrlen_xdash;
if (bsphere._radius<sqrlen_ydash) bsphere._radius = sqrlen_ydash;
if (bsphere._radius<sqrlen_zdash) bsphere._radius = sqrlen_zdash;
bsphere._radius = sqrtf(bsphere._radius);
}
osg::Vec4f colourFromRGB(unsigned int clr) osg::Vec4f colourFromRGB(unsigned int clr)
{ {
osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f, osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f,

View file

@ -49,7 +49,37 @@ namespace SceneUtil
// Transform a bounding sphere by a matrix // Transform a bounding sphere by a matrix
// based off private code in osg::Transform // based off private code in osg::Transform
// TODO: patch osg to make public // TODO: patch osg to make public
void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphere& bsphere); template<typename VT>
inline void transformBoundingSphere (const osg::Matrixf& matrix, osg::BoundingSphereImpl<VT>& bsphere)
{
VT xdash = bsphere._center;
xdash.x() += bsphere._radius;
xdash = xdash*matrix;
VT ydash = bsphere._center;
ydash.y() += bsphere._radius;
ydash = ydash*matrix;
VT zdash = bsphere._center;
zdash.z() += bsphere._radius;
zdash = zdash*matrix;
bsphere._center = bsphere._center*matrix;
xdash -= bsphere._center;
typename VT::value_type sqrlen_xdash = xdash.length2();
ydash -= bsphere._center;
typename VT::value_type sqrlen_ydash = ydash.length2();
zdash -= bsphere._center;
typename VT::value_type sqrlen_zdash = zdash.length2();
bsphere._radius = sqrlen_xdash;
if (bsphere._radius<sqrlen_ydash) bsphere._radius = sqrlen_ydash;
if (bsphere._radius<sqrlen_zdash) bsphere._radius = sqrlen_zdash;
bsphere._radius = sqrtf(bsphere._radius);
}
osg::Vec4f colourFromRGB (unsigned int clr); osg::Vec4f colourFromRGB (unsigned int clr);