diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index 5392343ec..ba4847ab7 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -150,6 +150,21 @@ class SG_EXPORT NodeVisitor : public virtual Referenced /** Get the traversal mode.*/ inline TraversalMode getTraversalMode() const { return _traversalMode; } + /** + * Set user data, data must be subclased from Referenced to allow + * automatic memory handling. If you own data isn't directly + * subclassed from Referenced then create and adapter object + * which points to your own objects and handles the memory addressing. + */ + inline void setUserData(Referenced* obj) { _userData = obj; } + + /** Get user data.*/ + inline Referenced* getUserData() { return _userData.get(); } + + /** Get const user data.*/ + inline const Referenced* getUserData() const { return _userData.get(); } + + /** Method for handling traversal of a nodes. If you intend to use the visitor for actively traversing the scene graph then make sure the accept() methods call @@ -241,6 +256,8 @@ class SG_EXPORT NodeVisitor : public virtual Referenced NodePath _nodePath; + ref_ptr _userData; + };