From Cedric Pinson, fix constructors for cloning osgAnimation objects
This commit is contained in:
@@ -31,7 +31,7 @@ namespace osgAnimation
|
||||
META_Object(osgAnimation, Animation)
|
||||
|
||||
Animation() : _duration(0), _weight(0), _startTime(0), _playmode(LOOP) {}
|
||||
Animation(const osgAnimation::Animation& anim, const osg::CopyOp&);
|
||||
Animation(const osgAnimation::Animation&, const osg::CopyOp&);
|
||||
|
||||
enum PlayMode
|
||||
{
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace osgAnimation
|
||||
void clearTargets();
|
||||
void normalizeTargets();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
AnimationList _animations;
|
||||
|
||||
@@ -29,7 +29,9 @@ namespace osgAnimation
|
||||
public:
|
||||
|
||||
Channel();
|
||||
Channel(const Channel& channel);
|
||||
virtual ~Channel();
|
||||
virtual Channel* clone() const = 0;
|
||||
|
||||
virtual void update(float time) = 0;
|
||||
virtual void reset() = 0;
|
||||
@@ -66,8 +68,16 @@ namespace osgAnimation
|
||||
typedef typename SamplerType::UsingType UsingType;
|
||||
typedef TemplateTarget<UsingType> TargetType;
|
||||
typedef TemplateKeyframeContainer<typename SamplerType::KeyframeType> KeyframeContainerType;
|
||||
Channel* clone() const { return new TemplateChannel<SamplerType>(*this); }
|
||||
|
||||
TemplateChannel (SamplerType* s = 0,TargetType* target = 0)
|
||||
TemplateChannel (const TemplateChannel& channel) :
|
||||
Channel(channel),
|
||||
_target(new TargetType),
|
||||
_sampler(channel._sampler.get())
|
||||
{
|
||||
}
|
||||
|
||||
TemplateChannel (SamplerType* s = 0,TargetType* target = 0)
|
||||
{
|
||||
if (target)
|
||||
_target = target;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace osgAnimation
|
||||
{
|
||||
META_Object(osgAnimation, UpdateSkeleton);
|
||||
UpdateSkeleton() {}
|
||||
UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::NodeCallback(us, copyop) {}
|
||||
UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop) {}
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user