Changed the CullVisitor::popProjection() so that it doesn't adjust orthorgraphic
projection matrices.
This commit is contained in:
@@ -208,16 +208,6 @@ int main( int argc, char **argv )
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
// set all the sceneview's up so that their left and right add cull masks are set up.
|
||||
for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin();
|
||||
itr!=viewer.getSceneHandlerList().end();
|
||||
++itr)
|
||||
{
|
||||
osgUtil::SceneView* sceneview = itr->get();
|
||||
sceneview->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
}
|
||||
|
||||
|
||||
while( !viewer.done() )
|
||||
{
|
||||
// wait for all cull and draw threads to complete.
|
||||
|
||||
@@ -177,26 +177,36 @@ void CullVisitor::popProjectionMatrix()
|
||||
// so it doesn't cull them out.
|
||||
osg::Matrix& projection = *_projectionStack.back();
|
||||
|
||||
double desired_znear = _computed_znear*0.98f;
|
||||
double desired_zfar = _computed_zfar*1.02f;
|
||||
if (projection(0,3)==0.0f && projection(1,3)==0.0f && projection(2,3)==0.0f)
|
||||
{
|
||||
//cout << "Orthographic projection "<<projection<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
double min_near_plane = _computed_zfar*_nearFarRatio;
|
||||
if (desired_znear<min_near_plane) desired_znear=min_near_plane;
|
||||
|
||||
// assign the clamped values back to the computed values.
|
||||
_computed_znear = desired_znear;
|
||||
_computed_zfar = desired_zfar;
|
||||
//cout << "Perspective projection "<<projection<<endl;
|
||||
|
||||
double trans_near_plane = (-desired_znear*projection(2,2)+projection(3,2))/(-desired_znear*projection(2,3)+projection(3,3));
|
||||
double trans_far_plane = (-desired_zfar*projection(2,2)+projection(3,2))/(-desired_zfar*projection(2,3)+projection(3,3));
|
||||
double desired_znear = _computed_znear *0.98f;
|
||||
double desired_zfar = _computed_zfar *1.02f;
|
||||
|
||||
double ratio = fabs(2.0f/(trans_near_plane-trans_far_plane));
|
||||
double center = -(trans_near_plane+trans_far_plane)/2.0f;
|
||||
double min_near_plane = _computed_zfar*_nearFarRatio;
|
||||
if (desired_znear<min_near_plane) desired_znear=min_near_plane;
|
||||
|
||||
projection.postMult(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,ratio,0.0f,
|
||||
0.0f,0.0f,center*ratio,1.0f));
|
||||
// assign the clamped values back to the computed values.
|
||||
_computed_znear = desired_znear;
|
||||
_computed_zfar = desired_zfar;
|
||||
|
||||
double trans_near_plane = (-desired_znear*projection(2,2)+projection(3,2))/(-desired_znear*projection(2,3)+projection(3,3));
|
||||
double trans_far_plane = (-desired_zfar*projection(2,2)+projection(3,2))/(-desired_zfar*projection(2,3)+projection(3,3));
|
||||
|
||||
double ratio = fabs(2.0f/(trans_near_plane-trans_far_plane));
|
||||
double center = -(trans_near_plane+trans_far_plane)/2.0f;
|
||||
|
||||
projection.postMult(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,ratio,0.0f,
|
||||
0.0f,0.0f,center*ratio,1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
CullStack::popProjectionMatrix();
|
||||
|
||||
Reference in New Issue
Block a user