diff --git a/components/terrain/compositemaprenderer.cpp b/components/terrain/compositemaprenderer.cpp index 8e63575f1..b00dfd2d9 100644 --- a/components/terrain/compositemaprenderer.cpp +++ b/components/terrain/compositemaprenderer.cpp @@ -47,8 +47,11 @@ void CompositeMapRenderer::drawImplementation(osg::RenderInfo &renderInfo) const compile(*node, renderInfo, &timeLeft); - mCompiled.insert(node); - mCompileSet.erase(mCompileSet.begin()); + if (node->mCompiled >= node->mDrawables.size()) + { + mCompiled.insert(node); + mCompileSet.erase(mCompileSet.begin()); + } } } @@ -78,7 +81,7 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo & return; } - for (unsigned int i=0; igetStateSet(); @@ -93,15 +96,23 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo & if (stateset) renderInfo.getState()->popStateSet(); + + ++compositeMap.mCompiled; + + if (timeLeft) + { + *timeLeft -= timer.time_s(); + timer.setStartTick(); + + if (*timeLeft <= 0) + break; + } } state.haveAppliedAttribute(osg::StateAttribute::VIEWPORT); GLuint fboId = state.getGraphicsContext() ? state.getGraphicsContext()->getDefaultFboId() : 0; ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); - - if (timeLeft) - *timeLeft -= timer.time_s(); } void CompositeMapRenderer::setTimeAvailableForCompile(double time) @@ -131,6 +142,11 @@ void CompositeMapRenderer::setImmediate(CompositeMap* compositeMap) } } +CompositeMap::CompositeMap() + : mCompiled(0) +{ +} + CompositeMap::~CompositeMap() { diff --git a/components/terrain/compositemaprenderer.hpp b/components/terrain/compositemaprenderer.hpp index 5bc45da45..f84d2121f 100644 --- a/components/terrain/compositemaprenderer.hpp +++ b/components/terrain/compositemaprenderer.hpp @@ -20,9 +20,11 @@ namespace Terrain class CompositeMap : public osg::Referenced { public: + CompositeMap(); ~CompositeMap(); std::vector > mDrawables; osg::ref_ptr mTexture; + unsigned int mCompiled; }; /**