From 8e209565113e66bc92c4ee8e80cc17963242e802 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 21 Jan 2007 18:34:26 +0000 Subject: [PATCH] Changed the camera with focus code to only accept cameras with valid views as ones that can recieve focus. --- src/osgViewer/CompositeViewer.cpp | 4 +++- src/osgViewer/Viewer.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index d26899459..60073adb5 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -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 diff --git a/src/osgViewer/Viewer.cpp b/src/osgViewer/Viewer.cpp index fd41c4ae9..c47b7e4fa 100644 --- a/src/osgViewer/Viewer.cpp +++ b/src/osgViewer/Viewer.cpp @@ -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); + } } } }