diff --git a/apps/openmw/mwrender/precipitationocclusion.cpp b/apps/openmw/mwrender/precipitationocclusion.cpp index c1e11ae93b..ad3e6d8f05 100644 --- a/apps/openmw/mwrender/precipitationocclusion.cpp +++ b/apps/openmw/mwrender/precipitationocclusion.cpp @@ -147,7 +147,8 @@ namespace MWRender void PrecipitationOccluder::enable() { - mSkyNode->setCullCallback(new PrecipitationOcclusionUpdater(mDepthTexture)); + mSkyCullCallback = new PrecipitationOcclusionUpdater(mDepthTexture); + mSkyNode->addCullCallback(mSkyCullCallback); mCamera->setCullCallback(new DepthCameraUpdater); mRootNode->removeChild(mCamera); @@ -156,8 +157,9 @@ namespace MWRender void PrecipitationOccluder::disable() { - mSkyNode->setCullCallback(nullptr); + mSkyNode->removeCullCallback(mSkyCullCallback); mCamera->setCullCallback(nullptr); + mSkyCullCallback = nullptr; mRootNode->removeChild(mCamera); } diff --git a/apps/openmw/mwrender/precipitationocclusion.hpp b/apps/openmw/mwrender/precipitationocclusion.hpp index 9910777449..26114ed42f 100644 --- a/apps/openmw/mwrender/precipitationocclusion.hpp +++ b/apps/openmw/mwrender/precipitationocclusion.hpp @@ -23,6 +23,7 @@ namespace MWRender osg::Group* mSkyNode; osg::Group* mSceneNode; osg::Group* mRootNode; + osg::ref_ptr mSkyCullCallback; osg::ref_ptr mCamera; osg::ref_ptr mSceneCamera; osg::ref_ptr mDepthTexture;