Merge 10671-10672 to 2.8 branch. This is a continuration of the backport of osgAnimation. (Note prev rev log message should read "11206" not "11026".)

This commit is contained in:
Paul MARTZ
2010-03-13 21:38:17 +00:00
parent 38e68ed7f1
commit 40fc0eb263
9 changed files with 105 additions and 30 deletions

View File

@@ -18,6 +18,7 @@
#include <osg/Array>
#include <osg/PrimitiveSet>
#include <osg/Shape>
#include <osg/StateAttribute>
using namespace osg;
@@ -65,3 +66,37 @@ StateAttribute* CopyOp::operator() (const StateAttribute* attr) const
}
NodeCallback* CopyOp::operator() (const NodeCallback* nc) const
{
if (nc && _flags&DEEP_COPY_CALLBACKS)
{
// deep copy the full chain of callback
osg::NodeCallback* first = dynamic_cast<osg::NodeCallback*>(nc->clone(*this));
first->setNestedCallback(0);
nc = nc->getNestedCallback();
while (nc)
{
osg::NodeCallback* ucb = dynamic_cast<osg::NodeCallback*>(nc->clone(*this));
ucb->setNestedCallback(0);
first->addNestedCallback(ucb);
nc = nc->getNestedCallback();
}
return first;
}
else
return const_cast<NodeCallback*>(nc);
}
StateAttributeCallback* CopyOp::operator() (const StateAttributeCallback* sc) const
{
if (sc && _flags&DEEP_COPY_CALLBACKS)
{
// deep copy the full chain of callback
StateAttributeCallback* cb = dynamic_cast<StateAttributeCallback*>(sc->clone(*this));
return cb;
}
else
return const_cast<StateAttributeCallback*>(sc);
}