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.
"
This commit is contained in:
Robert Osfield 2008-11-21 18:16:43 +00:00
parent 6524788516
commit fdaa75400b

View File

@ -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);
}
}
}
}