Changed NodeVisitor so that is subclasses from osg::Object rather than osg::Referenced to enable it to be used with serialization and scripting

This commit is contained in:
Robert Osfield 2013-09-24 15:08:23 +00:00
parent 874a7ed3b3
commit 796314c339
4 changed files with 20 additions and 10 deletions

View File

@ -49,6 +49,10 @@ public:
{
}
SwitchDOFVisitor(const SwitchDOFVisitor& sdfv, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
META_Object(osg, SwitchDOFVisitor)
virtual void apply(Group& node)
{
osgSim::MultiSwitch* pMSwitch = dynamic_cast<osgSim::MultiSwitch*>(&node);

View File

@ -62,7 +62,7 @@ const unsigned int UNINITIALIZED_FRAME_NUMBER=0xffffffff;
myVisitor.apply(*root). The later method will bypass the double
dispatch and the appropriate NodeVisitor::apply(..) method will
not be called. */
class OSG_EXPORT NodeVisitor : public virtual Referenced
class OSG_EXPORT NodeVisitor : public virtual Object
{
public:
@ -87,13 +87,11 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
NodeVisitor(VisitorType type,TraversalMode tm=TRAVERSE_NONE);
virtual ~NodeVisitor();
NodeVisitor(const NodeVisitor& nv, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
/** return the library name/namespapce of the visitor's. Should be defined by derived classes.*/
virtual const char* libraryName() const { return "osg"; }
/** return the name of the visitor's class type. Should be defined by derived classes.*/
virtual const char* className() const { return "NodeVisitor"; }
virtual ~NodeVisitor();
META_Object(osg, NodeVisitor)
/** Method to call to reset visitor. Useful if your visitor accumulates
state during a traversal, and you plan to reuse the visitor.

View File

@ -795,7 +795,6 @@ KdTreeBuilder::KdTreeBuilder():
}
KdTreeBuilder::KdTreeBuilder(const KdTreeBuilder& rhs):
osg::Referenced(true),
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_buildOptions(rhs._buildOptions),
_kdTreePrototype(rhs._kdTreePrototype)

View File

@ -39,7 +39,7 @@
using namespace osg;
NodeVisitor::NodeVisitor(TraversalMode tm):
Referenced(true)
Object(true)
{
_visitorType = NODE_VISITOR;
_traversalNumber = osg::UNINITIALIZED_FRAME_NUMBER;
@ -50,7 +50,7 @@ NodeVisitor::NodeVisitor(TraversalMode tm):
}
NodeVisitor::NodeVisitor(VisitorType type,TraversalMode tm):
Referenced(true)
Object(true)
{
_visitorType = type;
_traversalNumber = osg::UNINITIALIZED_FRAME_NUMBER;
@ -60,6 +60,15 @@ NodeVisitor::NodeVisitor(VisitorType type,TraversalMode tm):
_nodeMaskOverride = 0x0;
}
NodeVisitor::NodeVisitor(const NodeVisitor& nv, const osg::CopyOp& copyop):
Object(nv, copyop),
_visitorType(nv._visitorType),
_traversalNumber(nv._traversalNumber),
_traversalMode(nv._traversalMode),
_traversalMask(nv._traversalMask),
_nodeMaskOverride(nv._nodeMaskOverride)
{
}
NodeVisitor::~NodeVisitor()
{