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();