From 45c7ca720cce053245b9a2c248b51191df4f1c32 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 6 Nov 2008 13:38:11 +0000 Subject: [PATCH] Fixed IntersectionVisitor::accept(Camera) handling of relative Cameras. --- src/osgUtil/IntersectionVisitor.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/osgUtil/IntersectionVisitor.cpp b/src/osgUtil/IntersectionVisitor.cpp index c6486e2df..a4bb8f072 100644 --- a/src/osgUtil/IntersectionVisitor.cpp +++ b/src/osgUtil/IntersectionVisitor.cpp @@ -440,6 +440,7 @@ void IntersectionVisitor::apply(osg::Camera& camera) osg::RefMatrix* projection = NULL; osg::RefMatrix* view = NULL; + osg::RefMatrix* model = NULL; if (camera.getReferenceFrame()==osg::Transform::RELATIVE_RF && getProjectionMatrix() && getViewMatrix()) { @@ -447,22 +448,27 @@ void IntersectionVisitor::apply(osg::Camera& camera) { projection = new osg::RefMatrix(*getProjectionMatrix()*camera.getProjectionMatrix()); view = new osg::RefMatrix(*getViewMatrix()*camera.getViewMatrix()); + model = new osg::RefMatrix(*getModelMatrix()); } else // pre multiply { projection = new osg::RefMatrix(camera.getProjectionMatrix()*(*getProjectionMatrix())); - view = new osg::RefMatrix(camera.getViewMatrix()*(*getViewMatrix())); - } - } else { + view = new osg::RefMatrix(*getViewMatrix()); + model = new osg::RefMatrix(camera.getViewMatrix()*(*getModelMatrix())); + } + } + else + { // an absolute reference frame projection = new osg::RefMatrix(camera.getProjectionMatrix()); view = new osg::RefMatrix(camera.getViewMatrix()); + model = new osg::RefMatrix(); } if (camera.getViewport()) pushWindowMatrix( camera.getViewport() ); pushProjectionMatrix(projection); pushViewMatrix(view); - pushModelMatrix( new osg::RefMatrix() ); + pushModelMatrix(model); // now push an new intersector clone transform to the new local coordinates push_clone();