Added new Node/Drawable::s/getInitialBound and Node/Drawable::s/getComputeBoundCallback

methods and reimplement computeBound so that it passes back a bounding volume rather
than modifying the local one.
This commit is contained in:
Robert Osfield
2005-05-12 14:03:22 +00:00
parent ad2bd31ac8
commit bf4d63f6ea
52 changed files with 337 additions and 377 deletions

View File

@@ -74,7 +74,7 @@ void Impostor::addImpostorSprite(unsigned int contextID, ImpostorSprite* is)
}
}
bool Impostor::computeBound() const
osg::BoundingSphere Impostor::computeBound() const
{
return LOD::computeBound();
}

View File

@@ -100,22 +100,20 @@ void ImpostorSprite::drawImplementation(osg::State&) const
}
bool ImpostorSprite::computeBound() const
osg::BoundingBox ImpostorSprite::computeBound() const
{
_bbox.init();
_bbox.expandBy(_coords[0]);
_bbox.expandBy(_coords[1]);
_bbox.expandBy(_coords[2]);
_bbox.expandBy(_coords[3]);
osg::BoundingBox bbox;
bbox.expandBy(_coords[0]);
bbox.expandBy(_coords[1]);
bbox.expandBy(_coords[2]);
bbox.expandBy(_coords[3]);
_bbox_computed=true;
if (!_bbox.valid())
if (!bbox.valid())
{
osg::notify(osg::WARN) << "******* ImpostorSprite::computeBound() problem"<<std::endl;
}
return true;
return bbox;
}
void ImpostorSprite::setTexture(osg::Texture2D* tex,int s,int t)

View File

@@ -169,9 +169,9 @@ void LightPointDrawable::drawImplementation(osg::State& state) const
}
bool LightPointDrawable::computeBound() const
osg::BoundingBox LightPointDrawable::computeBound() const
{
_bbox.init();
osg::BoundingBox bbox;
SizedLightPointList::const_iterator sitr;
for(sitr=_sizedOpaqueLightPointList.begin();
@@ -183,7 +183,7 @@ bool LightPointDrawable::computeBound() const
litr!=lpl.end();
++litr)
{
_bbox.expandBy(litr->second);
bbox.expandBy(litr->second);
}
}
for(sitr=_sizedAdditiveLightPointList.begin();
@@ -195,7 +195,7 @@ bool LightPointDrawable::computeBound() const
litr!=lpl.end();
++litr)
{
_bbox.expandBy(litr->second);
bbox.expandBy(litr->second);
}
}
for(sitr=_sizedBlendedLightPointList.begin();
@@ -207,9 +207,9 @@ bool LightPointDrawable::computeBound() const
litr!=lpl.end();
++litr)
{
_bbox.expandBy(litr->second);
bbox.expandBy(litr->second);
}
}
return true;
return bbox;
}

View File

@@ -93,10 +93,10 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
double getReferenceTime() const { return _referenceTime; }
double getReferenceTimeInterval() const { return _referenceTimeInterval; }
virtual osg::BoundingBox computeBound() const;
protected:
virtual bool computeBound() const;
virtual ~LightPointDrawable() {}
osg::Endian _endian;

View File

@@ -80,15 +80,15 @@ void LightPointNode::removeLightPoint(unsigned int pos)
dirtyBound();
}
bool LightPointNode::computeBound() const
osg::BoundingSphere LightPointNode::computeBound() const
{
_bsphere.init();
osg::BoundingSphere bsphere;
bsphere.init();
_bbox.init();
if (_lightPointList.empty())
{
_bsphere_computed=true;
return false;
return bsphere;
}
@@ -101,21 +101,19 @@ bool LightPointNode::computeBound() const
}
_bsphere.set(_bbox.center(),0.0f);
bsphere.set(_bbox.center(),0.0f);
for(itr=_lightPointList.begin();
itr!=_lightPointList.end();
++itr)
{
osg::Vec3 dv(itr->_position-_bsphere.center());
osg::Vec3 dv(itr->_position-bsphere.center());
float radius = dv.length()+itr->_radius;
if (_bsphere.radius()<radius) _bsphere.radius()=radius;
if (bsphere.radius()<radius) bsphere.radius()=radius;
}
_bsphere.radius()+=1.0f;
_bsphere_computed=true;
return true;
bsphere.radius()+=1.0f;
return bsphere;
}

View File

@@ -35,9 +35,9 @@ public:
void drawImplementation(osg::State& state) const;
protected:
virtual osg::BoundingBox computeBound() const;
virtual bool computeBound() const;
protected:
private:
@@ -49,10 +49,11 @@ void SphereSegment::Surface::drawImplementation(osg::State& state) const
_ss->Surface_drawImplementation(state);
}
bool SphereSegment::Surface::computeBound() const
osg:: BoundingBox SphereSegment::Surface::computeBound() const
{
_bbox_computed = _ss->Surface_computeBound(_bbox);
return _bbox_computed;
osg:: BoundingBox bbox;
_ss->Surface_computeBound(bbox);
return bbox;
}
@@ -93,7 +94,7 @@ protected:
}
virtual bool computeBound() const;
virtual osg::BoundingBox computeBound() const;
private:
@@ -105,10 +106,11 @@ void SphereSegment::EdgeLine::drawImplementation(osg::State& state) const
_ss->EdgeLine_drawImplementation(state);
}
bool SphereSegment::EdgeLine::computeBound() const
osg::BoundingBox SphereSegment::EdgeLine::computeBound() const
{
_bbox_computed = _ss->EdgeLine_computeBound(_bbox);
return _bbox_computed;
osg::BoundingBox bbox;
_ss->EdgeLine_computeBound(bbox);
return bbox;
}
@@ -141,7 +143,7 @@ public:
protected:
virtual bool computeBound() const;
virtual osg::BoundingBox computeBound() const;
private:
SphereSegment* _ss;
@@ -155,10 +157,11 @@ void SphereSegment::Side::drawImplementation(osg::State& state) const
_ss->Side_drawImplementation(state, _planeOrientation, _BoundaryAngle);
}
bool SphereSegment::Side::computeBound() const
osg::BoundingBox SphereSegment::Side::computeBound() const
{
_bbox_computed = _ss->Side_computeBound(_bbox, _planeOrientation, _BoundaryAngle);
return _bbox_computed;
osg::BoundingBox bbox;
_ss->Side_computeBound(bbox, _planeOrientation, _BoundaryAngle);
return bbox;
}
@@ -199,7 +202,7 @@ protected:
//getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF);
}
virtual bool computeBound() const;
virtual osg::BoundingBox computeBound() const;
private:
SphereSegment* _ss;
@@ -211,10 +214,11 @@ void SphereSegment::Spoke::drawImplementation(osg::State& state) const
_ss->Spoke_drawImplementation(state, _azAngle, _elevAngle);
}
bool SphereSegment::Spoke::computeBound() const
osg::BoundingBox SphereSegment::Spoke::computeBound() const
{
_bbox_computed = _ss->Spoke_computeBound(_bbox, _azAngle, _elevAngle);
return _bbox_computed;
osg::BoundingBox bbox;
_ss->Spoke_computeBound(bbox, _azAngle, _elevAngle);
return bbox;
}
SphereSegment::SphereSegment(const osg::Vec3& centre, float radius, const osg::Vec3& vec, float azRange,