2002-01-29 20:52:04 +08:00
|
|
|
#include <osg/CopyOp>
|
|
|
|
#include <osg/Node>
|
|
|
|
#include <osg/StateSet>
|
2002-08-28 23:28:11 +08:00
|
|
|
#include <osg/Texture>
|
2002-01-29 20:52:04 +08:00
|
|
|
#include <osg/Drawable>
|
2002-07-26 05:50:08 +08:00
|
|
|
#include <osg/Array>
|
2002-09-20 22:51:59 +08:00
|
|
|
#include <osg/PrimitiveSet>
|
2002-01-29 20:52:04 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
Referenced* CopyOp::operator() (const Referenced* ref) const
|
|
|
|
{
|
|
|
|
return const_cast<Referenced*>(ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
Object* CopyOp::operator() (const Object* obj) const
|
|
|
|
{
|
|
|
|
if (obj && _flags&DEEP_COPY_OBJECTS)
|
|
|
|
return obj->clone(*this);
|
|
|
|
else return const_cast<Object*>(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
Node* CopyOp::operator() (const Node* node) const
|
|
|
|
{
|
|
|
|
if (node && _flags&DEEP_COPY_NODES)
|
|
|
|
return dynamic_cast<Node*>(node->clone(*this));
|
|
|
|
else
|
|
|
|
return const_cast<Node*>(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawable* CopyOp::operator() (const Drawable* drawable) const
|
|
|
|
{
|
|
|
|
if (drawable && _flags&DEEP_COPY_DRAWABLES)
|
|
|
|
return dynamic_cast<Drawable*>(drawable->clone(*this));
|
|
|
|
else
|
|
|
|
return const_cast<Drawable*>(drawable);
|
|
|
|
}
|
|
|
|
|
|
|
|
StateSet* CopyOp::operator() (const StateSet* stateset) const
|
|
|
|
{
|
|
|
|
if (stateset && _flags&DEEP_COPY_STATESETS)
|
|
|
|
return dynamic_cast<StateSet*>(stateset->clone(*this));
|
|
|
|
else
|
|
|
|
return const_cast<StateSet*>(stateset);
|
|
|
|
}
|
|
|
|
|
|
|
|
StateAttribute* CopyOp::operator() (const StateAttribute* attr) const
|
|
|
|
{
|
|
|
|
if (attr && _flags&DEEP_COPY_STATEATTRIBUTES)
|
|
|
|
{
|
2002-08-28 23:28:11 +08:00
|
|
|
const Texture* textbase = dynamic_cast<const Texture*>(attr);
|
2002-08-25 03:39:39 +08:00
|
|
|
if (textbase)
|
2002-01-29 20:52:04 +08:00
|
|
|
{
|
2002-08-25 03:39:39 +08:00
|
|
|
return operator()(textbase);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-28 23:28:11 +08:00
|
|
|
return dynamic_cast<StateAttribute*>(attr->clone(*this));
|
2002-01-29 20:52:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return const_cast<StateAttribute*>(attr);
|
|
|
|
}
|
|
|
|
|
2002-08-28 23:28:11 +08:00
|
|
|
Texture* CopyOp::operator() (const Texture* text) const
|
2002-01-29 20:52:04 +08:00
|
|
|
{
|
|
|
|
if (text && _flags&DEEP_COPY_TEXTURES)
|
2002-08-28 23:28:11 +08:00
|
|
|
return dynamic_cast<Texture*>(text->clone(*this));
|
2002-01-29 20:52:04 +08:00
|
|
|
else
|
2002-08-28 23:28:11 +08:00
|
|
|
return const_cast<Texture*>(text);
|
2002-01-29 20:52:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Image* CopyOp::operator() (const Image* image) const
|
|
|
|
{
|
|
|
|
if (image && _flags&DEEP_COPY_IMAGES)
|
|
|
|
return dynamic_cast<Image*>(image->clone(*this));
|
|
|
|
else return const_cast<Image*>(image);
|
|
|
|
}
|
2002-07-26 05:50:08 +08:00
|
|
|
|
|
|
|
Array* CopyOp::operator() (const Array* array) const
|
|
|
|
{
|
|
|
|
if (array && _flags&DEEP_COPY_ARRAYS)
|
|
|
|
return dynamic_cast<Array*>(array->clone(*this));
|
|
|
|
else
|
|
|
|
return const_cast<Array*>(array);
|
|
|
|
}
|
|
|
|
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet* CopyOp::operator() (const PrimitiveSet* primitive) const
|
2002-07-26 05:50:08 +08:00
|
|
|
{
|
|
|
|
if (primitive && _flags&DEEP_COPY_PRIMITIVES)
|
2002-09-20 22:51:59 +08:00
|
|
|
return dynamic_cast<PrimitiveSet*>(primitive->clone(*this));
|
2002-07-26 05:50:08 +08:00
|
|
|
else
|
2002-09-20 22:51:59 +08:00
|
|
|
return const_cast<PrimitiveSet*>(primitive);
|
2002-07-26 05:50:08 +08:00
|
|
|
}
|