From 796314c33954fd81b67296ca904fe772ed91909c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 24 Sep 2013 15:08:23 +0000 Subject: [PATCH] Changed NodeVisitor so that is subclasses from osg::Object rather than osg::Referenced to enable it to be used with serialization and scripting --- examples/osgsidebyside/osgsidebyside.cpp | 4 ++++ include/osg/NodeVisitor | 12 +++++------- src/osg/KdTree.cpp | 1 - src/osg/NodeVisitor.cpp | 13 +++++++++++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/examples/osgsidebyside/osgsidebyside.cpp b/examples/osgsidebyside/osgsidebyside.cpp index 5ed3dbaef..1d8e8bcd2 100644 --- a/examples/osgsidebyside/osgsidebyside.cpp +++ b/examples/osgsidebyside/osgsidebyside.cpp @@ -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(&node); diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index d0b7e8fd9..85db4181f 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -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. diff --git a/src/osg/KdTree.cpp b/src/osg/KdTree.cpp index ca608c19a..484155bea 100644 --- a/src/osg/KdTree.cpp +++ b/src/osg/KdTree.cpp @@ -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) diff --git a/src/osg/NodeVisitor.cpp b/src/osg/NodeVisitor.cpp index 191c827ec..850820bdf 100644 --- a/src/osg/NodeVisitor.cpp +++ b/src/osg/NodeVisitor.cpp @@ -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() {