1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 12:23:51 +00:00
openmw-tes3mp/components/sceneutil/visitor.hpp
2015-07-07 22:46:15 +02:00

38 lines
842 B
C++

#ifndef OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
#define OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
#include <osg/NodeVisitor>
#include <components/misc/stringops.hpp>
// 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(nullptr)
{
}
virtual void apply(osg::Group& group)
{
if (Misc::StringUtils::ciEqual(group.getName(), mNameToFind))
{
mFoundNode = &group;
return;
}
traverse(group);
}
std::string mNameToFind;
osg::Group* mFoundNode;
};
}
#endif