From Chris Denham, fixed support of in scene graph osg::Camera's with ReferenceFrame of RELATIVE_RF.

This commit is contained in:
Robert Osfield
2008-10-27 16:06:24 +00:00
parent 72200de866
commit 10b6309f79

View File

@@ -438,9 +438,30 @@ void IntersectionVisitor::apply(osg::Camera& camera)
// osg::notify(osg::NOTICE)<<"inside apply(Camera&)"<<std::endl;
osg::RefMatrix* projection = NULL;
osg::RefMatrix* view = NULL;
if (camera.getReferenceFrame()==osg::Transform::RELATIVE_RF && getProjectionMatrix() && getViewMatrix())
{
if (camera.getTransformOrder()==osg::Camera::POST_MULTIPLY)
{
projection = new osg::RefMatrix(*getProjectionMatrix()*camera.getProjectionMatrix());
view = new osg::RefMatrix(*getViewMatrix()*camera.getViewMatrix());
}
else // pre multiply
{
projection = new osg::RefMatrix(camera.getProjectionMatrix()*(*getProjectionMatrix()));
view = new osg::RefMatrix(camera.getViewMatrix()*(*getViewMatrix()));
}
} else {
// an absolute reference frame
projection = new osg::RefMatrix(camera.getProjectionMatrix());
view = new osg::RefMatrix(camera.getViewMatrix());
}
if (camera.getViewport()) pushWindowMatrix( camera.getViewport() );
pushProjectionMatrix( new osg::RefMatrix(camera.getProjectionMatrix()) );
pushViewMatrix( new osg::RefMatrix(camera.getViewMatrix()) );
pushProjectionMatrix(projection);
pushViewMatrix(view);
pushModelMatrix( new osg::RefMatrix() );
// now push an new intersector clone transform to the new local coordinates