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:
@@ -123,7 +123,7 @@ bool Billboard::removeDrawable( Drawable *gset )
|
||||
// note ref_ptr<> automatically handles decrementing gset's reference count.
|
||||
_drawables.erase(itr);
|
||||
_positionList.erase(pitr);
|
||||
_bsphere_computed = false;
|
||||
dirtyBound();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -265,41 +265,40 @@ bool Billboard::computeMatrix(Matrix& modelview, const Vec3& eye_local, const Ve
|
||||
|
||||
}
|
||||
|
||||
bool Billboard::computeBound() const
|
||||
BoundingSphere Billboard::computeBound() const
|
||||
{
|
||||
int i;
|
||||
int ngsets = _drawables.size();
|
||||
|
||||
if( ngsets == 0 ) return false;
|
||||
if( ngsets == 0 ) return BoundingSphere();
|
||||
|
||||
_bsphere._center.set(0.0f,0.0f,0.0f);
|
||||
BoundingSphere bsphere;
|
||||
bsphere._center.set(0.0f,0.0f,0.0f);
|
||||
|
||||
for( i = 0; i < ngsets; i++ )
|
||||
{
|
||||
const Drawable *gset = _drawables[i].get();
|
||||
const BoundingBox& bbox = gset->getBound();
|
||||
|
||||
_bsphere._center += bbox.center();
|
||||
_bsphere._center += _positionList[i];
|
||||
bsphere._center += bbox.center();
|
||||
bsphere._center += _positionList[i];
|
||||
}
|
||||
|
||||
_bsphere._center /= (float)(ngsets);
|
||||
bsphere._center /= (float)(ngsets);
|
||||
|
||||
float maxd = 0.0;
|
||||
for( i = 0; i < ngsets; ++i )
|
||||
{
|
||||
const Drawable *gset = _drawables[i].get();
|
||||
const BoundingBox& bbox = gset->getBound();
|
||||
Vec3 local_center = _bsphere._center-_positionList[i];
|
||||
Vec3 local_center = bsphere._center-_positionList[i];
|
||||
for(unsigned int c=0;c<8;++c)
|
||||
{
|
||||
float d = (bbox.corner(c)-local_center).length2();
|
||||
if( d > maxd ) maxd = d;
|
||||
}
|
||||
}
|
||||
_bsphere._radius = sqrtf(maxd);
|
||||
bsphere._radius = sqrtf(maxd);
|
||||
|
||||
_bsphere_computed=true;
|
||||
|
||||
return true;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ void ClipNode::setLocalStateSetModes(const StateAttribute::GLModeValue value)
|
||||
setStateSetModes(*_stateset,value);
|
||||
}
|
||||
|
||||
bool ClipNode::computeBound() const
|
||||
BoundingSphere ClipNode::computeBound() const
|
||||
{
|
||||
return Group::computeBound();
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ void DrawPixels::getSubImageDimensions(unsigned int& offsetX,unsigned int& offse
|
||||
}
|
||||
|
||||
|
||||
bool DrawPixels::computeBound() const
|
||||
BoundingBox DrawPixels::computeBound() const
|
||||
{
|
||||
// really needs to be dependant of view poistion and projection... will implement simple version right now.
|
||||
_bbox.init();
|
||||
BoundingBox bbox;
|
||||
float diagonal = 0.0f;
|
||||
if (_useSubImage)
|
||||
{
|
||||
@@ -83,10 +83,9 @@ bool DrawPixels::computeBound() const
|
||||
diagonal = sqrtf(_image->s()*_image->s()+_image->t()*_image->t());
|
||||
}
|
||||
|
||||
_bbox.expandBy(_position-osg::Vec3(diagonal,diagonal,diagonal));
|
||||
_bbox.expandBy(_position+osg::Vec3(diagonal,diagonal,diagonal));
|
||||
_bbox_computed = true;
|
||||
return true;
|
||||
bbox.expandBy(_position-osg::Vec3(diagonal,diagonal,diagonal));
|
||||
bbox.expandBy(_position+osg::Vec3(diagonal,diagonal,diagonal));
|
||||
return bbox;
|
||||
}
|
||||
|
||||
void DrawPixels::drawImplementation(State&) const
|
||||
|
||||
@@ -259,7 +259,7 @@ void Drawable::flushDeletedVertexBufferObjects(unsigned int contextID,double /*c
|
||||
|
||||
Drawable::Drawable()
|
||||
{
|
||||
_bbox_computed = false;
|
||||
_boundingBoxComputed = false;
|
||||
|
||||
// Note, if your are defining a subclass from drawable which is
|
||||
// dynamically updated then you should set both the following to
|
||||
@@ -280,8 +280,9 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
Object(drawable,copyop),
|
||||
_parents(), // leave empty as parentList is managed by Geode
|
||||
_stateset(copyop(drawable._stateset.get())),
|
||||
_bbox(drawable._bbox),
|
||||
_bbox_computed(drawable._bbox_computed),
|
||||
_initialBound(drawable._initialBound),
|
||||
_boundingBox(drawable._boundingBox),
|
||||
_boundingBoxComputed(drawable._boundingBoxComputed),
|
||||
_shape(copyop(drawable._shape.get())),
|
||||
_supportsDisplayList(drawable._supportsDisplayList),
|
||||
_useDisplayList(drawable._useDisplayList),
|
||||
@@ -444,9 +445,9 @@ osg::StateSet* Drawable::getOrCreateStateSet()
|
||||
|
||||
void Drawable::dirtyBound()
|
||||
{
|
||||
if (_bbox_computed)
|
||||
if (_boundingBoxComputed)
|
||||
{
|
||||
_bbox_computed = false;
|
||||
_boundingBoxComputed = false;
|
||||
|
||||
// dirty parent bounding sphere's to ensure that all are valid.
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
@@ -724,23 +725,20 @@ struct ComputeBound : public PrimitiveFunctor
|
||||
BoundingBox _bb;
|
||||
};
|
||||
|
||||
bool Drawable::computeBound() const
|
||||
BoundingBox Drawable::computeBound() const
|
||||
{
|
||||
ComputeBound cb;
|
||||
|
||||
Drawable* non_const_this = const_cast<Drawable*>(this);
|
||||
non_const_this->accept(cb);
|
||||
|
||||
_bbox = cb._bb;
|
||||
_bbox_computed = true;
|
||||
|
||||
return true;
|
||||
return cb._bb;
|
||||
}
|
||||
|
||||
void Drawable::setBound(const BoundingBox& bb) const
|
||||
{
|
||||
_bbox = bb;
|
||||
_bbox_computed = true;
|
||||
_boundingBox = bb;
|
||||
_boundingBoxComputed = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -178,11 +178,11 @@ bool Geode::setDrawable( unsigned int i, Drawable* newDrawable )
|
||||
}
|
||||
|
||||
|
||||
bool Geode::computeBound() const
|
||||
BoundingSphere Geode::computeBound() const
|
||||
{
|
||||
_bsphere.init();
|
||||
BoundingSphere bsphere;
|
||||
|
||||
_bbox.init();
|
||||
_bbox.init();
|
||||
|
||||
DrawableList::const_iterator itr;
|
||||
for(itr=_drawables.begin();
|
||||
@@ -194,15 +194,9 @@ bool Geode::computeBound() const
|
||||
|
||||
if (_bbox.valid())
|
||||
{
|
||||
_bsphere.expandBy(_bbox);
|
||||
_bsphere_computed=true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bsphere_computed=true;
|
||||
return false;
|
||||
bsphere.expandBy(_bbox);
|
||||
}
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
void Geode::compileDrawables(State& state)
|
||||
|
||||
@@ -337,15 +337,12 @@ bool Group::setChild( unsigned int i, Node* newNode )
|
||||
|
||||
}
|
||||
|
||||
bool Group::computeBound() const
|
||||
BoundingSphere Group::computeBound() const
|
||||
{
|
||||
|
||||
|
||||
_bsphere.init();
|
||||
BoundingSphere bsphere;
|
||||
if (_children.empty())
|
||||
{
|
||||
_bsphere_computed = true;
|
||||
return false;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
// note, special handling of the case when a child is an Transform,
|
||||
@@ -368,12 +365,11 @@ bool Group::computeBound() const
|
||||
|
||||
if (!bb.valid())
|
||||
{
|
||||
_bsphere_computed = true;
|
||||
return false;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
_bsphere._center = bb.center();
|
||||
_bsphere._radius = 0.0f;
|
||||
bsphere._center = bb.center();
|
||||
bsphere._radius = 0.0f;
|
||||
for(itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
@@ -381,12 +377,11 @@ bool Group::computeBound() const
|
||||
const osg::Transform* transform = (*itr)->asTransform();
|
||||
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
|
||||
{
|
||||
_bsphere.expandRadiusBy((*itr)->getBound());
|
||||
bsphere.expandRadiusBy((*itr)->getBound());
|
||||
}
|
||||
}
|
||||
|
||||
_bsphere_computed = true;
|
||||
return true;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
void Group::releaseGLObjects(osg::State* state) const
|
||||
|
||||
@@ -84,15 +84,11 @@ void LOD::traverse(NodeVisitor& nv)
|
||||
}
|
||||
}
|
||||
|
||||
bool LOD::computeBound() const
|
||||
BoundingSphere LOD::computeBound() const
|
||||
{
|
||||
if (_centerMode==USER_DEFINED_CENTER && _radius>=0.0f)
|
||||
{
|
||||
_bsphere._center = _userDefinedCenter;
|
||||
_bsphere._radius = _radius;
|
||||
_bsphere_computed = true;
|
||||
|
||||
return true;
|
||||
return BoundingSphere(_userDefinedCenter,_radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -58,9 +58,9 @@ void LightSource::setLocalStateSetModes(StateAttribute::GLModeValue value)
|
||||
setStateSetModes(*_stateset,value);
|
||||
}
|
||||
|
||||
bool LightSource::computeBound() const
|
||||
BoundingSphere LightSource::computeBound() const
|
||||
{
|
||||
Group::computeBound();
|
||||
BoundingSphere bsphere(Group::computeBound());
|
||||
|
||||
if (_light.valid() && _referenceFrame==RELATIVE_RF)
|
||||
{
|
||||
@@ -68,11 +68,9 @@ bool LightSource::computeBound() const
|
||||
if (pos[3]!=0.0f)
|
||||
{
|
||||
float div = 1.0f/pos[3];
|
||||
_bsphere.expandBy(Vec3(pos[0]*div,pos[1]*div,pos[2]*div));
|
||||
bsphere.expandBy(Vec3(pos[0]*div,pos[1]*div,pos[2]*div));
|
||||
}
|
||||
}
|
||||
|
||||
_bsphere_computed = true;
|
||||
|
||||
return true;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace osg;
|
||||
|
||||
Node::Node()
|
||||
{
|
||||
_bsphere_computed = false;
|
||||
_boundingSphereComputed = false;
|
||||
_nodeMask = 0xffffffff;
|
||||
|
||||
_numChildrenRequiringUpdateTraversal = 0;
|
||||
@@ -38,8 +38,9 @@ Node::Node()
|
||||
|
||||
Node::Node(const Node& node,const CopyOp& copyop):
|
||||
Object(node,copyop),
|
||||
_bsphere(node._bsphere),
|
||||
_bsphere_computed(node._bsphere_computed),
|
||||
_initialBound(node._initialBound),
|
||||
_boundingSphere(node._boundingSphere),
|
||||
_boundingSphereComputed(node._boundingSphereComputed),
|
||||
_name(node._name),
|
||||
_parents(), // leave empty as parentList is managed by Group.
|
||||
_updateCallback(node._updateCallback),
|
||||
@@ -404,18 +405,17 @@ bool Node::containsOccluderNodes() const
|
||||
return _numChildrenWithOccluderNodes>0 || dynamic_cast<const OccluderNode*>(this);
|
||||
}
|
||||
|
||||
bool Node::computeBound() const
|
||||
BoundingSphere Node::computeBound() const
|
||||
{
|
||||
_bsphere.init();
|
||||
return false;
|
||||
return BoundingSphere();
|
||||
}
|
||||
|
||||
|
||||
void Node::dirtyBound()
|
||||
{
|
||||
if (_bsphere_computed)
|
||||
if (_boundingSphereComputed)
|
||||
{
|
||||
_bsphere_computed = false;
|
||||
_boundingSphereComputed = false;
|
||||
|
||||
// dirty parent bounding sphere's to ensure that all are valid.
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
|
||||
@@ -24,9 +24,9 @@ OccluderNode::OccluderNode(const OccluderNode& node,const CopyOp& copyop):
|
||||
{
|
||||
}
|
||||
|
||||
bool OccluderNode::computeBound() const
|
||||
BoundingSphere OccluderNode::computeBound() const
|
||||
{
|
||||
bool result = Group::computeBound();
|
||||
BoundingSphere bsphere(Group::computeBound());
|
||||
|
||||
if (getOccluder())
|
||||
{
|
||||
@@ -40,10 +40,8 @@ bool OccluderNode::computeBound() const
|
||||
}
|
||||
if (bb.valid())
|
||||
{
|
||||
_bsphere.expandBy(bb);
|
||||
_bsphere_computed=true;
|
||||
result = true;
|
||||
bsphere.expandBy(bb);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
@@ -103,15 +103,11 @@ bool ProxyNode::removeChild( Node *child )
|
||||
return Group::removeChild(child);
|
||||
}
|
||||
|
||||
bool ProxyNode::computeBound() const
|
||||
BoundingSphere ProxyNode::computeBound() const
|
||||
{
|
||||
if (_centerMode==USER_DEFINED_CENTER && _radius>=0.0f)
|
||||
{
|
||||
_bsphere._center = _userDefinedCenter;
|
||||
_bsphere._radius = _radius;
|
||||
_bsphere_computed = true;
|
||||
|
||||
return true;
|
||||
return BoundingSphere(_userDefinedCenter,_radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1787,20 +1787,14 @@ void ShapeDrawable::accept(PrimitiveFunctor& pf) const
|
||||
}
|
||||
|
||||
|
||||
bool ShapeDrawable::computeBound() const
|
||||
BoundingBox ShapeDrawable::computeBound() const
|
||||
{
|
||||
_bbox.init();
|
||||
|
||||
|
||||
BoundingBox bbox;
|
||||
if (_shape.valid())
|
||||
{
|
||||
ComputeBoundShapeVisitor cbsv(_bbox);
|
||||
ComputeBoundShapeVisitor cbsv(bbox);
|
||||
_shape->accept(cbsv);
|
||||
_bbox_computed = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,13 +175,12 @@ bool Switch::setSingleChildOn(unsigned int pos)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Switch::computeBound() const
|
||||
BoundingSphere Switch::computeBound() const
|
||||
{
|
||||
_bsphere.init();
|
||||
BoundingSphere bsphere;
|
||||
if (_children.empty())
|
||||
{
|
||||
_bsphere_computed = true;
|
||||
return false;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
// note, special handling of the case when a child is an Transform,
|
||||
@@ -205,12 +204,11 @@ bool Switch::computeBound() const
|
||||
|
||||
if (!bb.valid())
|
||||
{
|
||||
_bsphere_computed = true;
|
||||
return false;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
_bsphere._center = bb.center();
|
||||
_bsphere._radius = 0.0f;
|
||||
bsphere._center = bb.center();
|
||||
bsphere._radius = 0.0f;
|
||||
for(itr=_children.begin();
|
||||
itr!=_children.end();
|
||||
++itr)
|
||||
@@ -219,80 +217,9 @@ bool Switch::computeBound() const
|
||||
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
|
||||
{
|
||||
if( getChildValue((*itr).get()) == true )
|
||||
_bsphere.expandRadiusBy((*itr)->getBound());
|
||||
bsphere.expandRadiusBy((*itr)->getBound());
|
||||
}
|
||||
}
|
||||
|
||||
_bsphere_computed = true;
|
||||
return true;
|
||||
return bsphere;
|
||||
}
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
void Switch::setValue(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case(MULTIPLE_CHILDREN_ON):
|
||||
// do nothing...
|
||||
break;
|
||||
case(ALL_CHILDREN_OFF):
|
||||
{
|
||||
_newChildDefaultValue = false;
|
||||
for(ValueList::iterator itr=_values.begin();
|
||||
itr!=_values.end();
|
||||
++itr)
|
||||
{
|
||||
*itr = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(ALL_CHILDREN_ON):
|
||||
{
|
||||
_newChildDefaultValue = true;
|
||||
for(ValueList::iterator itr=_values.begin();
|
||||
itr!=_values.end();
|
||||
++itr)
|
||||
{
|
||||
*itr = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for(ValueList::iterator itr=_values.begin();
|
||||
itr!=_values.end();
|
||||
++itr)
|
||||
{
|
||||
*itr = false;
|
||||
}
|
||||
setValue(value,true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Switch::getValue() const
|
||||
{
|
||||
if (_values.empty()) return ALL_CHILDREN_OFF;
|
||||
|
||||
unsigned int noChildrenSwitchedOn=0;
|
||||
int firstChildSelected=ALL_CHILDREN_OFF;
|
||||
for(unsigned int i=0; i<_values.size();++i)
|
||||
{
|
||||
if (_values[i])
|
||||
{
|
||||
++noChildrenSwitchedOn;
|
||||
if (firstChildSelected==ALL_CHILDREN_OFF) firstChildSelected=i;
|
||||
}
|
||||
}
|
||||
|
||||
if (noChildrenSwitchedOn>1)
|
||||
{
|
||||
if (noChildrenSwitchedOn==_values.size()) return ALL_CHILDREN_ON;
|
||||
else return MULTIPLE_CHILDREN_ON;
|
||||
}
|
||||
return firstChildSelected;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -121,9 +121,10 @@ void Transform::setReferenceFrame(ReferenceFrame rf)
|
||||
setCullingActive(_referenceFrame==RELATIVE_RF);
|
||||
}
|
||||
|
||||
bool Transform::computeBound() const
|
||||
BoundingSphere Transform::computeBound() const
|
||||
{
|
||||
if (!Group::computeBound()) return false;
|
||||
BoundingSphere bsphere = Group::computeBound();
|
||||
if (!bsphere.valid()) return bsphere;
|
||||
|
||||
// note, NULL pointer for NodeVisitor, so compute's need
|
||||
// to handle this case gracefully, normally this should not be a problem.
|
||||
@@ -131,33 +132,34 @@ bool Transform::computeBound() const
|
||||
|
||||
computeLocalToWorldMatrix(l2w,NULL);
|
||||
|
||||
Vec3 xdash = _bsphere._center;
|
||||
xdash.x() += _bsphere._radius;
|
||||
Vec3 xdash = bsphere._center;
|
||||
xdash.x() += bsphere._radius;
|
||||
xdash = xdash*l2w;
|
||||
|
||||
Vec3 ydash = _bsphere._center;
|
||||
ydash.y() += _bsphere._radius;
|
||||
Vec3 ydash = bsphere._center;
|
||||
ydash.y() += bsphere._radius;
|
||||
ydash = ydash*l2w;
|
||||
|
||||
Vec3 zdash = _bsphere._center;
|
||||
zdash.z() += _bsphere._radius;
|
||||
Vec3 zdash = bsphere._center;
|
||||
zdash.z() += bsphere._radius;
|
||||
zdash = zdash*l2w;
|
||||
|
||||
_bsphere._center = _bsphere._center*l2w;
|
||||
|
||||
xdash -= _bsphere._center;
|
||||
bsphere._center = bsphere._center*l2w;
|
||||
|
||||
xdash -= bsphere._center;
|
||||
float len_xdash = xdash.length();
|
||||
|
||||
ydash -= _bsphere._center;
|
||||
ydash -= bsphere._center;
|
||||
float len_ydash = ydash.length();
|
||||
|
||||
zdash -= _bsphere._center;
|
||||
zdash -= bsphere._center;
|
||||
float len_zdash = zdash.length();
|
||||
|
||||
_bsphere._radius = len_xdash;
|
||||
if (_bsphere._radius<len_ydash) _bsphere._radius = len_ydash;
|
||||
if (_bsphere._radius<len_zdash) _bsphere._radius = len_zdash;
|
||||
bsphere._radius = len_xdash;
|
||||
if (bsphere._radius<len_ydash) bsphere._radius = len_ydash;
|
||||
if (bsphere._radius<len_zdash) bsphere._radius = len_zdash;
|
||||
|
||||
return true;
|
||||
return bsphere;
|
||||
|
||||
}
|
||||
|
||||
@@ -121,3 +121,9 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
|
||||
// call the inherited method
|
||||
Node::traverse(nv);
|
||||
}
|
||||
|
||||
osg::BoundingSphere osgParticle::ParticleProcessor::computeBound() const
|
||||
{
|
||||
return osg::BoundingSphere();
|
||||
}
|
||||
|
||||
|
||||
@@ -197,3 +197,15 @@ void osgParticle::ParticleSystem::single_pass_render(osg::State& /*state*/, con
|
||||
i0->endRender();
|
||||
|
||||
}
|
||||
|
||||
osg::BoundingBox osgParticle::ParticleSystem::computeBound() const
|
||||
{
|
||||
if (!_bounds_computed)
|
||||
{
|
||||
return _def_bbox;
|
||||
} else
|
||||
{
|
||||
return osg::BoundingBox(_bmin,_bmax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,3 +48,9 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
Node::traverse(nv);
|
||||
}
|
||||
|
||||
osg::BoundingSphere osgParticle::ParticleSystemUpdater::computeBound() const
|
||||
{
|
||||
return osg::BoundingSphere();
|
||||
}
|
||||
|
||||
|
||||
@@ -165,15 +165,15 @@ class Logos: public osg::Drawable
|
||||
return (n != 0);
|
||||
}
|
||||
|
||||
virtual osg::BoundingBox computeBound() const
|
||||
{
|
||||
return osg::BoundingBox( -1, -1, -1, 1, 1, 1);
|
||||
}
|
||||
|
||||
protected:
|
||||
Logos& operator = (const Logos&) { return *this;}
|
||||
|
||||
virtual ~Logos() {}
|
||||
virtual bool computeBound() const
|
||||
{
|
||||
_bbox.set( -1, -1, -1, 1, 1, 1);
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
std::vector <osg::Image *> logos[last_position];
|
||||
osg::Viewport *viewport;
|
||||
|
||||
@@ -101,14 +101,11 @@ void TXPNode::traverse(osg::NodeVisitor& nv)
|
||||
Group::traverse(nv);
|
||||
}
|
||||
|
||||
bool TXPNode::computeBound() const
|
||||
osg::BoundingSphere TXPNode::computeBound() const
|
||||
{
|
||||
if (getNumChildren() == 0)
|
||||
{
|
||||
_bsphere.init();
|
||||
_bsphere.expandBy(_extents);
|
||||
_bsphere_computed = true;
|
||||
return true;
|
||||
return osg::BoundingSphere( _extents );
|
||||
}
|
||||
return Group::computeBound();
|
||||
}
|
||||
|
||||
@@ -69,11 +69,12 @@ public:
|
||||
|
||||
void setArchive(TXPArchive* archive) { _archive = archive; }
|
||||
|
||||
virtual osg::BoundingSphere computeBound() const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TXPNode();
|
||||
|
||||
virtual bool computeBound() const;
|
||||
|
||||
void updateEye(osg::NodeVisitor& nv);
|
||||
void updateSceneGraph();
|
||||
|
||||
@@ -74,7 +74,7 @@ void Impostor::addImpostorSprite(unsigned int contextID, ImpostorSprite* is)
|
||||
}
|
||||
}
|
||||
|
||||
bool Impostor::computeBound() const
|
||||
osg::BoundingSphere Impostor::computeBound() const
|
||||
{
|
||||
return LOD::computeBound();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -222,9 +222,9 @@ void Text::setDrawMode(unsigned int mode)
|
||||
}
|
||||
|
||||
|
||||
bool Text::computeBound() const
|
||||
osg::BoundingBox Text::computeBound() const
|
||||
{
|
||||
_bbox.init();
|
||||
osg::BoundingBox bbox;
|
||||
|
||||
if (_textBB.valid())
|
||||
{
|
||||
@@ -238,16 +238,15 @@ bool Text::computeBound() const
|
||||
else
|
||||
{
|
||||
osg::Matrix& matrix = _autoTransformCache[i]._matrix;
|
||||
_bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
_bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
_bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMin())*matrix);
|
||||
_bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMin())*matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_bbox_computed = true;
|
||||
return true;
|
||||
return bbox;
|
||||
}
|
||||
|
||||
Font* Text::getActiveFont()
|
||||
|
||||
Reference in New Issue
Block a user