diff --git a/include/osg/Object b/include/osg/Object index 546636c72..bdc100770 100644 --- a/include/osg/Object +++ b/include/osg/Object @@ -36,6 +36,20 @@ class State; virtual const char* libraryName() const { return #library; }\ virtual const char* className() const { return #name; } +template +T* clone(const T* t, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) +{ + return dynamic_cast(t->clone(copyop)); +} + + +template +T* clone(const T* t, const std::string& name, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) +{ + T* newObject = dynamic_cast(t->clone(copyop)); + newObject->setName(name); + return newObject; +} /** Base class/standard interface for objects which require IO support, cloning and reference counting.