From e23a30652dd8758d5c97954efb8d090d9bd8aa3c Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 3 Jul 2016 17:31:07 +0200 Subject: [PATCH 1/2] streamline DatabasePager::requiresUpdateSceneGraph() would trigger unnecessary redraws when there were pending file requests or active database threads tested ok with and without IncrementalCompileOperation --- src/osgDB/DatabasePager.cpp | 11 ++++++----- src/osgViewer/Scene.cpp | 2 +- src/osgViewer/View.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index d443970af..73e24e803 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -1371,10 +1371,7 @@ bool DatabasePager::getRequestsInProgress() const { if (getFileRequestListSize()>0) return true; - if (getDataToCompileListSize()>0) - { - return true; - } + if (getDataToCompileListSize()>0) return true; if (getDataToMergeListSize()>0) return true; @@ -1595,7 +1592,11 @@ void DatabasePager::setDatabasePagerThreadPause(bool pause) bool DatabasePager::requiresUpdateSceneGraph() const { - return !(_dataToMergeList->empty()); + if (getDataToCompileListSize()>0) return true; + + if (getDataToMergeListSize()>0) return true; + + return false; } void DatabasePager::updateSceneGraph(const osg::FrameStamp& frameStamp) diff --git a/src/osgViewer/Scene.cpp b/src/osgViewer/Scene.cpp index d17ca124d..a83b71999 100644 --- a/src/osgViewer/Scene.cpp +++ b/src/osgViewer/Scene.cpp @@ -116,7 +116,7 @@ void Scene::setImagePager(osgDB::ImagePager* ip) bool Scene::requiresUpdateSceneGraph() const { // check if the database pager needs to update the scene - if (getDatabasePager()->requiresUpdateSceneGraph() || getDatabasePager()->getRequestsInProgress()) return true; + if (getDatabasePager()->requiresUpdateSceneGraph()) return true; // check if the image pager needs to update the scene if (getImagePager()->requiresUpdateSceneGraph()) return true; diff --git a/src/osgViewer/View.cpp b/src/osgViewer/View.cpp index ecb1ab987..a467422f4 100644 --- a/src/osgViewer/View.cpp +++ b/src/osgViewer/View.cpp @@ -1135,7 +1135,7 @@ bool View::requiresUpdateSceneGraph() const // check if there are camera update callbacks if (_camera->getUpdateCallback()) return true; - // check if there scene requires an update traversal + // check if the scene requires an update traversal if (_scene.valid() && _scene->requiresUpdateSceneGraph()) return true; return false; From 22d53357d380210d2287692b04f601031ff8ea74 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 4 Jul 2016 23:19:20 +0200 Subject: [PATCH 2/2] split requiresUpdateSceneGraph() into requires update and requires redraw (wip) --- include/osgDB/DatabasePager | 3 +++ include/osgViewer/Scene | 1 + src/osgDB/DatabasePager.cpp | 8 ++++++-- src/osgPresentation/SlideEventHandler.cpp | 11 ++++++----- src/osgViewer/Scene.cpp | 8 ++++++++ src/osgViewer/View.cpp | 4 ++++ 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 8ad4f5033..b6ebfd86e 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -244,6 +244,9 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl * Note, must only be called from single thread update phase. */ virtual void updateSceneGraph(const osg::FrameStamp& frameStamp); + /** Return true if there are ... . */ + bool requiresRedraw() const; + /** Report how many items are in the _fileRequestList queue */ unsigned int getFileRequestListSize() const { return static_cast(_fileRequestQueue->size() + _httpRequestQueue->size()); } diff --git a/include/osgViewer/Scene b/include/osgViewer/Scene index 84fc06db5..6b49c7ed5 100644 --- a/include/osgViewer/Scene +++ b/include/osgViewer/Scene @@ -49,6 +49,7 @@ class OSGVIEWER_EXPORT Scene : public osg::Referenced virtual void updateSceneGraph(osg::NodeVisitor& updateVisitor); + virtual bool requiresRedraw() const; /** Get the Scene object that has the specified node assigned to it. * return 0 if no Scene has yet been assigned the specified node.*/ diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 73e24e803..8d6f695bd 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -1592,8 +1592,6 @@ void DatabasePager::setDatabasePagerThreadPause(bool pause) bool DatabasePager::requiresUpdateSceneGraph() const { - if (getDataToCompileListSize()>0) return true; - if (getDataToMergeListSize()>0) return true; return false; @@ -1637,6 +1635,12 @@ void DatabasePager::updateSceneGraph(const osg::FrameStamp& frameStamp) #endif } +bool DatabasePager::requiresRedraw() const +{ + if (getDataToCompileListSize()>0) return true; + + return false; +} void DatabasePager::addLoadedDataToSceneGraph(const osg::FrameStamp &frameStamp) { diff --git a/src/osgPresentation/SlideEventHandler.cpp b/src/osgPresentation/SlideEventHandler.cpp index 0ef62cf7a..f3f6b81d8 100644 --- a/src/osgPresentation/SlideEventHandler.cpp +++ b/src/osgPresentation/SlideEventHandler.cpp @@ -1712,9 +1712,11 @@ bool SlideEventHandler::checkNeedToDoFrame() if (_viewer->getRequestRedraw()) return true; if (_viewer->getRequestContinousUpdate()) return true; - // If the database pager is going to update the scene the render flag is - // set so that the updates show up - if(_viewer->getDatabasePager()->requiresUpdateSceneGraph() || _viewer->getDatabasePager()->getRequestsInProgress()) return true; + // check if the database pager needs to update the scene + if (_viewer->getDatabasePager()->requiresUpdateSceneGraph()) return true; + + // check if the image pager needs to update the scene + if (_viewer->getImagePager()->requiresUpdateSceneGraph()) return true; // if there update callbacks then we need to do frame. if (_viewer->getCamera()->getUpdateCallback()) return true; @@ -1725,7 +1727,7 @@ bool SlideEventHandler::checkNeedToDoFrame() { if (_slideSwitch->getChild(_activeLayer)->getNumChildrenRequiringUpdateTraversal()>0) return true; } - else if (_viewer->getSceneData()!=0 && _viewer->getSceneData()->getNumChildrenRequiringUpdateTraversal()>0) return true; + else if (_viewer->getSceneData()!=0 && (_viewer->getSceneData()->getUpdateCallback() || (_viewer->getSceneData()->getNumChildrenRequiringUpdateTraversal()>0))) return true; if (_autoSteppingActive) { @@ -1753,4 +1755,3 @@ bool SlideEventHandler::checkNeedToDoFrame() return true; } } - diff --git a/src/osgViewer/Scene.cpp b/src/osgViewer/Scene.cpp index a83b71999..45f880caf 100644 --- a/src/osgViewer/Scene.cpp +++ b/src/osgViewer/Scene.cpp @@ -150,6 +150,14 @@ void Scene::updateSceneGraph(osg::NodeVisitor& updateVisitor) } } +bool Scene::requiresRedraw() const +{ + // check if the database pager needs a redraw + if (getDatabasePager()->requiresRedraw()) return true; + + return false; +} + Scene* Scene::getScene(osg::Node* node) { diff --git a/src/osgViewer/View.cpp b/src/osgViewer/View.cpp index a467422f4..ed4930355 100644 --- a/src/osgViewer/View.cpp +++ b/src/osgViewer/View.cpp @@ -1138,6 +1138,10 @@ bool View::requiresUpdateSceneGraph() const // check if the scene requires an update traversal if (_scene.valid() && _scene->requiresUpdateSceneGraph()) return true; + // check if the scene requires a redraw + // FIXME... + if (_scene.valid() && _scene->requiresRedraw()) return true; + return false; }