Commit ce1044a7 authored by Frédéric Larue's avatar Frédéric Larue

GLViewer::frameBox() function simplified.

parent 1bb0876c
...@@ -508,17 +508,9 @@ void GLViewer::frameBox( Box3f &box, const QMatrix4x4 *xf ) ...@@ -508,17 +508,9 @@ void GLViewer::frameBox( Box3f &box, const QMatrix4x4 *xf )
{ {
if( !box.IsNull() ) if( !box.IsNull() )
{ {
double boxHalfDiag = box.Dimensions().length() * 0.5; double bndgSphRadius = 0.5 * box.Diagonal();
double depth = ( 2.0*zFar()*zNear() - distToFocusPoint()*(zFar()+zNear()) ) / (zNear()-zFar()); setDistToFocusPoint( bndgSphRadius / std::sin( 0.5*fovY() ) );
double projectedRadius = boxHalfDiag * focal() / depth; setFocusPoint( xf? xf->map(box.Center()) : box.Center() );
if( xf )
setFocusPoint( xf->map(box.Center()) );
else
setFocusPoint( box.Center() );
if( projectedRadius > 0.000001 )
setDistToFocusPoint( distToFocusPoint() * (width()<height()? projectedRadius*height()/width() : projectedRadius) );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment