Merge pull request #81 from filnet/checkneedtodoframe
refactor common code from CompositeViewer::checkNeedToDoFrame() and Viewer::checkNeedToDoFrame() into View
This commit is contained in:
commit
48c1d0e8da
@ -305,6 +305,8 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
virtual void requestContinuousUpdate(bool needed=true);
|
||||
virtual void requestWarpPointer(float x,float y);
|
||||
|
||||
/** Return true if there are pending updates to the scene graph that require an update. */
|
||||
virtual bool requiresUpdateSceneGraph() const;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -245,34 +245,23 @@ bool CompositeViewer::isRealized() const
|
||||
|
||||
bool CompositeViewer::checkNeedToDoFrame()
|
||||
{
|
||||
// check if any event handler has prompted a redraw
|
||||
if (_requestRedraw) return true;
|
||||
if (_requestContinousUpdate) return true;
|
||||
|
||||
// check if any view needs to update the scene graph
|
||||
for(RefViews::iterator itr = _views.begin();
|
||||
itr != _views.end();
|
||||
++itr)
|
||||
{
|
||||
osgViewer::View* view = itr->get();
|
||||
if (view)
|
||||
{
|
||||
// check if the database pager needs to update the scene
|
||||
if (view->getDatabasePager()->requiresUpdateSceneGraph() ||
|
||||
view->getDatabasePager()->getRequestsInProgress()) return true;
|
||||
|
||||
// check if there are camera update callbacks
|
||||
if (view->getCamera()->getUpdateCallback()) return true;
|
||||
|
||||
// check if there are node update callbacks
|
||||
if (view->getSceneData() != 0)
|
||||
{
|
||||
if (view->getSceneData()->getUpdateCallback() || (view->getSceneData()->getNumChildrenRequiringUpdateTraversal()>0) ) return true;
|
||||
}
|
||||
}
|
||||
if (view && view->requiresUpdateSceneGraph()) return true;
|
||||
}
|
||||
|
||||
// check if events are available and need processing
|
||||
if (checkEvents()) return true;
|
||||
|
||||
// and check again if any event handler has prompted a redraw
|
||||
if (_requestRedraw) return true;
|
||||
if (_requestContinousUpdate) return true;
|
||||
|
||||
|
@ -1130,6 +1130,23 @@ void View::removeDevice(osgGA::Device* eventSource)
|
||||
}
|
||||
}
|
||||
|
||||
bool View::requiresUpdateSceneGraph() const
|
||||
{
|
||||
// check if the database pager needs to update the scene
|
||||
if (getDatabasePager()->requiresUpdateSceneGraph() || getDatabasePager()->getRequestsInProgress()) return true;
|
||||
|
||||
// check if there are camera update callbacks
|
||||
if (_camera->getUpdateCallback()) return true;
|
||||
|
||||
// check if there are node update callbacks
|
||||
if (getSceneData() != 0)
|
||||
{
|
||||
if (getSceneData()->getUpdateCallback() || (getSceneData()->getNumChildrenRequiringUpdateTraversal()>0)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods that support Stereo and Keystone correction.
|
||||
|
@ -362,17 +362,8 @@ bool Viewer::checkNeedToDoFrame()
|
||||
if (_requestRedraw) return true;
|
||||
if (_requestContinousUpdate) return true;
|
||||
|
||||
// check if the database pager needs to update the scene
|
||||
if (getDatabasePager()->requiresUpdateSceneGraph() || getDatabasePager()->getRequestsInProgress()) return true;
|
||||
|
||||
// check if there are camera update callbacks
|
||||
if (_camera->getUpdateCallback()) return true;
|
||||
|
||||
// check if there are node update callbacks
|
||||
if (getSceneData() != 0)
|
||||
{
|
||||
if (getSceneData()->getUpdateCallback() || (getSceneData()->getNumChildrenRequiringUpdateTraversal()>0) ) return true;
|
||||
}
|
||||
// check if the view needs to update the scene graph
|
||||
if (requiresUpdateSceneGraph()) return true;
|
||||
|
||||
// check if events are available and need processing
|
||||
if (checkEvents()) return true;
|
||||
|
Loading…
Reference in New Issue
Block a user