mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 11:36:42 +00:00
Compile the drawables of a composite map one by one to avoid frame drops for larger maps
This commit is contained in:
parent
47ca8aeee5
commit
c921620ef3
2 changed files with 24 additions and 6 deletions
|
@ -47,9 +47,12 @@ void CompositeMapRenderer::drawImplementation(osg::RenderInfo &renderInfo) const
|
||||||
|
|
||||||
compile(*node, renderInfo, &timeLeft);
|
compile(*node, renderInfo, &timeLeft);
|
||||||
|
|
||||||
|
if (node->mCompiled >= node->mDrawables.size())
|
||||||
|
{
|
||||||
mCompiled.insert(node);
|
mCompiled.insert(node);
|
||||||
mCompileSet.erase(mCompileSet.begin());
|
mCompileSet.erase(mCompileSet.begin());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &renderInfo, double* timeLeft) const
|
void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &renderInfo, double* timeLeft) const
|
||||||
|
@ -78,7 +81,7 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &
|
||||||
return;
|
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::Drawable* drw = compositeMap.mDrawables[i];
|
||||||
osg::StateSet* stateset = drw->getStateSet();
|
osg::StateSet* stateset = drw->getStateSet();
|
||||||
|
@ -93,15 +96,23 @@ void CompositeMapRenderer::compile(CompositeMap &compositeMap, osg::RenderInfo &
|
||||||
|
|
||||||
if (stateset)
|
if (stateset)
|
||||||
renderInfo.getState()->popStateSet();
|
renderInfo.getState()->popStateSet();
|
||||||
|
|
||||||
|
++compositeMap.mCompiled;
|
||||||
|
|
||||||
|
if (timeLeft)
|
||||||
|
{
|
||||||
|
*timeLeft -= timer.time_s();
|
||||||
|
timer.setStartTick();
|
||||||
|
|
||||||
|
if (*timeLeft <= 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.haveAppliedAttribute(osg::StateAttribute::VIEWPORT);
|
state.haveAppliedAttribute(osg::StateAttribute::VIEWPORT);
|
||||||
|
|
||||||
GLuint fboId = state.getGraphicsContext() ? state.getGraphicsContext()->getDefaultFboId() : 0;
|
GLuint fboId = state.getGraphicsContext() ? state.getGraphicsContext()->getDefaultFboId() : 0;
|
||||||
ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
|
ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
|
||||||
|
|
||||||
if (timeLeft)
|
|
||||||
*timeLeft -= timer.time_s();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositeMapRenderer::setTimeAvailableForCompile(double time)
|
void CompositeMapRenderer::setTimeAvailableForCompile(double time)
|
||||||
|
@ -131,6 +142,11 @@ void CompositeMapRenderer::setImmediate(CompositeMap* compositeMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompositeMap::CompositeMap()
|
||||||
|
: mCompiled(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CompositeMap::~CompositeMap()
|
CompositeMap::~CompositeMap()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,11 @@ namespace Terrain
|
||||||
class CompositeMap : public osg::Referenced
|
class CompositeMap : public osg::Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CompositeMap();
|
||||||
~CompositeMap();
|
~CompositeMap();
|
||||||
std::vector<osg::ref_ptr<osg::Drawable> > mDrawables;
|
std::vector<osg::ref_ptr<osg::Drawable> > mDrawables;
|
||||||
osg::ref_ptr<osg::Texture2D> mTexture;
|
osg::ref_ptr<osg::Texture2D> mTexture;
|
||||||
|
unsigned int mCompiled;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue