From d11a6bd92c54ba229936d65f9d4353a1ec8f0eae Mon Sep 17 00:00:00 2001 From: CedricMocquillon Date: Tue, 18 May 2021 14:03:16 +0200 Subject: [PATCH] Share state --- apps/openmw/mwrender/objectpaging.cpp | 1 + components/resource/scenemanager.cpp | 6 ++++++ components/resource/scenemanager.hpp | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/objectpaging.cpp b/apps/openmw/mwrender/objectpaging.cpp index d8f0215c0..b6bae8cbb 100644 --- a/apps/openmw/mwrender/objectpaging.cpp +++ b/apps/openmw/mwrender/objectpaging.cpp @@ -651,6 +651,7 @@ namespace MWRender } optimizer.setIsOperationPermissibleForObjectCallback(new CanOptimizeCallback); unsigned int options = SceneUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS|SceneUtil::Optimizer::REMOVE_REDUNDANT_NODES|SceneUtil::Optimizer::MERGE_GEOMETRY; + mSceneManager->shareState(mergeGroup); optimizer.optimize(mergeGroup, options); group->addChild(mergeGroup); diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 201767ab3..f6035a47d 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -514,6 +514,12 @@ namespace Resource return options; } + void SceneManager::shareState(osg::ref_ptr node) { + mSharedStateMutex.lock(); + mSharedStateManager->share(node.get()); + mSharedStateMutex.unlock(); + } + osg::ref_ptr SceneManager::getTemplate(const std::string &name, bool compile) { std::string normalized = name; diff --git a/components/resource/scenemanager.hpp b/components/resource/scenemanager.hpp index 7635cd20f..de014165b 100644 --- a/components/resource/scenemanager.hpp +++ b/components/resource/scenemanager.hpp @@ -135,7 +135,7 @@ namespace Resource osg::ref_ptr createInstance(const std::string& name); osg::ref_ptr createInstance(const osg::Node* base); - + void shareState(osg::ref_ptr node); /// Get an instance of the given scene template /// @see getTemplate /// @note Thread safe.