mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 05:39:42 +00:00
Update PrecipitationOccluder only when there is precipitation
This commit is contained in:
parent
dd706aab0e
commit
384a1dd13a
2 changed files with 16 additions and 5 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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue