Removed OSG_USE_BOUND and associated osg::Bound adapter class to avoid problems with BoundingBox::expandBy/expandByRadius() implementation choosing a null BoundingBox from

the osg::Bound class causing crashes.
This commit is contained in:
Robert Osfield 2014-06-02 16:20:39 +00:00
parent e1ec4ec67f
commit 2d41cbd0cf
8 changed files with 2 additions and 89 deletions

View File

@ -443,9 +443,6 @@ MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE)
OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON)
MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX)
OPTION(OSG_USE_BOUND "Set to ON to build OpenSceneGraph with Bound adapter class to help with porting applications between OSG-3.2 and 3.4 and later." ON)
MARK_AS_ADVANCED(OSG_USE_BOUND)
IF (WIN32)
OPTION(OSG_USE_UTF8_FILENAME "Set to ON to use a UTF8 locale for filenames instead of the default locale." OFF)
MARK_AS_ADVANCED(OSG_USE_UTF8_FILENAME)

View File

@ -135,7 +135,6 @@ class BoundingSphereImpl
return valid() && bs.valid() &&
((_center - bs._center).length2() <= (_radius + bs._radius)*(_radius + bs._radius));
}
};

View File

@ -123,19 +123,11 @@ class OSG_EXPORT Drawable : public Node
/** Set the initial bounding volume to use when computing the overall bounding volume.*/
const BoundingBox& getInitialBound() const { return _initialBound; }
#ifdef OSG_USE_BOUND
virtual Bound getBound() const
{
if(!_boundingSphereComputed) getBoundingBox();
return Bound(_boundingSphere, _boundingBox);
}
#else
inline const BoundingSphere& getBound() const
{
if(!_boundingSphereComputed) getBoundingBox();
return _boundingSphere;
}
#endif
/** Get BoundingBox of Drawable.
* If the BoundingBox is not up to date then its updated via an internal call to computeBond().

View File

@ -52,45 +52,6 @@ typedef std::vector< NodePath > NodePathList;
/** A vector of NodePath, typically used to describe all the paths from a node to the potential root nodes it has.*/
typedef std::vector< Matrix > MatrixList;
#ifdef OSG_USE_BOUND
struct Bound
{
Bound():
bb(0),
bs(0) {}
Bound(const osg::BoundingSphere& bs):
bb(0),
bs(&bs) {}
Bound(const osg::BoundingBox& bb):
bb(&bb),
bs(0) {}
Bound(const osg::BoundingSphere& bs, const osg::BoundingBox& bb):
bb(&bb),
bs(&bs) {}
const osg::BoundingBox* bb;
const osg::BoundingSphere* bs;
bool valid() const { return bs ? bs->valid() : false; }
const osg::Vec3& center() const { return bs->center(); }
float radius() const { return bs->radius(); }
float xMin() const { return bb->xMin(); }
float yMin() const { return bb->yMin(); }
float zMin() const { return bb->zMin(); }
float xMax() const { return bb->xMax(); }
float yMax() const { return bb->yMax(); }
float zMax() const { return bb->zMax(); }
operator const osg::BoundingBox& () const { return *bb; }
operator const osg::BoundingSphere& () const { return *bs; }
};
#endif
/** META_Node macro define the standard clone, isSameKindAs, className
* and accept methods. Use when subclassing from Node to make it
@ -450,24 +411,7 @@ class OSG_EXPORT Node : public Object
Forcing it to be computed on the next call to getBound().*/
void dirtyBound();
/** Get the bounding sphere of node.
Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/
#ifdef OSG_USE_BOUND
virtual Bound getBound() const
{
if(!_boundingSphereComputed)
{
_boundingSphere = _initialBound;
if (_computeBoundCallback.valid())
_boundingSphere.expandBy(_computeBoundCallback->computeBound(*this));
else
_boundingSphere.expandBy(computeBound());
_boundingSphereComputed = true;
}
return Bound(_boundingSphere);
}
#else
inline const BoundingSphere& getBound() const
{
if(!_boundingSphereComputed)
@ -482,7 +426,6 @@ class OSG_EXPORT Node : public Object
}
return _boundingSphere;
}
#endif
/** Compute the bounding sphere around Node's geometry or children.
This method is automatically called by getBound() when the bounding

View File

@ -22,10 +22,6 @@
#include <osg/BoundingSphere>
#include <osg/BoundingBox>
#ifdef OSG_USE_BOUND
#include <osg/Node>
#endif
#include <vector>
namespace osg {
@ -325,13 +321,6 @@ class OSG_EXPORT Plane
}
#ifdef OSG_USE_BOUND
inline int intersect(const Bound& bound) const
{
if (bound.bb) return intersect(*bound.bb);
else return intersect(*bound.bs);
}
#endif
/** Transform the plane by matrix. Note, this operation carries out
* the calculation of the inverse of the matrix since a plane
* must be multiplied by the inverse transposed to transform it. This

View File

@ -289,14 +289,6 @@ class OSG_EXPORT Polytope
return true;
}
#ifdef OSG_USE_BOUND
inline bool contains(const osg::Bound& bound)
{
if (bound.bb) return contains(*bound.bb);
else return contains(*bound.bs);
}
#endif
/** Check whether all of vertex list is contained with clipping set.*/
inline bool containsAllOf(const std::vector<Vec3>& vertices)
{

View File

@ -30,7 +30,6 @@
#cmakedefine OSG_USE_FLOAT_BOUNDINGBOX
#cmakedefine OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION
#cmakedefine OSG_USE_UTF8_FILENAME
#cmakedefine OSG_USE_BOUND
#cmakedefine OSG_DISABLE_MSVC_WARNINGS
#endif

View File

@ -53,6 +53,8 @@ namespace osg
};
}
Node::Node()
:Object(true)
{