From fdaa75400bc0a576956f672fff39a33f5890ebf1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 21 Nov 2008 18:16:43 +0000 Subject: [PATCH] From Danny Valente, submitted bu Jean-Sebastien Guay, "Some context: In the past I submitted a fix to osgViewer::CompositeViewer where events would get wrong input ranges. Later, you made a change to set the eventState's current graphics context to the current graphics context. However, there's a problem in the sequence of events. Here's the recap (doing a graphical diff with the attached file will show this clearly): Before: 1. if the camera is not a slave camera 1.1 set the eventState's graphics context to the current context. 2. if the current master view is not the view which has the focus 2.1 set the current master view to be the view which has the focus 2.2 use the new master view's eventState instead of the old one Now as you can see from this sequence, the graphics context is set on the eventState before switching to the view which has focus (and thus using another eventState). So the new eventState, in the case we need to switch views, will contain an old graphics context, not the correct one. Just inversing these steps fixes the problem: 1. if the current master view is not the view which has the focus 1.1 set the current master view to be the view which has the focus 1.2 use the new master view's eventState instead of the old one 2. if the camera is not a slave camera 2.1 set the eventState's graphics context to the current context. Now, the eventState will refer to the correct graphics context in both cases. Attached is a fixed CompositeViewer.cpp (based on today's SVN) which does this. Note that some other things are done in the 1. and 2. cases, but they have no influence on each other so they can just be swapped without problems. " --- src/osgViewer/CompositeViewer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index 5b64627a0..aba92a7e6 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -705,6 +705,20 @@ void CompositeViewer::eventTraversal() masterCameraVPW *= viewport->computeWindowMatrix(); } } + + // If this camera is not a slave camera + if (camera->getView()->getCamera() == camera) + { + eventState->setGraphicsContext(gw); + eventState->setInputRange( viewport->x(), viewport->y(), + viewport->x()+viewport->width(), + viewport->y()+viewport->height()); + + } + else + { + eventState->setInputRange(-1.0, -1.0, 1.0, 1.0); + } } } }