1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-21 09:39:56 +00:00

Improve performance of loading screen by not recomputing the bounding sphere of the entire scene after each loading step

This commit is contained in:
scrawl 2017-02-03 22:29:38 +01:00
parent 30b101b175
commit c58fc6d276

View File

@ -123,6 +123,12 @@ namespace MWGui
int mWidth, mHeight; int mWidth, mHeight;
}; };
class DontComputeBoundCallback : public osg::Node::ComputeBoundingSphereCallback
{
public:
virtual osg::BoundingSphere computeBound(const osg::Node&) const { return osg::BoundingSphere(); }
};
void LoadingScreen::loadingOn() void LoadingScreen::loadingOn()
{ {
mLoadingOnTime = mTimer.time_m(); mLoadingOnTime = mTimer.time_m();
@ -136,6 +142,10 @@ namespace MWGui
mViewer->getIncrementalCompileOperation()->setTargetFrameRate(mTargetFrameRate); mViewer->getIncrementalCompileOperation()->setTargetFrameRate(mTargetFrameRate);
} }
// Assign dummy bounding sphere callback to avoid the bounding sphere of the entire scene being recomputed after each frame of loading
// We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);
bool showWallpaper = (MWBase::Environment::get().getStateManager()->getState() bool showWallpaper = (MWBase::Environment::get().getStateManager()->getState()
== MWBase::StateManager::State_NoGame); == MWBase::StateManager::State_NoGame);
@ -192,6 +202,9 @@ namespace MWGui
else else
mImportantLabel = false; // label was already shown on loading screen mImportantLabel = false; // label was already shown on loading screen
mViewer->getSceneData()->setComputeBoundingSphereCallback(NULL);
mViewer->getSceneData()->dirtyBound();
//std::cout << "loading took " << mTimer.time_m() - mLoadingOnTime << std::endl; //std::cout << "loading took " << mTimer.time_m() - mLoadingOnTime << std::endl;
setVisible(false); setVisible(false);