1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 05:23:51 +00:00

Option to disable per view mapping.

This commit is contained in:
madsbuvi 2021-01-24 11:42:00 +01:00
parent 5c4e6c3f57
commit 2393fe9e1d
3 changed files with 11 additions and 3 deletions

View file

@ -233,6 +233,7 @@ class Refraction : public SceneUtil::RTTNode
{
public:
Refraction()
: RTTNode(false)
{
mClipCullNode = new ClipCullNode;
}
@ -296,6 +297,7 @@ class Reflection : public SceneUtil::RTTNode
{
public:
Reflection(bool isInterior)
: RTTNode(false)
{
setInterior(isInterior);
mClipCullNode = new ClipCullNode;

View file

@ -34,7 +34,6 @@ namespace SceneUtil
setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water");
setViewport(0, 0, rttSize, rttSize);
@ -63,7 +62,8 @@ namespace SceneUtil
osg::ref_ptr<osg::Texture2D> mDepthBuffer;
};
RTTNode::RTTNode()
RTTNode::RTTNode(bool doPerViewMapping)
: mDoPerViewMapping(doPerViewMapping)
{
addCullCallback(new CullCallback(this));
}
@ -91,6 +91,11 @@ namespace SceneUtil
RTTNode::ViewDependentData* RTTNode::getViewDependentData(osgUtil::CullVisitor* cv)
{
if (!mDoPerViewMapping)
// Always setting it to null is an easy way to disable per-view mapping when mDoPerViewMapping is false.
// This is safe since the visitor is never dereferenced.
cv = nullptr;
if (mViewDependentDataMap.count(cv) == 0)
{
mViewDependentDataMap[cv].reset(new ViewDependentData);

View file

@ -30,7 +30,7 @@ namespace SceneUtil
class RTTNode : public osg::Node
{
public:
RTTNode();
RTTNode(bool doPerViewMapping);
~RTTNode();
osg::Texture2D* getColorTexture(osgUtil::CullVisitor* cv);
@ -57,6 +57,7 @@ namespace SceneUtil
typedef std::map< osgUtil::CullVisitor*, std::unique_ptr<ViewDependentData> > ViewDependentDataMap;
ViewDependentDataMap mViewDependentDataMap;
bool mDoPerViewMapping;
};
}
#endif