From c2986b3bd72457c0e3f035c973fa2db06beb19b7 Mon Sep 17 00:00:00 2001 From: bzzt Date: Wed, 20 Feb 2019 13:37:00 +0000 Subject: [PATCH] Do not block the loading thread while compiling composite maps in the draw thread --- components/terrain/compositemaprenderer.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/terrain/compositemaprenderer.cpp b/components/terrain/compositemaprenderer.cpp index 39d00db361..3fc56a8821 100644 --- a/components/terrain/compositemaprenderer.cpp +++ b/components/terrain/compositemaprenderer.cpp @@ -59,26 +59,29 @@ void CompositeMapRenderer::drawImplementation(osg::RenderInfo &renderInfo) const while (!mImmediateCompileSet.empty()) { - CompositeMap* node = *mImmediateCompileSet.begin(); + osg::ref_ptr node = *mImmediateCompileSet.begin(); mCompiled.insert(node); + mImmediateCompileSet.erase(node); + mMutex.unlock(); compile(*node, renderInfo, nullptr); - - mImmediateCompileSet.erase(mImmediateCompileSet.begin()); + mMutex.lock(); } double timeLeft = availableTime; while (!mCompileSet.empty() && timeLeft > 0) { - CompositeMap* node = *mCompileSet.begin(); + osg::ref_ptr node = *mCompileSet.begin(); + mMutex.unlock(); compile(*node, renderInfo, &timeLeft); + mMutex.lock(); if (node->mCompiled >= node->mDrawables.size()) { mCompiled.insert(node); - mCompileSet.erase(mCompileSet.begin()); + mCompileSet.erase(node); } } mTimer.setStartTick();