Introduced CMake build option for compiling double or float versions of osg::BoundingSphere and osg::BoundingBox.

Introduced code in BoundgingSphere, BoundingBox, ProxyNode and LOD to utilise the above settings.

Added Matrix::value_type, Plane::value_type, BoundingSphere::value_type and BoundingBox::value_type command line 
options that report where the types of floats or doubles.
This commit is contained in:
Robert Osfield
2008-04-03 18:36:50 +00:00
parent fe5c019608
commit 2a54ff3e4a
11 changed files with 225 additions and 78 deletions

View File

@@ -15,15 +15,15 @@
using namespace osg;
void BoundingSphere::expandBy(const Vec3& v)
void BoundingSphere::expandBy(const Vec3f& v)
{
if (valid())
{
Vec3 dv = v-_center;
float r = dv.length();
vec_type dv = v-_center;
value_type r = dv.length();
if (r>_radius)
{
float dr = (r-_radius)*0.5f;
value_type dr = (r-_radius)*0.5;
_center += dv*(dr/r);
_radius += dr;
} // else do nothing as vertex is within sphere.
@@ -31,27 +31,66 @@ void BoundingSphere::expandBy(const Vec3& v)
else
{
_center = v;
_radius = 0.0f;
_radius = 0.0;
}
}
void BoundingSphere::expandRadiusBy(const Vec3& v)
void BoundingSphere::expandRadiusBy(const Vec3f& v)
{
if (valid())
{
float r = (v-_center).length();
value_type r = (v-_center).length();
if (r>_radius) _radius = r;
// else do nothing as vertex is within sphere.
}
else
{
_center = v;
_radius = 0.0f;
_radius = 0.0;
}
}
void BoundingSphere::expandBy(const Vec3d& v)
{
if (valid())
{
vec_type dv = v-_center;
value_type r = dv.length();
if (r>_radius)
{
value_type dr = (r-_radius)*0.5;
_center += dv*(dr/r);
_radius += dr;
} // else do nothing as vertex is within sphere.
}
else
{
_center = v;
_radius = 0.0;
}
}
void BoundingSphere::expandRadiusBy(const Vec3d& v)
{
if (valid())
{
value_type r = (v-_center).length();
if (r>_radius) _radius = r;
// else do nothing as vertex is within sphere.
}
else
{
_center = v;
_radius = 0.0;
}
}
void BoundingSphere::expandBy(const BoundingSphere& sh)
{
@@ -107,7 +146,7 @@ void BoundingSphere::expandRadiusBy(const BoundingSphere& sh)
{
if (valid())
{
float r = (sh._center-_center).length()+sh._radius;
value_type r = (sh._center-_center).length()+sh._radius;
if (r>_radius) _radius = r;
// else do nothing as vertex is within sphere.
}

View File

@@ -105,7 +105,7 @@ void NodeTrackerManipulator::setNode(osg::Node* node)
const osg::BoundingSphere& boundingSphere=_node->getBound();
const float minimumDistanceScale = 0.001f;
_minimumDistance = osg::clampBetween(
boundingSphere._radius * minimumDistanceScale,
float(boundingSphere._radius) * minimumDistanceScale,
0.00001f,1.0f);
osg::notify(osg::INFO)<<"Setting Tracker manipulator _minimumDistance to "<<_minimumDistance<<std::endl;

View File

@@ -51,7 +51,7 @@ void TerrainManipulator::setNode(osg::Node* node)
const osg::BoundingSphere& boundingSphere=_node->getBound();
const float minimumDistanceScale = 0.001f;
_minimumDistance = osg::clampBetween(
boundingSphere._radius * minimumDistanceScale,
float(boundingSphere._radius) * minimumDistanceScale,
0.00001f,1.0f);
osg::notify(osg::INFO)<<"Setting terrain manipulator _minimumDistance to "<<_minimumDistance<<std::endl;

View File

@@ -1994,7 +1994,8 @@ void ConvertToInventor::apply(osg::LOD& node)
lod->range.set1Value(i, node.getMaxRange(i));
// set center
lod->center.setValue(node.getCenter().ptr());
osg::Vec3f center(node.getCenter());
lod->center.setValue(center.ptr());
ivLOD = lod;