From 1f2d9f2280b4878be779bd3ba4f01de4f0f4b9d2 Mon Sep 17 00:00:00 2001 From: "glassmancody.info" Date: Wed, 24 Aug 2022 15:07:04 -0700 Subject: [PATCH] don't recycle statesets for light cullcallback for now --- components/sceneutil/lightmanager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 4f5261f04b..a861dcd32c 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -605,22 +605,22 @@ namespace SceneUtil if (!lightManager->getUBOManager()) return; - for (size_t i = 0; i < mStateSet.size(); ++i) + for (size_t i = 0; i < mUBBs.size(); ++i) { auto& buffer = lightManager->getUBOManager()->getLightBuffer(i); - osg::ref_ptr ubb = new osg::UniformBufferBinding(static_cast(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData(), 0, buffer->getData()->getTotalDataSize()); - mStateSet[i]->setAttributeAndModes(ubb, osg::StateAttribute::ON); + mUBBs[i] = new osg::UniformBufferBinding(static_cast(Resource::SceneManager::UBOBinding::LightBuffer), buffer->getData(), 0, buffer->getData()->getTotalDataSize()); } } void operator()(LightManager* node, osgUtil::CullVisitor* cv) { - const size_t frameId = cv->getTraversalNumber() % 2; - - auto& stateset = mStateSet[frameId]; + osg::ref_ptr stateset = new osg::StateSet; if (node->getLightingMethod() == LightingMethod::SingleUBO) { + const size_t frameId = cv->getTraversalNumber() % 2; + stateset->setAttributeAndModes(mUBBs[frameId], osg::StateAttribute::ON); + auto& buffer = node->getUBOManager()->getLightBuffer(cv->getTraversalNumber()); if (auto sun = node->getSunlight()) @@ -653,7 +653,7 @@ namespace SceneUtil node->getPPLightsBuffer()->updateCount(cv->getTraversalNumber()); } - std::array, 2> mStateSet = { new osg::StateSet, new osg::StateSet }; + std::array, 2> mUBBs; }; UBOManager::UBOManager(int lightCount)