Fixed IntersectionVisitor::accept(Camera) handling of relative Cameras.

This commit is contained in:
Robert Osfield 2008-11-06 13:38:11 +00:00
parent c80c7dd5b9
commit 45c7ca720c

View File

@ -440,6 +440,7 @@ void IntersectionVisitor::apply(osg::Camera& camera)
osg::RefMatrix* projection = NULL; osg::RefMatrix* projection = NULL;
osg::RefMatrix* view = NULL; osg::RefMatrix* view = NULL;
osg::RefMatrix* model = NULL;
if (camera.getReferenceFrame()==osg::Transform::RELATIVE_RF && getProjectionMatrix() && getViewMatrix()) 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()); projection = new osg::RefMatrix(*getProjectionMatrix()*camera.getProjectionMatrix());
view = new osg::RefMatrix(*getViewMatrix()*camera.getViewMatrix()); view = new osg::RefMatrix(*getViewMatrix()*camera.getViewMatrix());
model = new osg::RefMatrix(*getModelMatrix());
} }
else // pre multiply else // pre multiply
{ {
projection = new osg::RefMatrix(camera.getProjectionMatrix()*(*getProjectionMatrix())); projection = new osg::RefMatrix(camera.getProjectionMatrix()*(*getProjectionMatrix()));
view = new osg::RefMatrix(camera.getViewMatrix()*(*getViewMatrix())); view = new osg::RefMatrix(*getViewMatrix());
model = new osg::RefMatrix(camera.getViewMatrix()*(*getModelMatrix()));
} }
} else { }
else
{
// an absolute reference frame // an absolute reference frame
projection = new osg::RefMatrix(camera.getProjectionMatrix()); projection = new osg::RefMatrix(camera.getProjectionMatrix());
view = new osg::RefMatrix(camera.getViewMatrix()); view = new osg::RefMatrix(camera.getViewMatrix());
model = new osg::RefMatrix();
} }
if (camera.getViewport()) pushWindowMatrix( camera.getViewport() ); if (camera.getViewport()) pushWindowMatrix( camera.getViewport() );
pushProjectionMatrix(projection); pushProjectionMatrix(projection);
pushViewMatrix(view); pushViewMatrix(view);
pushModelMatrix( new osg::RefMatrix() ); pushModelMatrix(model);
// now push an new intersector clone transform to the new local coordinates // now push an new intersector clone transform to the new local coordinates
push_clone(); push_clone();