diff --git a/CMakeLists.txt b/CMakeLists.txt index d414fe1d3..4d6e0b2e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -443,6 +443,9 @@ 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) diff --git a/examples/osgforest/osgforest.cpp b/examples/osgforest/osgforest.cpp index ba92df763..e37e9608f 100644 --- a/examples/osgforest/osgforest.cpp +++ b/examples/osgforest/osgforest.cpp @@ -812,9 +812,9 @@ class ShaderGeometry : public osg::Drawable } } - virtual osg::BoundingBox computeBound() const + virtual osg::BoundingBox computeBoundingBox() const { - osg::BoundingBox geom_box = _geometry->getBound(); + osg::BoundingBox geom_box = _geometry->getBoundingBox(); osg::BoundingBox bb; for(PositionSizeList::const_iterator itr = _trees.begin(); itr != _trees.end(); diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index d9d1f1fbe..1ca31d7b1 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -44,12 +44,12 @@ class CreateModelToSaveVisitor : public osg::NodeVisitor public: CreateModelToSaveVisitor(): - osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _group = new osg::Group; _addToModel = false; } - + virtual void apply(osg::Node& node) { osgFX::Scribe* scribe = dynamic_cast(&node); @@ -65,7 +65,7 @@ public: traverse(node); } } - + osg::ref_ptr _group; bool _addToModel; }; @@ -75,10 +75,10 @@ class DeleteSelectedNodesVisitor : public osg::NodeVisitor public: DeleteSelectedNodesVisitor(): - osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { } - + virtual void apply(osg::Node& node) { osgFX::Scribe* scribe = dynamic_cast(&node); @@ -91,7 +91,7 @@ public: traverse(node); } } - + void pruneSelectedNodes() { for(SelectedNodes::iterator itr = _selectedNodes.begin(); @@ -104,21 +104,21 @@ public: pitr != parents.end(); ++pitr) { - osg::Group* parent = *pitr; + osg::Node* parent = *pitr; parent->removeChild(node); } } } - + typedef std::vector< osg::ref_ptr > SelectedNodes; SelectedNodes _selectedNodes; - + }; // class to handle events with a pick -class PickHandler : public osgGA::GUIEventHandler +class PickHandler : public osgGA::GUIEventHandler { -public: +public: PickHandler(): _mx(0.0),_my(0.0), @@ -139,7 +139,7 @@ public: if (ea.getKey()=='s') { saveSelectedModel(viewer->getSceneData()); - } + } else if (ea.getKey()=='o') { osg::notify(osg::NOTICE)<<"Saved model to file 'saved_model.osgt'"<=1)?nodePath[nodePath.size()-1]:0; parent = (nodePath.size()>=2)?dynamic_cast(nodePath[nodePath.size()-2]):0; - if (node) std::cout<<" Hits "<className()<<" nodePath size "<className()<<" nodePath size "<className()<<" nodePath size"<accept(cmtsv); - + if (cmtsv._group->getNumChildren()>0) { std::cout<<"Writing selected compoents to 'selected_model.osgt'"< loadedModel; - + // load the scene. if (argc>1) loadedModel = osgDB::readNodeFile(argv[1]); - + // if not loaded assume no arguments passed in, try use default mode instead. if (!loadedModel) loadedModel = osgDB::readNodeFile("dumptruck.osgt"); - - if (!loadedModel) + + if (!loadedModel) { std::cout << argv[0] <<": No data loaded." << std::endl; return 1; } - + // create the window to draw to. osg::ref_ptr traits = new osg::GraphicsContext::Traits; traits->x = 200; @@ -376,7 +376,7 @@ int main( int argc, char **argv ) viewer.getCamera()->setGraphicsContext(gc.get()); viewer.getCamera()->setViewport(0,0,800,600); viewer.setSceneData(loadedModel.get()); - + // create a tracball manipulator to move the camera around in response to keyboard/mouse events viewer.setCameraManipulator( new osgGA::TrackballManipulator ); diff --git a/examples/osgoit/HeatMap.cpp b/examples/osgoit/HeatMap.cpp index 4b381e6fa..7e069c5d9 100644 --- a/examples/osgoit/HeatMap.cpp +++ b/examples/osgoit/HeatMap.cpp @@ -81,7 +81,7 @@ public: // an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map. virtual const osg::BoundingBox& getBoundingBox() const {return m_bounds;} - virtual osg::BoundingBox computeBound() const {return m_bounds;} + virtual osg::BoundingBox computeBoundingBox() const {return m_bounds;} virtual const osg::BoundingSphere& getBound() const {return m_bsphere;} protected: diff --git a/examples/osgparticleeffects/osgparticleeffects.cpp b/examples/osgparticleeffects/osgparticleeffects.cpp index cf9af6d44..78517a589 100644 --- a/examples/osgparticleeffects/osgparticleeffects.cpp +++ b/examples/osgparticleeffects/osgparticleeffects.cpp @@ -42,33 +42,33 @@ // for the grid data.. #include "../osghangglide/terrain_coords.h" -osg::Vec3 wind(1.0f,0.0f,0.0f); +osg::Vec3 wind(1.0f,0.0f,0.0f); osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime) { - // set up the animation path + // set up the animation path osg::AnimationPath* animationPath = new osg::AnimationPath; animationPath->setLoopMode(osg::AnimationPath::LOOP); - + int numSamples = 40; float yaw = 0.0f; float yaw_delta = 2.0f*osg::PI/((float)numSamples-1.0f); float roll = osg::inDegrees(30.0f); - + double time=0.0f; double time_delta = looptime/(double)numSamples; for(int i=0;iinsert(time,osg::AnimationPath::ControlPoint(position,rotation)); yaw += yaw_delta; time += time_delta; } - return animationPath; + return animationPath; } osg::Node* createMovingModel(const osg::Vec3& center, float radius) @@ -90,9 +90,9 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) positioned->setMatrix(osg::Matrix::translate(-bs.center())* osg::Matrix::scale(size,size,size)* osg::Matrix::rotate(osg::inDegrees(-90.0f),0.0f,0.0f,1.0f)); - + positioned->addChild(glider); - + osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform; xform->setDataVariance(osg::Object::DYNAMIC); xform->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); @@ -101,7 +101,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) model->addChild(xform); } - + osg::Node* cessna = osgDB::readNodeFile("cessna.osgt"); if (cessna) { @@ -114,10 +114,10 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) positioned->setMatrix(osg::Matrix::translate(-bs.center())* osg::Matrix::scale(size,size,size)* osg::Matrix::rotate(osg::inDegrees(180.0f),0.0f,0.0f,1.0f)); - + //positioned->addChild(cessna); positioned->addChild(cessna); - + osg::MatrixTransform* xform = new osg::MatrixTransform; xform->setDataVariance(osg::Object::DYNAMIC); xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,1.0)); @@ -125,7 +125,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) model->addChild(xform); } - + return model; } @@ -135,8 +135,8 @@ osg::Vec3 computeTerrainIntersection(osg::Node* subgraph,float x,float y) const osg::BoundingSphere& bs = subgraph->getBound(); float zMax = bs.center().z()+bs.radius(); float zMin = bs.center().z()-bs.radius(); - - osg::ref_ptr intersector = + + osg::ref_ptr intersector = new osgUtil::LineSegmentIntersector(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax)); osgUtil::IntersectionVisitor iv(intersector.get()); @@ -190,13 +190,13 @@ void build_world(osg::Group *root) } } terrainGeode->addDrawable(new osg::ShapeDrawable(grid)); - + root->addChild(terrainGeode); - } + } // create particle effects - { + { osg::Vec3 position = computeTerrainIntersection(terrainGeode,100.0f,100.0f); osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, 10.0f); @@ -214,9 +214,9 @@ void build_world(osg::Group *root) root->addChild(smoke); root->addChild(fire); } - + // create particle effects - { + { osg::Vec3 position = computeTerrainIntersection(terrainGeode,200.0f,100.0f); osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, 1.0f); @@ -244,10 +244,10 @@ void build_world(osg::Group *root) // class to handle events with a pick class PickHandler : public osgGA::GUIEventHandler { -public: +public: + + PickHandler() {} - PickHandler() {} - bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) { switch(ea.getEventType()) @@ -266,9 +266,9 @@ public: void pick(osgViewer::Viewer* viewer, const osgGA::GUIEventAdapter& ea) { - osg::Group* root = dynamic_cast(viewer->getSceneData()); + osg::Group* root = dynamic_cast(viewer->getSceneData()); if (!root) return; - + osgUtil::LineSegmentIntersector::Intersections intersections; if (viewer->computeIntersections(ea,intersections)) { @@ -286,7 +286,7 @@ public: if (transform->getDataVariance()==osg::Object::DYNAMIC) handleMovingModels=true; } } - + osg::Vec3 position = handleMovingModels ? hit.getLocalIntersectPoint() : hit.getWorldIntersectPoint(); float scale = 10.0f * ((float)rand() / (float)RAND_MAX); float intensity = 1.0f; @@ -299,7 +299,7 @@ public: smoke = new osgParticle::SmokeTrailEffect(position, scale, intensity); else smoke = new osgParticle::SmokeEffect(position, scale, intensity); - + explosion->setWind(wind); explosionDebri->setWind(wind); smoke->setWind(wind); @@ -310,17 +310,17 @@ public: effectsGroup->addChild(explosionDebri); effectsGroup->addChild(smoke); effectsGroup->addChild(fire); - + if (handleMovingModels) { // insert particle effects alongside the hit node, therefore able to track that nodes movement, // however, this does require us to insert the ParticleSystem itself into the root of the scene graph // separately from the the main particle effects group which contains the emitters and programs. - // the follow code block implements this, note the path for handling particle effects which arn't attached to + // the follow code block implements this, note the path for handling particle effects which arn't attached to // moving models is easy - just a single line of code! - - // tell the effects not to attach to the particle system locally for rendering, as we'll handle add it into the + + // tell the effects not to attach to the particle system locally for rendering, as we'll handle add it into the // scene graph ourselves. explosion->setUseLocalParticleSystem(false); explosionDebri->setUseLocalParticleSystem(false); @@ -333,8 +333,8 @@ public: // is found then this needs to be inserted above the hit node, and then the // particle effect can be inserted into this. osg::ref_ptr hitNode = hit.nodePath.back(); - osg::Node::ParentList parents = hitNode->getParents(); - osg::Group* insertGroup = 0; + osg::Node::ParentList parents = hitNode->getParents(); + osg::Node* insertGroup = 0; unsigned int numGroupsFound = 0; for(osg::Node::ParentList::iterator itr=parents.begin(); itr!=parents.end(); @@ -345,7 +345,7 @@ public: ++numGroupsFound; insertGroup = *itr; } - } + } if (numGroupsFound==parents.size() && numGroupsFound==1 && insertGroup) { osg::notify(osg::INFO)<<"PickHandler::pick(,) hit node's parent is a single osg::Group so we can simple the insert the particle effects group here."<addChild(effectsGroup); } else - { + { osg::notify(osg::INFO)<<"PickHandler::pick(,) hit node doesn't have an appropriate osg::Group node to insert particle effects into, inserting a new osg::Group."<addDrawable(explosionDebri->getParticleSystem()); geode->addDrawable(smoke->getParticleSystem()); geode->addDrawable(fire->getParticleSystem()); - + root->addChild(geode); } @@ -385,15 +385,15 @@ public: root->addChild(effectsGroup); } -#if 0 +#if 0 osg::Geode* geode = new osg::Geode; geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(position,scale))); group->addChild(geode); #endif - + } } - + protected: virtual ~PickHandler() {} }; @@ -403,7 +403,7 @@ void insertParticle(osg::Group* root, const osg::Vec3& center, float radius) { bool handleMovingModels = false; - osg::Vec3 position = center + + osg::Vec3 position = center + osg::Vec3( radius * (((float)rand() / (float)RAND_MAX)-0.5)*2.0, radius * (((float)rand() / (float)RAND_MAX)-0.5)*2.0, 0.0f); @@ -445,15 +445,15 @@ int main(int, char **) // register the pick handler viewer.addEventHandler(new PickHandler()); - + osg::Group *root = new osg::Group; build_world(root); osgUtil::Optimizer optimizer; optimizer.optimize(root); - + // add a viewport to the viewer and attach the scene graph. viewer.setSceneData(root); - + return viewer.run(); } diff --git a/examples/osgteapot/osgteapot.cpp b/examples/osgteapot/osgteapot.cpp index 112849cfe..d11820a82 100644 --- a/examples/osgteapot/osgteapot.cpp +++ b/examples/osgteapot/osgteapot.cpp @@ -238,19 +238,19 @@ class Teapot : public osg::Drawable // teapot(..) doens't use vertex arrays at all so we don't need to toggle their state // if we did we'd need to something like following call // state.disableAllVertexArrays(), see src/osg/Geometry.cpp for the low down. - + // just call the OpenGL code. teapot(14,GL_FILL); } - - + + // we need to set up the bounding box of the data too, so that the scene graph knows where this // objects is, for both positioning the camera at start up, and most importantly for culling. - virtual osg::BoundingBox computeBound() const + virtual osg::BoundingBox computeBoundingBox() const { osg::BoundingBox bbox; - // follow is some truely horrible code required to calculate the + // follow is some truely horrible code required to calculate the // bounding box of the teapot. Have used the original code above to do // help compute it. float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3]; @@ -259,13 +259,13 @@ class Teapot : public osg::Drawable for (i = 0; i < 10; i++) { for (j = 0; j < 4; j++) { for (k = 0; k < 4; k++) { - + for (l = 0; l < 3; l++) { p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; if (l == 1) q[j][k][l] *= -1.0; - + if (i < 6) { r[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; @@ -278,7 +278,7 @@ class Teapot : public osg::Drawable s[j][k][l] *= -1.0; } } - + bbox.expandBy(osg::Vec3(p[j][k][0],p[j][k][1],p[j][k][2])); bbox.expandBy(osg::Vec3(q[j][k][0],q[j][k][1],q[j][k][2])); @@ -287,8 +287,8 @@ class Teapot : public osg::Drawable bbox.expandBy(osg::Vec3(r[j][k][0],r[j][k][1],r[j][k][2])); bbox.expandBy(osg::Vec3(s[j][k][0],s[j][k][1],s[j][k][2])); } - - + + } } } @@ -297,9 +297,9 @@ class Teapot : public osg::Drawable } protected: - + virtual ~Teapot() {} - + }; @@ -310,7 +310,7 @@ osg::Geode* createTeapot() // add the teapot to the geode. geode->addDrawable( new Teapot ); - // add a reflection map to the teapot. + // add a reflection map to the teapot. osg::Image* image = osgDB::readImageFile("Images/reflect.rgb"); if (image) { @@ -323,10 +323,10 @@ osg::Geode* createTeapot() osg::StateSet* stateset = new osg::StateSet; stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(0,texgen,osg::StateAttribute::ON); - + geode->setStateSet(stateset); } - + return geode; } @@ -335,8 +335,8 @@ int main(int , char **) #if 1 // create viewer on heap as a test, this looks to be causing problems - // on init on some platforms, and seg fault on exit when multi-threading on linux. - // Normal stack based version below works fine though... + // on init on some platforms, and seg fault on exit when multi-threading on linux. + // Normal stack based version below works fine though... // construct the viewer. osg::ref_ptr viewer = new osgViewer::Viewer; @@ -345,7 +345,7 @@ int main(int , char **) viewer->setSceneData( createTeapot() ); return viewer->run(); - + #else // construct the viewer. diff --git a/include/osg/CullingSet b/include/osg/CullingSet index a22b99c35..d0b00693f 100644 --- a/include/osg/CullingSet +++ b/include/osg/CullingSet @@ -271,6 +271,12 @@ class OSG_EXPORT CullingSet : public Referenced return false; } + inline bool isCulled(const Bound& bound) + { + if (bound.bb) return isCulled(*bound.bb); + else return isCulled(*bound.bs); + } + inline void pushCurrentMask() { _frustum.pushCurrentMask(); diff --git a/include/osg/DrawPixels b/include/osg/DrawPixels index 14c66b4ed..ae0519551 100644 --- a/include/osg/DrawPixels +++ b/include/osg/DrawPixels @@ -59,7 +59,7 @@ class OSG_EXPORT DrawPixels : public Drawable virtual void drawImplementation(RenderInfo& renderInfo) const; - virtual BoundingBox computeBound() const; + virtual BoundingBox computeBoundingBox() const; protected: diff --git a/include/osg/Drawable b/include/osg/Drawable index beb9f2602..17a75f374 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -19,6 +19,7 @@ #include #include #include +#include #ifndef GL_NV_occlusion_query @@ -90,7 +91,7 @@ class ArrayDispatchers; * Geodes, so that the same geometry (loaded to memory just once) can * be used in different parts of the scene graph. */ -class OSG_EXPORT Drawable : public Object +class OSG_EXPORT Drawable : public Node { public: @@ -103,9 +104,7 @@ class OSG_EXPORT Drawable : public Object /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ Drawable(const Drawable& drawable,const CopyOp& copyop=CopyOp::SHALLOW_COPY); - virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } - virtual const char* libraryName() const { return "osg"; } - virtual const char* className() const { return "Drawable"; } + META_Node(osg, Drawable); /** Convert 'this' into a Geometry pointer if Drawable is a Geometry, otherwise return 0. * Equivalent to dynamic_cast(this).*/ @@ -115,94 +114,44 @@ class OSG_EXPORT Drawable : public Object * Equivalent to dynamic_cast(this).*/ virtual const Geometry* asGeometry() const { return 0; } - /** Visitor Pattern : calls the apply method of a NodeVisitor with this drawable's type.*/ - virtual void accept(NodeVisitor& nv); - /** Compute the DataVariance based on an assessment of callback etc.*/ virtual void computeDataVariance(); - - /** A vector of osg::Node pointers which is used to store the parent(s) of drawable.*/ - typedef std::vector ParentList; - - /** Get the parent list of drawable. */ - inline const ParentList& getParents() const { return _parents; } - - /** Get the a copy of parent list of node. A copy is returned to - * prevent modification of the parent list.*/ - inline ParentList getParents() { return _parents; } - - /** Get a single parent of Drawable. - * @param i index of the parent to get. - * @return the parent i. - */ - inline Node* getParent(unsigned int i) { return _parents[i]; } - /** Get a single const parent of Drawable. - * @param i index of the parent to get. - * @return the parent i. - */ - inline const Node* getParent(unsigned int i) const { return _parents[i]; } - - /** - * Get the number of parents of node. - * @return the number of parents of this node. - */ - inline unsigned int getNumParents() const { return static_cast(_parents.size()); } - /** Get the list of matrices that transform this node from local coordinates to world coordinates. * The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. */ MatrixList getWorldMatrices(const osg::Node* haltTraversalAtNode=0) const; - /** Set the StateSet attached to the Drawable. - Previously attached StateSet are automatically unreferenced on - assignment of a new drawstate.*/ - void setStateSet(StateSet* stateset); - - /** Get the attached StateSet.*/ - inline StateSet* getStateSet() { return _stateset.get();} - - /** Get the attached const StateSet.*/ - inline const StateSet* getStateSet() const { return _stateset.get();} - - /** Get the attached const StateSet, - * if one is not already attached create one, - * attach it to the drawable and return a pointer to it.*/ - StateSet* getOrCreateStateSet(); - - /** Set the initial bounding volume to use when computing the overall bounding volume.*/ void setInitialBound(const osg::BoundingBox& bbox) { _initialBound = bbox; dirtyBound(); } /** Set the initial bounding volume to use when computing the overall bounding volume.*/ const BoundingBox& getInitialBound() const { return _initialBound; } - /** Dirty the bounding box, forcing a computeBound() on the next call - * to getBound(). Should be called in the internal geometry of the Drawable - * is modified.*/ - void dirtyBound(); - /** Get BoundingBox of Drawable. * If the BoundingBox is not up to date then its updated via an internal call to computeBond(). */ - inline const BoundingBox& getBound() const + inline const BoundingBox& getBoundingBox() const { - if(!_boundingBoxComputed) + if(!_boundingSphereComputed) { _boundingBox = _initialBound; if (_computeBoundCallback.valid()) _boundingBox.expandBy(_computeBoundCallback->computeBound(*this)); else - _boundingBox.expandBy(computeBound()); + _boundingBox.expandBy(computeBoundingBox()); - _boundingBoxComputed = true; + _boundingSphereComputed = true; } return _boundingBox; } + /** Compute the bounding sphere around Drawables's geometry.*/ + virtual BoundingSphere computeBound() const; + /** Compute the bounding box around Drawables's geometry.*/ - virtual BoundingBox computeBound() const; + virtual BoundingBox computeBoundingBox() const; /** Callback to allow users to override the default computation of bounding volume. */ struct ComputeBoundingBoxCallback : public osg::Object @@ -418,7 +367,7 @@ class OSG_EXPORT Drawable : public Object * drawImplementation(RenderInfo&) is called from the draw(RenderInfo&) method, with the draw method handling management of OpenGL display lists, * and drawImplementation(RenderInfo&) handling the actual drawing itself. * @param renderInfo The osg::RenderInfo object that encapsulates the current rendering information including the osg::State OpenGL state for the current graphics context. */ - virtual void drawImplementation(RenderInfo& renderInfo) const = 0; + virtual void drawImplementation(RenderInfo& /*renderInfo*/) const {} /** Return a OpenGL display list handle a newly generated or reused from display list cache. */ @@ -810,20 +759,13 @@ class OSG_EXPORT Drawable : public Object virtual ~Drawable(); - /** set the bounding box .*/ void setBound(const BoundingBox& bb) const; - void addParent(osg::Node* node); - void removeParent(osg::Node* node); - - ParentList _parents; friend class Node; friend class Geode; friend class StateSet; - ref_ptr _stateset; - BoundingBox _initialBound; ref_ptr _computeBoundCallback; mutable BoundingBox _boundingBox; @@ -840,14 +782,7 @@ class OSG_EXPORT Drawable : public Object mutable GLObjectList _globjList; ref_ptr _updateCallback; - unsigned int _numChildrenRequiringUpdateTraversal; - void setNumChildrenRequiringUpdateTraversal(unsigned int num); - unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; } - ref_ptr _eventCallback; - unsigned int _numChildrenRequiringEventTraversal; - void setNumChildrenRequiringEventTraversal(unsigned int num); - unsigned int getNumChildrenRequiringEventTraversal() const { return _numChildrenRequiringEventTraversal; } ref_ptr _cullCallback; ref_ptr _drawCallback; diff --git a/include/osg/Node b/include/osg/Node index 1b410a0ba..bfbc851cf 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,46 @@ 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 * more convenient to define the required pure virtual methods.*/ @@ -395,7 +436,23 @@ class OSG_EXPORT Node : public Object /** Get the bounding sphere of node. Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/ - inline const BoundingSphere& getBound() const +#ifdef OSG_USE_BOUND + inline 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 BoundingSphere getBound() const { if(!_boundingSphereComputed) { @@ -409,7 +466,7 @@ 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 diff --git a/include/osg/Plane b/include/osg/Plane index bb9b03342..512a09809 100644 --- a/include/osg/Plane +++ b/include/osg/Plane @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -321,6 +322,13 @@ 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 diff --git a/include/osg/Polytope b/include/osg/Polytope index 1e9c0c7a7..fb5791966 100644 --- a/include/osg/Polytope +++ b/include/osg/Polytope @@ -289,6 +289,14 @@ 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& vertices) { diff --git a/include/osg/ShapeDrawable b/include/osg/ShapeDrawable index 9f69152a7..a0fcd0c07 100644 --- a/include/osg/ShapeDrawable +++ b/include/osg/ShapeDrawable @@ -181,7 +181,7 @@ class OSG_EXPORT ShapeDrawable : public Drawable /** Accept a PrimitiveFunctor and call its methods to tell it about the internal primitives that this Drawable has.*/ virtual void accept(PrimitiveFunctor& pf) const; - virtual BoundingBox computeBound() const; + virtual BoundingBox computeBoundingBox() const; protected: diff --git a/include/osgParticle/ParticleSystem b/include/osgParticle/ParticleSystem index d32c75007..fec42748e 100644 --- a/include/osgParticle/ParticleSystem +++ b/include/osgParticle/ParticleSystem @@ -243,7 +243,7 @@ namespace osgParticle virtual void drawImplementation(osg::RenderInfo& renderInfo) const; - virtual osg::BoundingBox computeBound() const; + virtual osg::BoundingBox computeBoundingBox() const; #ifdef OSGPARTICLE_USE_ReadWriteMutex typedef OpenThreads::ReadWriteMutex ReadWriterMutex; diff --git a/include/osgShadow/OccluderGeometry b/include/osgShadow/OccluderGeometry index c81ae5f08..381cfbca6 100644 --- a/include/osgShadow/OccluderGeometry +++ b/include/osgShadow/OccluderGeometry @@ -69,7 +69,7 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable virtual void drawImplementation(osg::RenderInfo& renderInfo) const; /** Compute the bounding box around occluder geometry.*/ - virtual osg::BoundingBox computeBound() const; + virtual osg::BoundingBox computeBoundingBox() const; typedef std::vector Vec3List; typedef std::vector UIntList; @@ -240,7 +240,7 @@ class OSGSHADOW_EXPORT ShadowVolumeGeometry : public osg::Drawable virtual void drawImplementation(osg::RenderInfo& renderInfo) const; /** Compute the bounding box around occluder geometry.*/ - virtual osg::BoundingBox computeBound() const; + virtual osg::BoundingBox computeBoundingBox() const; public: diff --git a/include/osgSim/ImpostorSprite b/include/osgSim/ImpostorSprite index d086c7a62..a3b22af36 100644 --- a/include/osgSim/ImpostorSprite +++ b/include/osgSim/ImpostorSprite @@ -149,7 +149,7 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable // for debugging purposes. osg::Vec4 _color; - virtual osg::BoundingBox computeBound() const; + virtual osg::BoundingBox computeBoundingBox() const; /** Set the camera node to use for pre rendering the impostor sprite's texture.*/ void setCamera(osg::Camera* camera) { _camera = camera; } diff --git a/include/osgText/Text3D b/include/osgText/Text3D index 21f10de92..6b4a5edf5 100644 --- a/include/osgText/Text3D +++ b/include/osgText/Text3D @@ -113,7 +113,7 @@ class OSGTEXT_EXPORT Text3D : public osgText::TextBase // // forcefully unloaded. friend class Font; - virtual osg::BoundingBox computeBound() const; + virtual osg::BoundingBox computeBoundingBox() const; protected: diff --git a/include/osgText/TextBase b/include/osgText/TextBase index a8ae93ad4..ec02a0127 100644 --- a/include/osgText/TextBase +++ b/include/osgText/TextBase @@ -264,7 +264,7 @@ public: virtual void releaseGLObjects(osg::State* state=0) const; - virtual osg::BoundingBox computeBound() const; + virtual osg::BoundingBox computeBoundingBox() const; protected: diff --git a/src/osg/Config.in b/src/osg/Config.in index 0bc618c14..dd695b6ab 100644 --- a/src/osg/Config.in +++ b/src/osg/Config.in @@ -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 diff --git a/src/osg/DrawPixels.cpp b/src/osg/DrawPixels.cpp index 6b335b808..0919647c6 100644 --- a/src/osg/DrawPixels.cpp +++ b/src/osg/DrawPixels.cpp @@ -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; diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index 8e1d2cbcd..a3d5e68fd 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -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 lock(getRefMutex()); - - _parents.push_back(node); -} - -void Drawable::removeParent(osg::Node* node) -{ - OpenThreads::ScopedPointerLock 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; diff --git a/src/osg/Group.cpp b/src/osg/Group.cpp index 5074ebcbd..39e3aa330 100644 --- a/src/osg/Group.cpp +++ b/src/osg/Group.cpp @@ -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); } } diff --git a/src/osg/ShapeDrawable.cpp b/src/osg/ShapeDrawable.cpp index 186e949ab..39f5b68c3 100644 --- a/src/osg/ShapeDrawable.cpp +++ b/src/osg/ShapeDrawable.cpp @@ -1987,7 +1987,7 @@ void ShapeDrawable::accept(PrimitiveFunctor& pf) const } -BoundingBox ShapeDrawable::computeBound() const +BoundingBox ShapeDrawable::computeBoundingBox() const { BoundingBox bbox; if (_shape.valid()) diff --git a/src/osg/Switch.cpp b/src/osg/Switch.cpp index f6b51301f..7fd22b463 100644 --- a/src/osg/Switch.cpp +++ b/src/osg/Switch.cpp @@ -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(_children[pos]->getBound())); } } return bsphere; diff --git a/src/osgAnimation/RigGeometry.cpp b/src/osgAnimation/RigGeometry.cpp index 3fd358607..a8fe34f9d 100644 --- a/src/osgAnimation/RigGeometry.cpp +++ b/src/osgAnimation/RigGeometry.cpp @@ -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; diff --git a/src/osgParticle/ParticleSystem.cpp b/src/osgParticle/ParticleSystem.cpp index 206a36ee3..3e84bb79c 100644 --- a/src/osgParticle/ParticleSystem.cpp +++ b/src/osgParticle/ParticleSystem.cpp @@ -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) { diff --git a/src/osgPlugins/logo/ReaderWriterLOGO.cpp b/src/osgPlugins/logo/ReaderWriterLOGO.cpp index 0f5b12d06..5b03de9a1 100644 --- a/src/osgPlugins/logo/ReaderWriterLOGO.cpp +++ b/src/osgPlugins/logo/ReaderWriterLOGO.cpp @@ -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); } diff --git a/src/osgShadow/OccluderGeometry.cpp b/src/osgShadow/OccluderGeometry.cpp index 0d14f6523..aac9f4f4f 100644 --- a/src/osgShadow/OccluderGeometry.cpp +++ b/src/osgShadow/OccluderGeometry.cpp @@ -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(); diff --git a/src/osgSim/ImpostorSprite.cpp b/src/osgSim/ImpostorSprite.cpp index 60aba7a40..1c3017c4e 100644 --- a/src/osgSim/ImpostorSprite.cpp +++ b/src/osgSim/ImpostorSprite.cpp @@ -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]); diff --git a/src/osgSim/LightPointDrawable.cpp b/src/osgSim/LightPointDrawable.cpp index 552cdee4a..4f5b4f115 100644 --- a/src/osgSim/LightPointDrawable.cpp +++ b/src/osgSim/LightPointDrawable.cpp @@ -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; diff --git a/src/osgSim/LightPointDrawable.h b/src/osgSim/LightPointDrawable.h index b0251db7d..32cb9cca0 100644 --- a/src/osgSim/LightPointDrawable.h +++ b/src/osgSim/LightPointDrawable.h @@ -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(obj)!=NULL; } virtual const char* className() const { return "LightPointDrawable"; } - + //typedef std::pair 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 LightPointList; typedef std::vector SizedLightPointList; @@ -122,7 +122,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable osg::ref_ptr _blendOneMinusSrcAlpha; osg::ref_ptr _colorMaskOff; - + }; } diff --git a/src/osgSim/OverlayNode.cpp b/src/osgSim/OverlayNode.cpp index e2ac34bc4..1f59f308b 100644 --- a/src/osgSim/OverlayNode.cpp +++ b/src/osgSim/OverlayNode.cpp @@ -1248,7 +1248,7 @@ void OverlayNode::traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeV osg::BoundingSphere bs; for(unsigned int i=0; igetNumChildren(); ++i) { - bs.expandBy(camera->getChild(i)->getBound()); + bs.expandBy(static_cast(camera->getChild(i)->getBound())); } if (bs.valid()) diff --git a/src/osgSim/SphereSegment.cpp b/src/osgSim/SphereSegment.cpp index bcdcb99d2..e6d6472ee 100644 --- a/src/osgSim/SphereSegment.cpp +++ b/src/osgSim/SphereSegment.cpp @@ -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"<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; igetBound())) + if (_polytopeStack.back().second.contains(node.getDrawable(i)->getBoundingBox())) { _hits.push_back(Hit(_polytopeStack.back().first,getNodePath(),node.getDrawable(i))); } diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index ecd64aea1..be40b58ab 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -409,7 +409,7 @@ void Text3D::computeGlyphRepresentation() TextBase::computePositions(); } -osg::BoundingBox Text3D::computeBound() const +osg::BoundingBox Text3D::computeBoundingBox() const { osg::BoundingBox bbox; diff --git a/src/osgText/TextBase.cpp b/src/osgText/TextBase.cpp index 16382067a..608a8b45b 100644 --- a/src/osgText/TextBase.cpp +++ b/src/osgText/TextBase.cpp @@ -268,7 +268,7 @@ void TextBase::setBoundingBoxMargin(float margin) } -osg::BoundingBox TextBase::computeBound() const +osg::BoundingBox TextBase::computeBoundingBox() const { osg::BoundingBox bbox; diff --git a/src/osgUtil/PlaneIntersector.cpp b/src/osgUtil/PlaneIntersector.cpp index 46e239409..4469b403c 100644 --- a/src/osgUtil/PlaneIntersector.cpp +++ b/src/osgUtil/PlaneIntersector.cpp @@ -656,8 +656,8 @@ void PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable // OSG_NOTICE<<"PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* 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)"<getBound() ) ) return; + if ( !_polytope.contains( drawable->getBoundingBox() ) ) return; osg::TemplatePrimitiveFunctor func; func.setPolytope( _polytope, _referencePlane );