OpenSceneGraph/src/osg/Switch.cpp

42 lines
987 B
C++
Raw Normal View History

2001-01-11 00:32:10 +08:00
#include "osg/Switch"
#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;
}
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;
}
}