mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Merge branch 'fix_ubsan_warnings' into 'master'
Fix ubsan warnings See merge request OpenMW/openmw!3772
This commit is contained in:
commit
6b9fd12ab7
3 changed files with 17 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "precipitationocclusion.hpp"
|
#include "precipitationocclusion.hpp"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <osgUtil/CullVisitor>
|
#include <osgUtil/CullVisitor>
|
||||||
|
|
||||||
#include <components/misc/constants.hpp>
|
#include <components/misc/constants.hpp>
|
||||||
|
@ -120,16 +122,19 @@ namespace MWRender
|
||||||
|
|
||||||
void PrecipitationOccluder::update()
|
void PrecipitationOccluder::update()
|
||||||
{
|
{
|
||||||
|
if (!mRange.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
const osg::Vec3 pos = mSceneCamera->getInverseViewMatrix().getTrans();
|
const osg::Vec3 pos = mSceneCamera->getInverseViewMatrix().getTrans();
|
||||||
|
|
||||||
const float zmin = pos.z() - mRange.z() - Constants::CellSizeInUnits;
|
const float zmin = pos.z() - mRange->z() - Constants::CellSizeInUnits;
|
||||||
const float zmax = pos.z() + mRange.z() + Constants::CellSizeInUnits;
|
const float zmax = pos.z() + mRange->z() + Constants::CellSizeInUnits;
|
||||||
const float near = 0;
|
const float near = 0;
|
||||||
const float far = zmax - zmin;
|
const float far = zmax - zmin;
|
||||||
|
|
||||||
const float left = -mRange.x() / 2;
|
const float left = -mRange->x() / 2;
|
||||||
const float right = -left;
|
const float right = -left;
|
||||||
const float top = mRange.y() / 2;
|
const float top = mRange->y() / 2;
|
||||||
const float bottom = -top;
|
const float bottom = -top;
|
||||||
|
|
||||||
if (SceneUtil::AutoDepth::isReversed())
|
if (SceneUtil::AutoDepth::isReversed())
|
||||||
|
@ -163,10 +168,14 @@ namespace MWRender
|
||||||
mSkyCullCallback = nullptr;
|
mSkyCullCallback = nullptr;
|
||||||
|
|
||||||
mRootNode->removeChild(mCamera);
|
mRootNode->removeChild(mCamera);
|
||||||
|
mRange = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrecipitationOccluder::updateRange(const osg::Vec3f range)
|
void PrecipitationOccluder::updateRange(const osg::Vec3f range)
|
||||||
{
|
{
|
||||||
|
assert(range.x() != 0);
|
||||||
|
assert(range.y() != 0);
|
||||||
|
assert(range.z() != 0);
|
||||||
const osg::Vec3f margin = { -50, -50, 0 };
|
const osg::Vec3f margin = { -50, -50, 0 };
|
||||||
mRange = range - margin;
|
mRange = range - margin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <osg/Camera>
|
#include <osg/Camera>
|
||||||
#include <osg/Texture2D>
|
#include <osg/Texture2D>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
class PrecipitationOccluder
|
class PrecipitationOccluder
|
||||||
|
@ -27,7 +29,7 @@ namespace MWRender
|
||||||
osg::ref_ptr<osg::Camera> mCamera;
|
osg::ref_ptr<osg::Camera> mCamera;
|
||||||
osg::ref_ptr<osg::Camera> mSceneCamera;
|
osg::ref_ptr<osg::Camera> mSceneCamera;
|
||||||
osg::ref_ptr<osg::Texture2D> mDepthTexture;
|
osg::ref_ptr<osg::Texture2D> mDepthTexture;
|
||||||
osg::Vec3f mRange;
|
std::optional<osg::Vec3f> mRange;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace fx
|
||||||
osg::ref_ptr<osg::Texture2D> mRenderTexture;
|
osg::ref_ptr<osg::Texture2D> mRenderTexture;
|
||||||
bool mResolve = false;
|
bool mResolve = false;
|
||||||
Types::SizeProxy mSize;
|
Types::SizeProxy mSize;
|
||||||
bool mMipMap;
|
bool mMipMap = false;
|
||||||
|
|
||||||
SubPass(const SubPass& other, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
|
SubPass(const SubPass& other, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
|
||||||
: mStateSet(new osg::StateSet(*other.mStateSet, copyOp))
|
: mStateSet(new osg::StateSet(*other.mStateSet, copyOp))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue