From c58fc6d276f4087370e5f43f5a6b1df42e10af06 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 3 Feb 2017 22:29:38 +0100 Subject: [PATCH] Improve performance of loading screen by not recomputing the bounding sphere of the entire scene after each loading step --- apps/openmw/mwgui/loadingscreen.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 6385eb2c6e..c31d161b47 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -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);