OpenSceneGraph/src/osg/Switch.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

#include <osg/Switch>
2001-01-11 00:32:10 +08:00
#include <algorithm>
using namespace osg;
/**
* Switch constructor. The default setting of _value is
* ALL_CHILDREN_OFF.
*/
2001-01-11 00:32:10 +08:00
Switch::Switch()
{
_value = ALL_CHILDREN_OFF;
}
Switch::Switch(const Switch& sw,const Cloner& cloner):
Group(sw,cloner),
_value(sw._value)
{
}
2001-01-11 00:32:10 +08:00
void Switch::traverse(NodeVisitor& nv)
{
switch(nv.getTraversalMode())
2001-01-11 00:32:10 +08:00
{
case(NodeVisitor::TRAVERSE_ALL_CHILDREN):
2001-01-11 00:32:10 +08:00
std::for_each(_children.begin(),_children.end(),NodeAcceptOp(nv));
break;
case(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN):
switch(_value)
{
case(ALL_CHILDREN_ON):
std::for_each(_children.begin(),_children.end(),NodeAcceptOp(nv));
break;
case(ALL_CHILDREN_OFF):
return;
default:
if (_value>=0 && (unsigned int)_value<_children.size()) _children[_value]->accept(nv);
break;
}
break;
2001-01-11 00:32:10 +08:00
default:
break;
}
}