Added handling of zero radius models

This commit is contained in:
Robert Osfield 2019-07-18 12:18:04 +01:00
parent 7f370bdfc6
commit da6b4df00a

View File

@ -96,8 +96,10 @@ void CameraManipulator::computeHomePosition(const osg::Camera *camera, bool useB
OSG_INFO<<" boundingSphere.center() = ("<<boundingSphere.center()<<")"<<std::endl;
OSG_INFO<<" boundingSphere.radius() = "<<boundingSphere.radius()<<std::endl;
double radius = osg::maximum(double(boundingSphere.radius()), 1e-6);
// set dist to default
double dist = 3.5f * boundingSphere.radius();
double dist = 3.5f * radius;
if (camera)
{
@ -110,7 +112,7 @@ void CameraManipulator::computeHomePosition(const osg::Camera *camera, bool useB
double horizontal2 = fabs(top - bottom) / zNear / 2.;
double dim = horizontal2 < vertical2 ? horizontal2 : vertical2;
double viewAngle = atan2(dim,1.);
dist = boundingSphere.radius() / sin(viewAngle);
dist = radius / sin(viewAngle);
}
else
{