From e45bdb60d7acc13abb91f0cc6d17a6bc6790e462 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 1 Nov 2012 18:06:46 +0000 Subject: [PATCH] =?UTF-8?q?From=20David=20Longest,=20"When=20drawing,=20a?= =?UTF-8?q?=20transform=20with=20an=20absolute=20reference=20frame=20will?= =?UTF-8?q?=20ignore=20the=20calculated=20model=20/=20view=20matrices=20up?= =?UTF-8?q?=20to=20that=20point.=20The=20IntersectionVisitor=20would=20ins?= =?UTF-8?q?tead=20keep=20the=20view=20matrices=20calculated=20up=20to=20th?= =?UTF-8?q?at=20point=20even=20though=20the=20Transform=20class=20will=20t?= =?UTF-8?q?hrow=20out=20the=20calculated=20model=20matrix=20via=20?= =?UTF-8?q?=E2=80=9CcomputeLocalToWorldMatrix.=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The change I made will push an identity matrix as the view matrix when running into a transform with an absolute reference frame and will pop the matrix off after the traverse. To test this, I created a camera with a perspective view and added a transform with some geometry in it. Afterwards, I set the transform’s reference frame to ABSOLUTE_RF and spun the camera around using the trackball manipulator. When trying to pick with a LineSegmentIntersector, it would not pick the geometry in the transform with the reference frame set to ABSOLUTE_RF." --- src/osgUtil/IntersectionVisitor.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/osgUtil/IntersectionVisitor.cpp b/src/osgUtil/IntersectionVisitor.cpp index ae95e1c77..c0b61d0b0 100644 --- a/src/osgUtil/IntersectionVisitor.cpp +++ b/src/osgUtil/IntersectionVisitor.cpp @@ -397,6 +397,12 @@ void IntersectionVisitor::apply(osg::Transform& transform) osg::ref_ptr matrix = _modelStack.empty() ? new osg::RefMatrix() : new osg::RefMatrix(*_modelStack.back()); transform.computeLocalToWorldMatrix(*matrix,this); + // We want to ignore the view matrix if the transform is an absolute reference + if (transform.getReferenceFrame() != osg::Transform::RELATIVE_RF) + { + pushViewMatrix(new osg::RefMatrix()); + } + pushModelMatrix(matrix.get()); // now push an new intersector clone transform to the new local coordinates @@ -409,6 +415,11 @@ void IntersectionVisitor::apply(osg::Transform& transform) popModelMatrix(); + if (transform.getReferenceFrame() != osg::Transform::RELATIVE_RF) + { + popViewMatrix(); + } + // tidy up an cached cull variables in the current intersector. leave(); }