Changed the camera with focus code to only accept cameras with valid views

as ones that can recieve focus.
This commit is contained in:
Robert Osfield 2007-01-21 18:34:26 +00:00
parent b47ef11d74
commit 8e20956511
2 changed files with 11 additions and 6 deletions

View File

@ -857,11 +857,13 @@ void CompositeViewer::eventTraversal()
{
osg::Camera* camera = *citr;
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport &&
if (camera->getView() &&
viewport &&
x >= viewport->x() && y >= viewport->y() &&
x <= (viewport->x()+viewport->width()) && y <= (viewport->y()+viewport->height()) )
{
setCameraWithFocus(camera);
if (getViewWithFocus()!=masterView)
{
// need to reset the masterView

View File

@ -821,12 +821,15 @@ void Viewer::eventTraversal()
++citr)
{
osg::Camera* camera = *citr;
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport &&
x >= viewport->x() && y >= viewport->y() &&
x <= (viewport->x()+viewport->width()) && y <= (viewport->y()+viewport->height()) )
if (camera->getView()==this)
{
setCameraWithFocus(camera);
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport &&
x >= viewport->x() && y >= viewport->y() &&
x <= (viewport->x()+viewport->width()) && y <= (viewport->y()+viewport->height()) )
{
setCameraWithFocus(camera);
}
}
}
}