diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 16af3880f8..e8cfad5220 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -726,7 +726,7 @@ namespace SceneUtil META_StateAttribute(NifOsg, LightManagerStateAttribute, osg::StateAttribute::LIGHT) - void initSharedLayout(osg::GLExtensions* ext, int handle, LightManager& lightManager) const + void initSharedLayout(osg::GLExtensions* ext, int handle) const { constexpr std::array index = { static_cast(Shader::UBOBinding::LightBuffer) }; int totalBlockSize = -1; @@ -748,17 +748,13 @@ namespace SceneUtil for (int i = 0; i < 2; ++i) { - auto& buf = lightManager.getLightBuffer(i); + auto& buf = mLightManager->getLightBuffer(i); buf = new LightBuffer(*buf, offsets[0], offsets[1], offsets[2], totalBlockSize, stride); } } void apply(osg::State& state) const override { - osg::ref_ptr lightManager; - if (!mLightManager.lock(lightManager)) - return; - if (!mInitLayout) { mDummyProgram->apply(state); @@ -771,12 +767,12 @@ namespace SceneUtil // wait until the UBO binding is created if (activeUniformBlocks > 0) { - initSharedLayout(ext, handle, *lightManager); + initSharedLayout(ext, handle); mInitLayout = true; } } - lightManager->getLightBuffer(state.getFrameStamp()->getFrameNumber())->uploadCachedSunPos(state.getInitialViewMatrix()); - lightManager->getLightBuffer(state.getFrameStamp()->getFrameNumber())->dirty(); + mLightManager->getLightBuffer(state.getFrameStamp()->getFrameNumber())->uploadCachedSunPos(state.getInitialViewMatrix()); + mLightManager->getLightBuffer(state.getFrameStamp()->getFrameNumber())->dirty(); } private: @@ -806,7 +802,7 @@ namespace SceneUtil return shader; } - osg::observer_ptr mLightManager; + LightManager* mLightManager; osg::ref_ptr mDummyProgram; mutable bool mInitLayout; };