Moved get/setUserData from osg::Node into its superclass osg::Object to
allow other subclasses to add their own custom data.
This commit is contained in:
parent
ff8b4c001d
commit
34be82c1ee
@ -9,7 +9,6 @@
|
||||
#include <osg/StateSet>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -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<Referenced> _userData;
|
||||
|
||||
NodeMask _nodeMask;
|
||||
|
||||
DescriptionList _descriptions;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
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<Referenced> _userData;
|
||||
|
||||
private:
|
||||
|
||||
/** disallow any copy operator.*/
|
||||
|
@ -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()))
|
||||
|
@ -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())) {}
|
||||
|
@ -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<geode.getNumDrawables();++i)
|
||||
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
||||
{
|
||||
fw.writeObject(*geode.getDrawable(i));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user