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

pull/140/head
scrawl 8 years ago
parent 30b101b175
commit c58fc6d276

@ -123,6 +123,12 @@ namespace MWGui
int mWidth, mHeight;
};
class DontComputeBoundCallback : public osg::Node::ComputeBoundingSphereCallback
{
public:
virtual osg::BoundingSphere computeBound(const osg::Node&) const { return osg::BoundingSphere(); }
};
void LoadingScreen::loadingOn()
{
mLoadingOnTime = mTimer.time_m();
@ -136,6 +142,10 @@ namespace MWGui
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()
== MWBase::StateManager::State_NoGame);
@ -192,6 +202,9 @@ namespace MWGui
else
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;
setVisible(false);

Loading…
Cancel
Save