diff --git a/include/osg/Switch b/include/osg/Switch index 55ebc8c7d..e7d18e45f 100644 --- a/include/osg/Switch +++ b/include/osg/Switch @@ -45,6 +45,10 @@ class SG_EXPORT Switch : public Group virtual bool addChild( Node *child, bool value ); + virtual bool insertChild( unsigned int index, Node *child ); + + virtual bool insertChild( unsigned int index, Node *child, bool value ); + virtual bool removeChild( Node *child ); void setValue(unsigned int pos,bool value); diff --git a/src/osg/Switch.cpp b/src/osg/Switch.cpp index d2d7a724a..036013b5d 100644 --- a/src/osg/Switch.cpp +++ b/src/osg/Switch.cpp @@ -63,6 +63,29 @@ bool Switch::addChild( Node *child, bool value ) return false; } +bool Switch::insertChild( unsigned int index, Node *child ) +{ + return insertChild(index,child,_newChildDefaultValue); +} + +bool Switch::insertChild( unsigned int index, Node *child, bool value ) +{ + if (Group::insertChild(index,child)) + { + if (index>=_values.size()) + { + _values.push_back(value); + } + else + { + _values.insert(_values.begin()+index, value); + } + + return true; + } + return false; +} + bool Switch::removeChild( Node *child ) { // find the child's position.