Hi Wee See and Daniel,
I have just completed a second review and have merged the changes, with a
few revisions, the main one is that I have renamed the new StatsHandler
method to:
void
StatsHandler::collectWhichCamerasToRenderStatsFor(osgViewer::ViewerBase*
viewer, osgViewer::ViewerBase::Cameras& cameras)
I have gone for this name as the original name was a bit cryptic and
potentially confusing for end users - getStatCameras() suggests that the
StatsHandler aggregates the "stat" cameras that the user can get. Note, I
also changed the ordering of the parameter to be more in keeping of how
other parts of the OSG group parameters, with source and destination
flowing from left to right within a parameter sequence.
I also refactored the changes to Renderer.cpp to make them less verbose and
easier to read. I have copied the git diff that I made to make things
clear. Changed now checked into git master.
Cheers,
Robert.
$ git diff
diff --git a/include/osgViewer/ViewerEventHandlers
b/include/osgViewer/ViewerEventHandlers
index b71bdbf..23b8797 100644
--- a/include/osgViewer/ViewerEventHandlers
+++ b/include/osgViewer/ViewerEventHandlers
@@ -100,6 +100,8 @@ class OSGVIEWER_EXPORT StatsHandler : public
osgGA::GUIEventHandler
osg::Camera* getCamera() { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
+ virtual void
collectWhichCamerasToRenderStatsFor(osgViewer::ViewerBase* viewer,
osgViewer::ViewerBase::Cameras& cameras);
+
virtual bool handle(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa);
/** Get the keyboard and mouse usage of this manipulator.*/
diff --git a/src/osgViewer/Renderer.cpp b/src/osgViewer/Renderer.cpp
index dc8069c..b2b2d7e 100644
--- a/src/osgViewer/Renderer.cpp
+++ b/src/osgViewer/Renderer.cpp
@@ -556,6 +556,15 @@ void Renderer::updateSceneView(osgUtil::SceneView*
sceneView)
_startTick = view->getStartTick();
if (state) state->setStartTick(_startTick);
}
+ else
+ {
+ osgViewer::GraphicsWindow* gw =
dynamic_cast<osgViewer::GraphicsWindow*>(context);
+ if (gw)
+ {
+ _startTick = gw->getEventQueue()->getStartTick();
+ if (state) state->setStartTick(_startTick);
+ }
+ }
}
void Renderer::compile()
diff --git a/src/osgViewer/StatsHandler.cpp b/src/osgViewer/StatsHandler.cpp
index 2a908a9..721d2aa 100644
--- a/src/osgViewer/StatsHandler.cpp
+++ b/src/osgViewer/StatsHandler.cpp
@@ -54,6 +54,11 @@ StatsHandler::StatsHandler():
_camera->setProjectionResizePolicy(osg::Camera::FIXED);
}
+void
StatsHandler::collectWhichCamerasToRenderStatsFor(osgViewer::ViewerBase*
viewer, osgViewer::ViewerBase::Cameras& cameras)
+{
+ if (viewer) viewer->getCameras(cameras);
+}
+
bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa)
{
@@ -89,7 +94,7 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter&
ea, osgGA::GUIActionAdap
if (_statsType==LAST) _statsType = NO_STATS;
osgViewer::ViewerBase::Cameras cameras;
- viewer->getCameras(cameras);
+ collectWhichCamerasToRenderStatsFor(viewer, cameras);
switch(_statsType)
{
@@ -1081,7 +1086,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase*
viewer)
// collect all the relevant cameras
ViewerBase::Cameras validCameras;
- viewer->getCameras(validCameras);
+ collectWhichCamerasToRenderStatsFor(viewer, validCameras);
ViewerBase::Cameras cameras;
for(ViewerBase::Cameras::iterator itr = validCameras.begin();
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org