Hi Ajun, Thanks for tracking down and fixing this rather subtle bug. As the StatsHandler gets events directly from the view itself there is no reason for the StatsHandler to receive events from via the Camera too and having this enabled just creates problems.
I have merged your fix with svn/trunk and OSG-3.2 branch. Cheers, Robert. On 13 February 2015 at 07:27, Arjun Ramamurthy <[email protected]> wrote: > Hi, > > When we use StatsHandler in multiple views, then we are unable to control > 1st view. Attached fix is based on OSG 3.2.1. > > Reproduction Scenario: > 1. Use "osgcompositeviewer.cpp" (modified osg example) provided with the > following command line arguments "cow.osg -2". > 2. After starting the application, use mouse inputs to control the scene > in both the view (this should work as expected). > 3. Now enable Stats via 's' key in 1st view then use mouse inputs ONLY in > 1st view (this will work). > 4. Now just hover the mouse pointer onto 2nd view (so that the 2nd view > comes into focus) and then try to control 1st view using mouse inputs. ONLY > 2nd view will respond. There is no healing other than restarting the > application. > > Reason for the Bug: > 1. StatsHandler creates HUDCamera > 1a. Using GraphicsContext of 1st view in > StatsHandler::setUpHUDCamera() i.e. windows.front() context > 1b. With AllowEventFocus(true) > 2. This causes 1st view's context to have 2 Cameras attached to it (Main + > Stats HUD) > 3. In CompositeViewer::generatePointerData(), whenever an event is handled > for 1st view it will always add PointerData of 1st view's Stats HUD camera > instead of Main Camera due to "std::sort(activeCameras.begin(), > activeCameras.end(), osg::CameraRenderOrderSortOp());" > 4. Since HUD camera doesn't have a osgViewer::View*, the following code in > CompositeViewer::eventTraversal() results in events being pushed to > _viewWithFocus > if (!view) > { > if (_viewWithFocus.valid()) > { > // OSG_NOTICE<<"Falling back to using > _viewWithFocus"<<std::endl; > view = _viewWithFocus.get(); > } > else if (!_views.empty()) > { > // OSG_NOTICE<<"Falling back to using first view > as one with focus"<<std::endl; > view = _views[0].get(); > } > } > 5. As explained in reproduction scenario, once 2nd view comes to focus, > then _viewWithFocus will be 2nd view and 1st view cannot be controlled > there after > > Fix: > To fix this issue StatsHandler's HUDCamera can be created with > "_camera->setAllowEventFocus(false);" > > Fix has been tested on Windows using "osgcompositeviewer.cpp" example > provided with the following command line arguments "cow.osg -2" > > Thank you! > > Cheers, > Arjun > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=62665#62665 > > > > > Attachments: > > http://forum.openscenegraph.org//files/multiview_statshandler_bug_fix_548.zip > > > _______________________________________________ > osg-submissions mailing list > [email protected] > > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >
_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
