mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00: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 <cassert>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
#include <components/misc/constants.hpp>
|
||||
|
@ -120,16 +122,19 @@ namespace MWRender
|
|||
|
||||
void PrecipitationOccluder::update()
|
||||
{
|
||||
if (!mRange.has_value())
|
||||
return;
|
||||
|
||||
const osg::Vec3 pos = mSceneCamera->getInverseViewMatrix().getTrans();
|
||||
|
||||
const float zmin = pos.z() - mRange.z() - Constants::CellSizeInUnits;
|
||||
const float zmax = 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 near = 0;
|
||||
const float far = zmax - zmin;
|
||||
|
||||
const float left = -mRange.x() / 2;
|
||||
const float left = -mRange->x() / 2;
|
||||
const float right = -left;
|
||||
const float top = mRange.y() / 2;
|
||||
const float top = mRange->y() / 2;
|
||||
const float bottom = -top;
|
||||
|
||||
if (SceneUtil::AutoDepth::isReversed())
|
||||
|
@ -163,10 +168,14 @@ namespace MWRender
|
|||
mSkyCullCallback = nullptr;
|
||||
|
||||
mRootNode->removeChild(mCamera);
|
||||
mRange = std::nullopt;
|
||||
}
|
||||
|
||||
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 };
|
||||
mRange = range - margin;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <osg/Camera>
|
||||
#include <osg/Texture2D>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class PrecipitationOccluder
|
||||
|
@ -27,7 +29,7 @@ namespace MWRender
|
|||
osg::ref_ptr<osg::Camera> mCamera;
|
||||
osg::ref_ptr<osg::Camera> mSceneCamera;
|
||||
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;
|
||||
bool mResolve = false;
|
||||
Types::SizeProxy mSize;
|
||||
bool mMipMap;
|
||||
bool mMipMap = false;
|
||||
|
||||
SubPass(const SubPass& other, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
|
||||
: mStateSet(new osg::StateSet(*other.mStateSet, copyOp))
|
||||
|
|
Loading…
Reference in a new issue