From aad7c5066d0098a5689f4e838af4c5d4d19dddfb Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 22 Jun 2023 15:18:53 +0400 Subject: [PATCH] Do not lose existing callbacks for sky node --- apps/openmw/mwrender/precipitationocclusion.cpp | 6 ++++-- apps/openmw/mwrender/precipitationocclusion.hpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) 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;