From Eric Wing, added missing removeChildren method.

This commit is contained in:
Robert Osfield
2005-12-09 11:22:09 +00:00
parent da2adaec06
commit a8d7234a0b
4 changed files with 47 additions and 23 deletions

View File

@@ -13,6 +13,7 @@
#include <osg/Switch>
#include <osg/BoundingBox>
#include <osg/Transform>
#include <osg/Notify>
#include <algorithm>
@@ -102,13 +103,29 @@ bool Switch::removeChild( Node *child )
{
// find the child's position.
unsigned int pos=getChildIndex(child);
if (pos==_children.size()) return false;
if (pos>=_children.size()) return false;
_values.erase(_values.begin()+pos);
return Group::removeChild(child);
}
bool Switch::removeChild(unsigned int pos,unsigned int numChildrenToRemove)
{
if (pos>=_values.size() || numChildrenToRemove==0) return false;
unsigned int endOfRemoveRange = pos+numChildrenToRemove;
if (endOfRemoveRange>_values.size())
{
notify(DEBUG_INFO)<<"Warning: Switch::removeChild(i,numChildrenToRemove) has been passed an excessive number"<<std::endl;
notify(DEBUG_INFO)<<" of chilren to remove, trimming just to end of value list."<<std::endl;
endOfRemoveRange=_values.size();
}
_values.erase(_values.begin()+pos,_values.begin()+endOfRemoveRange);
return Group::removeChild(pos, numChildrenToRemove);
}
void Switch::setValue(unsigned int pos,bool value)
{
if (pos>=_values.size()) _values.resize(pos+1,_newChildDefaultValue);