From David Longest, "When drawing, a transform with an absolute reference frame will ignore the
calculated model / view matrices up to that point. The IntersectionVisitor would instead keep the view matrices calculated up to that point even though the Transform class will throw out the calculated model matrix via “computeLocalToWorldMatrix.” 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."
This commit is contained in:
@@ -397,6 +397,12 @@ void IntersectionVisitor::apply(osg::Transform& transform)
|
||||
osg::ref_ptr<osg::RefMatrix> 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user