diff --git a/include/osg/CollectOccludersVisitor b/include/osg/CollectOccludersVisitor index 49b8ac3c7..b0491318f 100644 --- a/include/osg/CollectOccludersVisitor +++ b/include/osg/CollectOccludersVisitor @@ -31,6 +31,8 @@ class OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg:: CollectOccludersVisitor(); virtual ~CollectOccludersVisitor(); + META_NodeVisitor("osg","CollectOccludersVisitor") + virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); } virtual void reset(); diff --git a/include/osg/ComputeBoundsVisitor b/include/osg/ComputeBoundsVisitor index b70b338cd..320870ff1 100644 --- a/include/osg/ComputeBoundsVisitor +++ b/include/osg/ComputeBoundsVisitor @@ -26,6 +26,8 @@ public: ComputeBoundsVisitor(TraversalMode traversalMode = TRAVERSE_ALL_CHILDREN); + META_NodeVisitor("osg","ComputeBoundsVisitor") + virtual void reset(); osg::BoundingBox& getBoundingBox() { return _bb; } diff --git a/include/osg/KdTree b/include/osg/KdTree index e68634f1e..580736cd3 100644 --- a/include/osg/KdTree +++ b/include/osg/KdTree @@ -175,6 +175,8 @@ class OSG_EXPORT KdTreeBuilder : public osg::NodeVisitor KdTreeBuilder(const KdTreeBuilder& rhs); + META_NodeVisitor("osg","KdTreeBuilder") + virtual KdTreeBuilder* clone() { return new KdTreeBuilder(*this); } void apply(osg::Geode& geode); diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index ab32f73dd..682287ca0 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -42,6 +42,10 @@ class Transform; class Camera; class CameraView; +#define META_NodeVisitor(library,name) \ + virtual const char* libraryName() const { return #library; }\ + virtual const char* className() const { return #name; } + /** Visitor for type safe operations on osg::Nodes. Based on GOF's Visitor pattern. The NodeVisitor is useful for developing type safe operations to nodes @@ -82,6 +86,12 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced NodeVisitor(VisitorType type,TraversalMode tm=TRAVERSE_NONE); virtual ~NodeVisitor(); + + /** 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"; } /** 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/include/osgAnimation/Bone b/include/osgAnimation/Bone index 1d79d78ab..f714ad5d0 100644 --- a/include/osgAnimation/Bone +++ b/include/osgAnimation/Bone @@ -56,6 +56,8 @@ namespace osgAnimation BoneMap _map; BoneMapVisitor(): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} + META_NodeVisitor("osgAnimation","BoneMapVisitor") + void apply(osg::Node& node) { return; } void apply(osg::Transform& node) { diff --git a/include/osgAnimation/LinkVisitor b/include/osgAnimation/LinkVisitor index afc318220..0492a4d65 100644 --- a/include/osgAnimation/LinkVisitor +++ b/include/osgAnimation/LinkVisitor @@ -26,8 +26,12 @@ namespace osgAnimation { AnimationList _animations; unsigned int _nbLinkedTarget; + LinkVisitor(Animation* animation) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _animations.push_back(animation); _nbLinkedTarget = 0;} LinkVisitor(const AnimationList& animations) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _animations = animations; _nbLinkedTarget = 0;} + + META_NodeVisitor("osgAnimation","LinkVisitor") + void apply(osg::Node& node) { osgAnimation::AnimationUpdateCallback* cb = dynamic_cast(node.getUpdateCallback()); diff --git a/include/osgAnimation/RigGeometry b/include/osgAnimation/RigGeometry index 1eeb903e1..1885d49f8 100644 --- a/include/osgAnimation/RigGeometry +++ b/include/osgAnimation/RigGeometry @@ -77,6 +77,9 @@ namespace osgAnimation { osg::ref_ptr _root; BuildVertexTransformerVisitor(Skeleton* root): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _root = root;} + + META_NodeVisitor("osgAnimation","BuildVertexTransformerVisitor") + void apply(osg::Geode& node) { int num = node.getNumDrawables(); diff --git a/include/osgDB/SharedStateManager b/include/osgDB/SharedStateManager index 77c5542a1..9246a22e3 100644 --- a/include/osgDB/SharedStateManager +++ b/include/osgDB/SharedStateManager @@ -48,6 +48,8 @@ namespace osgDB { SharedStateManager(unsigned int mode = SHARE_ALL); + META_NodeVisitor("osgDB","SharedStateManager") + void setShareMode(unsigned int mode); unsigned int getShareMode() { return _shareMode; } diff --git a/include/osgGA/EventVisitor b/include/osgGA/EventVisitor index 7e0fda7ed..3e8acb219 100644 --- a/include/osgGA/EventVisitor +++ b/include/osgGA/EventVisitor @@ -43,6 +43,7 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor EventVisitor(); virtual ~EventVisitor(); + META_NodeVisitor("osgGA","EventVisitor") void setActionAdapter(osgGA::GUIActionAdapter* actionAdapter) { _actionAdapter=actionAdapter; } diff --git a/include/osgSim/InsertImpostorsVisitor b/include/osgSim/InsertImpostorsVisitor index 5da1e4e22..2fb4c5c5a 100644 --- a/include/osgSim/InsertImpostorsVisitor +++ b/include/osgSim/InsertImpostorsVisitor @@ -29,6 +29,8 @@ class OSGSIM_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor /** Default to traversing all children. */ InsertImpostorsVisitor(); + META_NodeVisitor("osgSim","InsertImpostorsVisitor") + void setImpostorThresholdRatio(float ratio) { _impostorThresholdRatio = ratio; } float getImpostorThresholdRatio() const { return _impostorThresholdRatio; } diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 008218d7e..2a94533e1 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -57,6 +57,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac /// Copy constructor that does a shallow copy. CullVisitor(const CullVisitor&); + META_NodeVisitor("osgUtil","CullVisitor") + /** Create a shallow copy of the CullVisitor, used by CullVisitor::create() to clone the prototype. */ virtual CullVisitor* clone() const { return new CullVisitor(*this); } diff --git a/include/osgUtil/DisplayRequirementsVisitor b/include/osgUtil/DisplayRequirementsVisitor index 03d9ce621..5648822c9 100644 --- a/include/osgUtil/DisplayRequirementsVisitor +++ b/include/osgUtil/DisplayRequirementsVisitor @@ -36,6 +36,7 @@ class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor * alpha and stencil off.*/ DisplayRequirementsVisitor(); + META_NodeVisitor("osgUtil","DisplayRequirementsVisitor") /** Set the DisplaySettings. */ inline void setDisplaySettings(osg::DisplaySettings* ds) { _ds = ds; } diff --git a/include/osgUtil/DrawElementTypeSimplifier b/include/osgUtil/DrawElementTypeSimplifier index 226369e6a..0737d9fd5 100644 --- a/include/osgUtil/DrawElementTypeSimplifier +++ b/include/osgUtil/DrawElementTypeSimplifier @@ -32,6 +32,8 @@ class OSGUTIL_EXPORT DrawElementTypeSimplifierVisitor : public osg::NodeVisitor { public: + META_NodeVisitor("osgUtil","DrawElementTypeSimplifierVisitor") + void apply(osg::Geode& node); }; diff --git a/include/osgUtil/GLObjectsVisitor b/include/osgUtil/GLObjectsVisitor index b93db359c..343586f99 100644 --- a/include/osgUtil/GLObjectsVisitor +++ b/include/osgUtil/GLObjectsVisitor @@ -51,9 +51,10 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor * display list/texture objects etc. Default mode is to compile * GL objects. */ - GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES); - - + GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES); + + META_NodeVisitor("osg","GLObjectsVisitor") + virtual void reset() { _drawablesAppliedSet.clear(); diff --git a/include/osgUtil/IntersectVisitor b/include/osgUtil/IntersectVisitor index bf90634c8..2b6565774 100644 --- a/include/osgUtil/IntersectVisitor +++ b/include/osgUtil/IntersectVisitor @@ -102,6 +102,8 @@ class OSGUTIL_EXPORT IntersectVisitor : public osg::NodeVisitor IntersectVisitor(); virtual ~IntersectVisitor(); + META_NodeVisitor("osgUtil","IntersectVisitor") + void reset(); /** Add a line segment to use for intersection testing during scene traversal. diff --git a/include/osgUtil/IntersectionVisitor b/include/osgUtil/IntersectionVisitor index 7106f9833..d459702c1 100644 --- a/include/osgUtil/IntersectionVisitor +++ b/include/osgUtil/IntersectionVisitor @@ -137,6 +137,8 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor IntersectionVisitor(Intersector* intersector=0, ReadCallback* readCallback=0); + META_NodeVisitor("osgUtil","IntersectionVisitor") + virtual void reset(); diff --git a/include/osgUtil/Simplifier b/include/osgUtil/Simplifier index 8eeac2eb3..d1e58b081 100644 --- a/include/osgUtil/Simplifier +++ b/include/osgUtil/Simplifier @@ -30,6 +30,7 @@ class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor Simplifier(double sampleRatio=1.0, double maximumError=FLT_MAX, double maximumLength=0.0); + META_NodeVisitor("osgUtil","Simplifier") void setSampleRatio(float sampleRatio) { _sampleRatio = sampleRatio; } float getSampleRatio() const { return _sampleRatio; } diff --git a/include/osgUtil/Statistics b/include/osgUtil/Statistics index 28fba258b..91564790b 100644 --- a/include/osgUtil/Statistics +++ b/include/osgUtil/Statistics @@ -167,6 +167,8 @@ public: StatsVisitor(); + META_NodeVisitor("osgUtil","StatsVisitor") + void reset(); void apply(osg::Node& node); diff --git a/include/osgUtil/UpdateVisitor b/include/osgUtil/UpdateVisitor index 47b628259..eb2cffd18 100644 --- a/include/osgUtil/UpdateVisitor +++ b/include/osgUtil/UpdateVisitor @@ -41,9 +41,11 @@ class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor UpdateVisitor(); virtual ~UpdateVisitor(); + META_NodeVisitor("osgUtil","UpdateVisitor") + virtual void reset(); - /** During traversal each type of node calls its callbacks and its children traversed. */ + /** During traversal each type of node calls its callbacks and its children traversed. */ virtual void apply(osg::Node& node) { handle_callbacks_and_traverse(node); } virtual void apply(osg::Geode& node) { handle_geode_callbacks(node); } diff --git a/src/osg/Transform.cpp b/src/osg/Transform.cpp index 349e87222..99afb5c29 100644 --- a/src/osg/Transform.cpp +++ b/src/osg/Transform.cpp @@ -39,6 +39,8 @@ class TransformVisitor : public NodeVisitor _ignoreCameras(ignoreCameras) {} + META_NodeVisitor("osg","TransformVisitor") + virtual void apply(Transform& transform) { if (_coordMode==LOCAL_TO_WORLD) diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 756603794..8488da927 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -129,6 +129,8 @@ public: } + META_NodeVisitor("osgDB","FindCompileableGLObjectsVisitor") + virtual void apply(osg::Node& node) { apply(node.getStateSet()); @@ -1486,6 +1488,8 @@ public: { } + META_NodeVisitor("osgDB","FindCompileableGLObjectsVisitor") + virtual void apply(osg::PagedLOD& plod) { if (plod.getName()!=_marker) @@ -1842,6 +1846,8 @@ public: { } + META_NodeVisitor("osgDB","FindPagedLODsVisitor") + virtual void apply(osg::PagedLOD& plod) { plod.setFrameNumberOfLastTraversal(_frameNumber); diff --git a/src/osgFX/BumpMapping.cpp b/src/osgFX/BumpMapping.cpp index e1df745c5..da10a6bd0 100644 --- a/src/osgFX/BumpMapping.cpp +++ b/src/osgFX/BumpMapping.cpp @@ -30,6 +30,9 @@ namespace class TsgVisitor: public NodeVisitor { public: TsgVisitor(BumpMapping* bm): NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN), _bm(bm) {} + + META_NodeVisitor("osgFX","TsgVisitor") + void apply(osg::Geode& geode) { for (unsigned i=0; i NodePathList; - NodePathList _nodePaths; -}; - NodeTrackerManipulator::NodeTrackerManipulator() { _trackerMode = NODE_CENTER_AND_ROTATION; @@ -120,14 +100,17 @@ void NodeTrackerManipulator::setTrackNode(osg::Node* node) return; } - CollectParentPaths cpp; - node->accept(cpp); - - if (!cpp._nodePaths.empty()) + osg::NodePathList nodePaths = node->getParentalNodePaths(); + if (!nodePaths.empty()) { + if (nodePaths.size()>1) + { + osg::notify(osg::NOTICE)<<"osgGA::NodeTrackerManipualtor::setTrackNode(..) taking first parent path, ignoring others."<getName()<<"): Path set"< #include +#include + #include using namespace osgManipulator; -class FindNodePathToRootVisitor : public osg::NodeVisitor -{ - public: - - osg::NodePath& _nodePathToRoot; - - FindNodePathToRootVisitor(osg::NodePath& np) - : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_PARENTS), - _nodePathToRoot(np) - {} - - virtual void apply(osg::Node& node) - { - _nodePathToRoot.push_back(&node); - traverse(node); - } -}; - void osgManipulator::computeNodePathToRoot(osg::Node& node, osg::NodePath& np) { np.clear(); - osg::ref_ptr visitor = new FindNodePathToRootVisitor(np); - node.accept(*visitor); - np.pop_back(); - std::reverse(np.begin(), np.end()); + + osg::NodePathList nodePaths = node.getParentalNodePaths(); + + if (!nodePaths.empty()) + { + np = nodePaths.front(); + if (nodePaths.size()>1) + { + osg::notify(osg::NOTICE)<<"osgManipulator::computeNodePathToRoot(,) taking first parent path, ignoring others."<