From Cedric Pinson, fix constructors for cloning osgAnimation objects

This commit is contained in:
Cedric Pinson
2009-06-22 14:24:59 +00:00
parent c0c47b2eca
commit 658d96aa64
10 changed files with 50 additions and 21 deletions

View File

@@ -16,13 +16,18 @@
using namespace osgAnimation;
Animation::Animation(const osgAnimation::Animation& anim, const osg::CopyOp& c)
Animation::Animation(const osgAnimation::Animation& anim, const osg::CopyOp& copyop):
_duration(anim._duration),
_originalDuration(anim._originalDuration),
_weight(anim._weight),
_startTime(anim._startTime),
_playmode(anim._playmode)
{
_duration = anim._duration;
_originalDuration = anim._originalDuration;
_weight = anim._weight;
_startTime = anim._startTime;
_playmode = anim._playmode;
const ChannelList& cl = anim.getChannels();
for (ChannelList::const_iterator it = cl.begin(); it != cl.end(); it++)
{
addChannel(it->get()->clone());
}
}

View File

@@ -57,11 +57,18 @@ void AnimationManagerBase::operator()(osg::Node* node, osg::NodeVisitor* nv)
}
AnimationManagerBase::AnimationManagerBase(const AnimationManagerBase& b, const osg::CopyOp& copyop) : osg::NodeCallback(b,copyop)
AnimationManagerBase::AnimationManagerBase(const AnimationManagerBase& b, const osg::CopyOp& copyop) : osg::NodeCallback(b,copyop)
{
_animations = b._animations;
_targets = b._targets;
_needToLink = b._needToLink;
const AnimationList& animationList = b.getAnimationList();
for (AnimationList::const_iterator it = animationList.begin();
it != animationList.end();
it++)
{
Animation* animation = dynamic_cast<osgAnimation::Animation*>(it->get()->clone(copyop));
_animations.push_back(animation);
}
_needToLink = true;
buildTargetReference();
}
void AnimationManagerBase::buildTargetReference()

View File

@@ -17,6 +17,7 @@
#include <osgAnimation/Skeleton>
osgAnimation::Bone::UpdateBone::UpdateBone(const osgAnimation::Bone::UpdateBone& apc,const osg::CopyOp& copyop) :
osg::Object(apc, copyop),
osgAnimation::AnimationUpdateCallback(apc, copyop)
{
_quaternion = new osgAnimation::QuatTarget(apc._quaternion->getValue());
@@ -40,7 +41,6 @@ osgAnimation::Bone::Bone(const Bone& b, const osg::CopyOp& copyop) :
while (updatecallback.valid()) {
osg::NodeCallback* ucb = dynamic_cast<osg::NodeCallback*>(updatecallback->clone(copyop));
ucb->setNestedCallback(0);
ucb->setName(updatecallback->getName());
addUpdateCallback(ucb);
updatecallback = updatecallback->getNestedCallback();
}

View File

@@ -17,6 +17,12 @@ using namespace osgAnimation;
Channel::Channel() { _weight=1; }
Channel::~Channel() {}
Channel::Channel(const Channel& channel) : osg::Referenced(channel),
_targetName(channel._targetName),
_name(channel._name),
_weight(channel._weight)
{
}
const std::string& Channel::getName() const { return _name; }
void Channel::setName (const std::string& name) { _name = name; }

View File

@@ -35,8 +35,9 @@ osgAnimation::Timeline::Timeline()
setName("Timeline");
}
osgAnimation::Timeline::Timeline(const Timeline& nc,const osg::CopyOp& op) : Action(nc, op),
_actions(nc._actions)
osgAnimation::Timeline::Timeline(const Timeline& nc,const osg::CopyOp& op)
: Action(nc, op),
_actions(nc._actions)
{
_lastUpdate = 0;
_currentFrame = 0;

View File

@@ -66,11 +66,12 @@ void AnimationUpdateCallback::updateLink()
UpdateTransform::UpdateTransform(const UpdateTransform& apc,const osg::CopyOp& copyop)
: AnimationUpdateCallback(apc, copyop),
_euler(apc._euler),
_position(apc._position),
_scale(apc._scale)
: osg::Object(apc, copyop),
AnimationUpdateCallback(apc, copyop)
{
_euler = new osgAnimation::Vec3Target(apc._euler->getValue());
_position = new osgAnimation::Vec3Target(apc._euler->getValue());
_scale = new osgAnimation::Vec3Target(apc._euler->getValue());
}
UpdateTransform::UpdateTransform(const std::string& name) : AnimationUpdateCallback(name)