diff --git a/include/osg/Node b/include/osg/Node index f8cb24eea..a54f37ac5 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -148,20 +147,6 @@ class SG_EXPORT Node : public Object /** return true if this node is an OccluderNode or the subgraph below this node are OccluderNodes.*/ const bool containsOccluderNodes() const; - /** - * 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(osg::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(); } - - typedef unsigned int NodeMask; /** Set the node mask. Note, node mask is will be replaced by TraversalMask.*/ @@ -258,8 +243,6 @@ class SG_EXPORT Node : public Object int _numChildrenWithOccluderNodes; void setNumChildrenWithOccluderNodes(const int num); - osg::ref_ptr _userData; - NodeMask _nodeMask; DescriptionList _descriptions; diff --git a/include/osg/Object b/include/osg/Object index 0083e4e8b..2a537f527 100644 --- a/include/osg/Object +++ b/include/osg/Object @@ -7,6 +7,7 @@ #include #include +#include namespace osg { @@ -77,6 +78,21 @@ class SG_EXPORT Object : public Referenced inline const DataVariance getDataVariance() const { return _dataVariance; } + /** + * 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(); } + + protected: /** Object destructor. Note, is protected so that Objects cannot @@ -90,6 +106,8 @@ class SG_EXPORT Object : public Referenced DataVariance _dataVariance; + ref_ptr _userData; + private: /** disallow any copy operator.*/ diff --git a/src/osg/Node.cpp b/src/osg/Node.cpp index 760b928b8..c0de9a3f6 100644 --- a/src/osg/Node.cpp +++ b/src/osg/Node.cpp @@ -33,7 +33,6 @@ Node::Node(const Node& node,const CopyOp& copyop): _cullingActive(node._cullingActive), _numChildrenWithCullingDisabled(0), // assume no children yet. _numChildrenWithOccluderNodes(0), - _userData(copyop(node._userData.get())), _nodeMask(node._nodeMask), _descriptions(node._descriptions), _dstate(copyop(node._dstate.get())) diff --git a/src/osg/Object.cpp b/src/osg/Object.cpp index e7efa7548..594b744c9 100644 --- a/src/osg/Object.cpp +++ b/src/osg/Object.cpp @@ -14,6 +14,7 @@ Referenced::~Referenced() } -Object::Object(const Object& obj,const CopyOp&): +Object::Object(const Object& obj,const CopyOp& copyop): Referenced(), - _dataVariance(obj._dataVariance) {} + _dataVariance(obj._dataVariance), + _userData(copyop(obj._userData.get())) {} diff --git a/src/osgPlugins/osg/Geode.cpp b/src/osgPlugins/osg/Geode.cpp index edaba6aee..ad36847b5 100644 --- a/src/osgPlugins/osg/Geode.cpp +++ b/src/osgPlugins/osg/Geode.cpp @@ -53,7 +53,7 @@ bool Geode_writeLocalData(const osg::Object& obj, Output& fw) fw.indent() << "num_drawables " << geode.getNumDrawables() << std::endl; - for(int i=0;i