This commit is contained in:
Robert Osfield
2014-05-14 10:19:43 +00:00
parent 12a737ae02
commit 4174d72a52
37 changed files with 244 additions and 397 deletions

View File

@@ -30,6 +30,7 @@
#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

@@ -69,7 +69,7 @@ void DrawPixels::getSubImageDimensions(unsigned int& offsetX,unsigned int& offse
}
BoundingBox DrawPixels::computeBound() const
BoundingBox DrawPixels::computeBoundingBox() const
{
// really needs to be dependent of view position and projection... will implement simple version right now.
BoundingBox bbox;

View File

@@ -217,7 +217,6 @@ void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availabl
}
Drawable::Drawable()
:Object(true)
{
_boundingBoxComputed = false;
@@ -237,14 +236,10 @@ Drawable::Drawable()
_supportsVertexBufferObjects = false;
_useVertexBufferObjects = false;
// _useVertexBufferObjects = true;
_numChildrenRequiringUpdateTraversal = 0;
_numChildrenRequiringEventTraversal = 0;
}
Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
Object(drawable,copyop),
_parents(), // leave empty as parentList is managed by Geode
Node(drawable,copyop),
_initialBound(drawable._initialBound),
_computeBoundCallback(drawable._computeBoundCallback),
_boundingBox(drawable._boundingBox),
@@ -255,9 +250,7 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
_supportsVertexBufferObjects(drawable._supportsVertexBufferObjects),
_useVertexBufferObjects(drawable._useVertexBufferObjects),
_updateCallback(drawable._updateCallback),
_numChildrenRequiringUpdateTraversal(drawable._numChildrenRequiringUpdateTraversal),
_eventCallback(drawable._eventCallback),
_numChildrenRequiringEventTraversal(drawable._numChildrenRequiringEventTraversal),
_cullCallback(drawable._cullCallback),
_drawCallback(drawable._drawCallback)
{
@@ -266,17 +259,9 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
Drawable::~Drawable()
{
// cleanly detatch any associated stateset (include remove parent links)
setStateSet(0);
dirtyDisplayList();
}
void Drawable::accept(NodeVisitor& nv)
{
nv.apply(*this);
}
osg::MatrixList Drawable::getWorldMatrices(const osg::Node* haltTraversalAtNode) const
{
osg::MatrixList matrices;
@@ -306,168 +291,6 @@ void Drawable::computeDataVariance()
setDataVariance(dynamic ? DYNAMIC : STATIC);
}
void Drawable::addParent(osg::Node* node)
{
OpenThreads::ScopedPointerLock<OpenThreads::Mutex> lock(getRefMutex());
_parents.push_back(node);
}
void Drawable::removeParent(osg::Node* node)
{
OpenThreads::ScopedPointerLock<OpenThreads::Mutex> lock(getRefMutex());
ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),node);
if (pitr!=_parents.end()) _parents.erase(pitr);
}
void Drawable::setStateSet(osg::StateSet* stateset)
{
// do nothing if nothing changed.
if (_stateset==stateset) return;
// track whether we need to account for the need to do a update or event traversal.
int delta_update = 0;
int delta_event = 0;
// remove this node from the current statesets parent list
if (_stateset.valid())
{
_stateset->removeParent(this);
if (_stateset->requiresUpdateTraversal()) --delta_update;
if (_stateset->requiresEventTraversal()) --delta_event;
}
// set the stateset.
_stateset = stateset;
// add this node to the new stateset to the parent list.
if (_stateset.valid())
{
_stateset->addParent(this);
if (_stateset->requiresUpdateTraversal()) ++delta_update;
if (_stateset->requiresEventTraversal()) ++delta_event;
}
// only inform parents if change occurs and drawable doesn't already have an update callback
if (delta_update!=0 && !_updateCallback)
{
for(ParentList::iterator itr=_parents.begin();
itr!=_parents.end();
++itr)
{
(*itr)->setNumChildrenRequiringUpdateTraversal( (*itr)->getNumChildrenRequiringUpdateTraversal()+delta_update );
}
}
// only inform parents if change occurs and drawable doesn't already have an event callback
if (delta_event!=0 && !_eventCallback)
{
for(ParentList::iterator itr=_parents.begin();
itr!=_parents.end();
++itr)
{
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta_event );
}
}
}
void Drawable::setNumChildrenRequiringUpdateTraversal(unsigned int num)
{
// if no changes just return.
if (_numChildrenRequiringUpdateTraversal==num) return;
// note, if _updateCallback is set then the
// parents won't be affected by any changes to
// _numChildrenRequiringUpdateTraversal so no need to inform them.
if (!_updateCallback && !_parents.empty())
{
// need to pass on changes to parents.
int delta = 0;
if (_numChildrenRequiringUpdateTraversal>0) --delta;
if (num>0) ++delta;
if (delta!=0)
{
// the number of callbacks has changed, need to pass this
// on to parents so they know whether app traversal is
// required on this subgraph.
for(ParentList::iterator itr =_parents.begin();
itr != _parents.end();
++itr)
{
(*itr)->setNumChildrenRequiringUpdateTraversal( (*itr)->getNumChildrenRequiringUpdateTraversal()+delta );
}
}
}
// finally update this objects value.
_numChildrenRequiringUpdateTraversal=num;
}
void Drawable::setNumChildrenRequiringEventTraversal(unsigned int num)
{
// if no changes just return.
if (_numChildrenRequiringEventTraversal==num) return;
// note, if _eventCallback is set then the
// parents won't be affected by any changes to
// _numChildrenRequiringEventTraversal so no need to inform them.
if (!_eventCallback && !_parents.empty())
{
// need to pass on changes to parents.
int delta = 0;
if (_numChildrenRequiringEventTraversal>0) --delta;
if (num>0) ++delta;
if (delta!=0)
{
// the number of callbacks has changed, need to pass this
// on to parents so they know whether app traversal is
// required on this subgraph.
for(ParentList::iterator itr =_parents.begin();
itr != _parents.end();
++itr)
{
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta );
}
}
}
// finally Event this objects value.
_numChildrenRequiringEventTraversal=num;
}
osg::StateSet* Drawable::getOrCreateStateSet()
{
if (!_stateset) setStateSet(new StateSet);
return _stateset.get();
}
void Drawable::dirtyBound()
{
if (_boundingBoxComputed)
{
_boundingBoxComputed = false;
// dirty parent bounding sphere's to ensure that all are valid.
for(ParentList::iterator itr=_parents.begin();
itr!=_parents.end();
++itr)
{
(*itr)->dirtyBound();
}
}
}
void Drawable::compileGLObjects(RenderInfo& renderInfo) const
{
if (!_useDisplayList) return;
@@ -790,7 +613,12 @@ struct ComputeBound : public PrimitiveFunctor
BoundingBox _bb;
};
BoundingBox Drawable::computeBound() const
BoundingSphere Drawable::computeBound() const
{
return BoundingSphere(getBoundingBox());
}
BoundingBox Drawable::computeBoundingBox() const
{
ComputeBound cb;

View File

@@ -387,7 +387,8 @@ BoundingSphere Group::computeBound() const
const osg::Transform* transform = (*itr)->asTransform();
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{
bsphere.expandRadiusBy((*itr)->getBound());
const BoundingSphere& bs = (*itr)->getBound();
bsphere.expandRadiusBy(bs);
}
}

View File

@@ -1987,7 +1987,7 @@ void ShapeDrawable::accept(PrimitiveFunctor& pf) const
}
BoundingBox ShapeDrawable::computeBound() const
BoundingBox ShapeDrawable::computeBoundingBox() const
{
BoundingBox bbox;
if (_shape.valid())

View File

@@ -213,7 +213,7 @@ BoundingSphere Switch::computeBound() const
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
{
if( _values[pos] == true )
bsphere.expandRadiusBy(_children[pos]->getBound());
bsphere.expandRadiusBy(static_cast<const BoundingSphere&>(_children[pos]->getBound()));
}
}
return bsphere;

View File

@@ -34,7 +34,7 @@ osg::BoundingBox RigComputeBoundingBoxCallback::computeBound(const osg::Drawable
// if the computing of bb is invalid (like no geometry inside)
// then dont tag the bounding box as computed
osg::BoundingBox bb = rig.computeBound();
osg::BoundingBox bb = rig.computeBoundingBox();
if (!bb.valid())
return bb;

View File

@@ -154,10 +154,10 @@ void osgParticle::ParticleSystem::update(double dt, osg::NodeVisitor& nv)
// Repopulate the death stack as it will have been invalidated by the sort.
unsigned int numDead = _deadparts.size();
if (numDead>0)
{
{
// clear the death stack
_deadparts = Death_stack();
// copy the tail of the _particles vector as this will contain all the dead Particle thanks to the depth sort against DBL_MAX
Particle* first_dead_ptr = &_particles[_particles.size()-numDead];
Particle* last_dead_ptr = &_particles[_particles.size()-1];
@@ -528,7 +528,7 @@ void osgParticle::ParticleSystem::render_vertex_array(osg::RenderInfo& renderInf
glDrawArrays(GL_POINTS, 0, _particles.size());
}
osg::BoundingBox osgParticle::ParticleSystem::computeBound() const
osg::BoundingBox osgParticle::ParticleSystem::computeBoundingBox() const
{
if (!_bounds_computed)
{

View File

@@ -200,7 +200,7 @@ class Logos: public osg::Drawable
return (n != 0);
}
virtual osg::BoundingBox computeBound() const
virtual osg::BoundingBox computeBoundingBox() const
{
return osg::BoundingBox( -1, -1, -1, 1, 1, 1);
}

View File

@@ -904,7 +904,7 @@ void OccluderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
}
}
osg::BoundingBox OccluderGeometry::computeBound() const
osg::BoundingBox OccluderGeometry::computeBoundingBox() const
{
osg::BoundingBox bb;
for(Vec3List::const_iterator itr = _vertices.begin();
@@ -989,7 +989,7 @@ void ShadowVolumeGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
}
}
osg::BoundingBox ShadowVolumeGeometry::computeBound() const
osg::BoundingBox ShadowVolumeGeometry::computeBoundingBox() const
{
osg::BoundingBox bb;
for(Vec3List::const_iterator itr = _vertices.begin();

View File

@@ -114,7 +114,7 @@ void ImpostorSprite::drawImplementation(osg::RenderInfo& renderInfo) const
gl.End();
}
osg::BoundingBox ImpostorSprite::computeBound() const
osg::BoundingBox ImpostorSprite::computeBoundingBox() const
{
osg::BoundingBox bbox;
bbox.expandBy(_coords[0]);

View File

@@ -174,7 +174,7 @@ void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
#endif
}
osg::BoundingBox LightPointDrawable::computeBound() const
osg::BoundingBox LightPointDrawable::computeBoundingBox() const
{
osg::BoundingBox bbox;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -35,7 +35,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
public :
LightPointDrawable();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
LightPointDrawable(const LightPointDrawable&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
@@ -44,7 +44,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const LightPointDrawable*>(obj)!=NULL; }
virtual const char* className() const { return "LightPointDrawable"; }
//typedef std::pair<unsigned int,osg::Vec3> ColorPosition;
struct ColorPosition
{
@@ -53,7 +53,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
ColorPosition() {}
ColorPosition(unsigned int f,const osg::Vec3& s):first(f),second(s) {}
};
void reset();
inline unsigned int asRGBA(const osg::Vec4& color) const
@@ -78,7 +78,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
if (pointSize>=_sizedBlendedLightPointList.size()) _sizedBlendedLightPointList.resize(pointSize+1);
_sizedBlendedLightPointList[pointSize].push_back(ColorPosition(asRGBA(color),position));
}
/** draw LightPoints. */
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
@@ -94,21 +94,21 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
_simulationTimeInterval = osg::clampAbove(time-_simulationTime,0.0);
_simulationTime = time;
}
double getSimulationTime() const { return _simulationTime; }
double getSimulationTimeInterval() const { return _simulationTimeInterval; }
virtual osg::BoundingBox computeBound() const;
virtual osg::BoundingBox computeBoundingBox() const;
protected:
virtual ~LightPointDrawable() {}
osg::Endian _endian;
double _simulationTime;
double _simulationTimeInterval;
typedef std::vector<ColorPosition> LightPointList;
typedef std::vector<LightPointList> SizedLightPointList;
@@ -122,7 +122,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
osg::ref_ptr<osg::BlendFunc> _blendOneMinusSrcAlpha;
osg::ref_ptr<osg::ColorMask> _colorMaskOff;
};
}

View File

@@ -1248,7 +1248,7 @@ void OverlayNode::traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeV
osg::BoundingSphere bs;
for(unsigned int i=0; i<camera->getNumChildren(); ++i)
{
bs.expandBy(camera->getChild(i)->getBound());
bs.expandBy(static_cast<const osg::BoundingSphere&>(camera->getChild(i)->getBound()));
}
if (bs.valid())

View File

@@ -55,7 +55,7 @@ public:
void drawImplementation(osg::RenderInfo& renderInfo) const;
virtual osg::BoundingBox computeBound() const;
virtual osg::BoundingBox computeBoundingBox() const;
protected:
@@ -69,7 +69,7 @@ void SphereSegment::Surface::drawImplementation(osg::RenderInfo& renderInfo) con
_ss->Surface_drawImplementation(*renderInfo.getState());
}
osg:: BoundingBox SphereSegment::Surface::computeBound() const
osg:: BoundingBox SphereSegment::Surface::computeBoundingBox() const
{
osg:: BoundingBox bbox;
_ss->Surface_computeBound(bbox);
@@ -114,7 +114,7 @@ protected:
}
virtual osg::BoundingBox computeBound() const;
virtual osg::BoundingBox computeBoundingBox() const;
private:
@@ -126,7 +126,7 @@ void SphereSegment::EdgeLine::drawImplementation(osg::RenderInfo& renderInfo) co
_ss->EdgeLine_drawImplementation(*renderInfo.getState());
}
osg::BoundingBox SphereSegment::EdgeLine::computeBound() const
osg::BoundingBox SphereSegment::EdgeLine::computeBoundingBox() const
{
osg::BoundingBox bbox;
_ss->EdgeLine_computeBound(bbox);
@@ -167,7 +167,7 @@ protected:
"Warning: unexpected call to osgSim::SphereSegment::Side() copy constructor"<<std::endl;
}
virtual osg::BoundingBox computeBound() const;
virtual osg::BoundingBox computeBoundingBox() const;
private:
SphereSegment* _ss;
@@ -181,7 +181,7 @@ void SphereSegment::Side::drawImplementation(osg::RenderInfo& renderInfo) const
_ss->Side_drawImplementation(*renderInfo.getState(), _planeOrientation, _BoundaryAngle);
}
osg::BoundingBox SphereSegment::Side::computeBound() const
osg::BoundingBox SphereSegment::Side::computeBoundingBox() const
{
osg::BoundingBox bbox;
_ss->Side_computeBound(bbox, _planeOrientation, _BoundaryAngle);
@@ -230,7 +230,7 @@ protected:
//getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF);
}
virtual osg::BoundingBox computeBound() const;
virtual osg::BoundingBox computeBoundingBox() const;
private:
SphereSegment* _ss;
@@ -242,7 +242,7 @@ void SphereSegment::Spoke::drawImplementation(osg::RenderInfo& renderInfo) const
_ss->Spoke_drawImplementation(*renderInfo.getState(), _azAngle, _elevAngle);
}
osg::BoundingBox SphereSegment::Spoke::computeBound() const
osg::BoundingBox SphereSegment::Spoke::computeBoundingBox() const
{
osg::BoundingBox bbox;
_ss->Spoke_computeBound(bbox, _azAngle, _elevAngle);
@@ -1049,7 +1049,7 @@ class PolytopeVisitor : public osg::NodeVisitor
{
for(unsigned int i=0; i<node.getNumDrawables(); ++i)
{
if (_polytopeStack.back().second.contains(node.getDrawable(i)->getBound()))
if (_polytopeStack.back().second.contains(node.getDrawable(i)->getBoundingBox()))
{
_hits.push_back(Hit(_polytopeStack.back().first,getNodePath(),node.getDrawable(i)));
}

View File

@@ -409,7 +409,7 @@ void Text3D::computeGlyphRepresentation()
TextBase::computePositions();
}
osg::BoundingBox Text3D::computeBound() const
osg::BoundingBox Text3D::computeBoundingBox() const
{
osg::BoundingBox bbox;

View File

@@ -268,7 +268,7 @@ void TextBase::setBoundingBoxMargin(float margin)
}
osg::BoundingBox TextBase::computeBound() const
osg::BoundingBox TextBase::computeBoundingBox() const
{
osg::BoundingBox bbox;

View File

@@ -656,8 +656,8 @@ void PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable
// OSG_NOTICE<<"PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable)"<<std::endl;
if (reachedLimit()) return;
if ( _plane.intersect( drawable->getBound() )!=0 ) return;
if ( !_polytope.contains( drawable->getBound() ) ) return;
if ( _plane.intersect( drawable->getBoundingBox() )!=0 ) return;
if ( !_polytope.contains( drawable->getBoundingBox() ) ) return;
// OSG_NOTICE<<"Succed PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable)"<<std::endl;

View File

@@ -559,7 +559,7 @@ void PolytopeIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawa
{
if (reachedLimit()) return;
if ( !_polytope.contains( drawable->getBound() ) ) return;
if ( !_polytope.contains( drawable->getBoundingBox() ) ) return;
osg::TemplatePrimitiveFunctor<PolytopeIntersectorUtils::PolytopePrimitiveIntersector> func;
func.setPolytope( _polytope, _referencePlane );