From 333a16a88dba0416277912b607a49e48cf235435 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 3 Jun 2014 09:52:55 +0000 Subject: [PATCH] Reverted change of Node::ParentList from being a vector back to a vector --- .../osgkeyboardmouse/osgkeyboardmouse.cpp | 3 +-- .../osgparticleeffects/osgparticleeffects.cpp | 2 +- include/osg/Node | 24 ++++--------------- src/osg/Node.cpp | 8 +++---- src/osgPlugins/txp/TXPParser.cpp | 3 +-- src/osgUtil/Optimizer.cpp | 2 +- 6 files changed, 13 insertions(+), 29 deletions(-) diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index 1ca31d7b1..6513abadd 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -104,8 +104,7 @@ public: pitr != parents.end(); ++pitr) { - osg::Node* parent = *pitr; - parent->removeChild(node); + (*pitr)->removeChild(node); } } } diff --git a/examples/osgparticleeffects/osgparticleeffects.cpp b/examples/osgparticleeffects/osgparticleeffects.cpp index 78517a589..4b9ae93e4 100644 --- a/examples/osgparticleeffects/osgparticleeffects.cpp +++ b/examples/osgparticleeffects/osgparticleeffects.cpp @@ -334,7 +334,7 @@ public: // particle effect can be inserted into this. osg::ref_ptr hitNode = hit.nodePath.back(); osg::Node::ParentList parents = hitNode->getParents(); - osg::Node* insertGroup = 0; + osg::Group* insertGroup = 0; unsigned int numGroupsFound = 0; for(osg::Node::ParentList::iterator itr=parents.begin(); itr!=parents.end(); diff --git a/include/osg/Node b/include/osg/Node index 8a7533905..dcd9d508d 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -166,7 +166,7 @@ class OSG_EXPORT Node : public Object virtual void traverse(NodeVisitor& /*nv*/) {} /** A vector of osg::Group pointers which is used to store the parent(s) of node.*/ - typedef std::vector ParentList; + typedef std::vector ParentList; /** Get the parent list of node. */ inline const ParentList& getParents() const { return _parents; } @@ -175,14 +175,14 @@ class OSG_EXPORT Node : public Object * prevent modification of the parent list.*/ inline ParentList getParents() { return _parents; } - inline Node* getParent(unsigned int i) { return _parents[i]; } + inline Group* getParent(unsigned int i) { return _parents[i]; } /** * Get a single const parent of node. * @param i index of the parent to get. * @return the parent i. */ - inline const Node* getParent(unsigned int i) const { return _parents[i]; } + inline const Group* getParent(unsigned int i) const { return _parents[i]; } /** * Get the number of parents of node. @@ -192,20 +192,6 @@ class OSG_EXPORT Node : public Object - /** Provide interface for Composite like Group nodes to implement.*/ - virtual unsigned int getNumChildren() const { return 0; } - - /** Provide interface for Composite like Group nodes to implement.*/ - virtual bool addChild( Node* /*child*/ ) { return false; } - - /** Provide interface for Composite like Group nodes to implement.*/ - virtual bool removeChild( Node* /*child*/ ) { return false; } - - /** Provide interface for Composite like Group nodes to implement.*/ - virtual bool replaceChild( Node* /*origChild*/, Node* /*newChild*/ ) { return false; } - - - /** Get the list of node paths parent paths. * The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. */ NodePathList getParentalNodePaths(osg::Node* haltTraversalAtNode=0) const; @@ -483,8 +469,8 @@ class OSG_EXPORT Node : public Object mutable BoundingSphere _boundingSphere; mutable bool _boundingSphereComputed; - void addParent(osg::Node* node); - void removeParent(osg::Node* node); + void addParent(osg::Group* parent); + void removeParent(osg::Group* parent); ParentList _parents; friend class osg::Group; diff --git a/src/osg/Node.cpp b/src/osg/Node.cpp index 2e3ff4383..e1783ad91 100644 --- a/src/osg/Node.cpp +++ b/src/osg/Node.cpp @@ -95,18 +95,18 @@ Node::~Node() setStateSet(0); } -void Node::addParent(osg::Node* node) +void Node::addParent(osg::Group* parent) { OpenThreads::ScopedPointerLock lock(getRefMutex()); - _parents.push_back(node); + _parents.push_back(parent); } -void Node::removeParent(osg::Node* node) +void Node::removeParent(osg::Group* parent) { OpenThreads::ScopedPointerLock lock(getRefMutex()); - ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),node); + ParentList::iterator pitr = std::find(_parents.begin(), _parents.end(), parent); if (pitr!=_parents.end()) _parents.erase(pitr); } diff --git a/src/osgPlugins/txp/TXPParser.cpp b/src/osgPlugins/txp/TXPParser.cpp index 4cccde3b9..ee1567538 100644 --- a/src/osgPlugins/txp/TXPParser.cpp +++ b/src/osgPlugins/txp/TXPParser.cpp @@ -316,8 +316,7 @@ void TXPParser::removeEmptyGroups() osg::Node::ParentList parents = node->getParents(); for (unsigned int j = 0; j < parents.size(); j++) { - osg::Node* parent = parents[j]; - if (parent) parent->removeChild(node); + parents[j]->removeChild(node); } } } diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index dbf9fe2fb..9a007f037 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -1387,7 +1387,7 @@ void Optimizer::RemoveEmptyNodesVisitor::removeEmptyNodes() pitr!=parents.end(); ++pitr) { - osg::Node* parent = *pitr; + osg::Group* parent = *pitr; if (!dynamic_cast(parent) && !dynamic_cast(parent) && strcmp(parent->className(),"MultiSwitch")!=0)