Compile the drawables of a composite map one by one to avoid frame drops for larger maps

0.6.1
scrawl 8 years ago
parent 47ca8aeee5
commit c921620ef3

@ -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; i<compositeMap.mDrawables.size(); ++i)
for (unsigned int i=compositeMap.mCompiled; i<compositeMap.mDrawables.size(); ++i)
{
osg::Drawable* drw = compositeMap.mDrawables[i];
osg::StateSet* stateset = drw->getStateSet();
@ -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()
{

@ -20,9 +20,11 @@ namespace Terrain
class CompositeMap : public osg::Referenced
{
public:
CompositeMap();
~CompositeMap();
std::vector<osg::ref_ptr<osg::Drawable> > mDrawables;
osg::ref_ptr<osg::Texture2D> mTexture;
unsigned int mCompiled;
};
/**

Loading…
Cancel
Save