1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

37 lines
771 B
C++
Raw Normal View History

#ifndef OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
#define OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
#include <osg/NodeVisitor>
// Commonly used scene graph visitors
namespace SceneUtil
{
class FindByNameVisitor : public osg::NodeVisitor
{
public:
FindByNameVisitor(const std::string& nameToFind)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mNameToFind(nameToFind)
, mFoundNode(NULL)
{
}
2015-04-21 18:52:13 +02:00
virtual void apply(osg::Group& group)
{
2015-04-21 18:52:13 +02:00
if (group.getName() == mNameToFind)
{
2015-04-21 18:52:13 +02:00
mFoundNode = &group;
return;
}
2015-04-21 18:52:13 +02:00
traverse(group);
}
2015-04-19 14:25:36 +02:00
std::string mNameToFind;
osg::Group* mFoundNode;
};
}
#endif