openscenegraph / OpenSceneGraph

OpenSceneGraph git repository
http://www.openscenegraph.org
Other
3.22k stars 1.42k forks source link

Should naming be exchanged? #1227

Open dansirming opened 1 year ago

dansirming commented 1 year ago

the code as follow:

 void CameraManipulator::computeHomePosition(const osg::Camera *camera, bool useBoundingBox)
{
      ..........
      if (camera->getProjectionMatrixAsFrustum(left,right,bottom,top,zNear,zFar))
            {
                **double vertical2 = fabs(right - left) / zNear / 2.;
                double horizontal2 = fabs(top - bottom) / zNear / 2.;**
               ...........
            }
            ..........
}

I think the code of bold should be as follow:

double horizontal2 = fabs(right - left) / zNear / 2.;
double  vertical2 = fabs(top - bottom) / zNear / 2.;

Names should be exchanged to avoid misunderstandings!Is it because I misunderstood this code?

robertosfield commented 1 year ago

Well spotted, it looks like this typo has been sitting there in the code quite some while. For future reference the problem code is:

https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgGA/CameraManipulator.cpp#l107