diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index f9f5e476c..875d6d5bb 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -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; diff --git a/components/sceneutil/rtt.cpp b/components/sceneutil/rtt.cpp index 8c4d2d695..e6a744900 100644 --- a/components/sceneutil/rtt.cpp +++ b/components/sceneutil/rtt.cpp @@ -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 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); diff --git a/components/sceneutil/rtt.hpp b/components/sceneutil/rtt.hpp index afb840873..251124de0 100644 --- a/components/sceneutil/rtt.hpp +++ b/components/sceneutil/rtt.hpp @@ -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 > ViewDependentDataMap; ViewDependentDataMap mViewDependentDataMap; + bool mDoPerViewMapping; }; } #endif