Added handling of zero radius models
This commit is contained in:
@@ -96,8 +96,10 @@ void CameraManipulator::computeHomePosition(const osg::Camera *camera, bool useB
|
|||||||
OSG_INFO<<" boundingSphere.center() = ("<<boundingSphere.center()<<")"<<std::endl;
|
OSG_INFO<<" boundingSphere.center() = ("<<boundingSphere.center()<<")"<<std::endl;
|
||||||
OSG_INFO<<" boundingSphere.radius() = "<<boundingSphere.radius()<<std::endl;
|
OSG_INFO<<" boundingSphere.radius() = "<<boundingSphere.radius()<<std::endl;
|
||||||
|
|
||||||
|
double radius = osg::maximum(double(boundingSphere.radius()), 1e-6);
|
||||||
|
|
||||||
// set dist to default
|
// set dist to default
|
||||||
double dist = 3.5f * boundingSphere.radius();
|
double dist = 3.5f * radius;
|
||||||
|
|
||||||
if (camera)
|
if (camera)
|
||||||
{
|
{
|
||||||
@@ -110,7 +112,7 @@ void CameraManipulator::computeHomePosition(const osg::Camera *camera, bool useB
|
|||||||
double horizontal2 = fabs(top - bottom) / zNear / 2.;
|
double horizontal2 = fabs(top - bottom) / zNear / 2.;
|
||||||
double dim = horizontal2 < vertical2 ? horizontal2 : vertical2;
|
double dim = horizontal2 < vertical2 ? horizontal2 : vertical2;
|
||||||
double viewAngle = atan2(dim,1.);
|
double viewAngle = atan2(dim,1.);
|
||||||
dist = boundingSphere.radius() / sin(viewAngle);
|
dist = radius / sin(viewAngle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user