diff --git a/include/osgAnimation/Target b/include/osgAnimation/Target index 8b5400a0d..c7c43362b 100644 --- a/include/osgAnimation/Target +++ b/include/osgAnimation/Target @@ -50,7 +50,7 @@ namespace osgAnimation { public: - TemplateTarget() {} + TemplateTarget() : _target() {} TemplateTarget(const T& v) { setValue(v); } TemplateTarget(const TemplateTarget& v) { setValue(v.getValue()); } diff --git a/src/osgAnimation/MorphGeometry.cpp b/src/osgAnimation/MorphGeometry.cpp index 934661abc..d2d36c7e0 100644 --- a/src/osgAnimation/MorphGeometry.cpp +++ b/src/osgAnimation/MorphGeometry.cpp @@ -261,19 +261,22 @@ bool UpdateMorph::link(osgAnimation::Channel* channel) if (weightIndex >= 0) { - osgAnimation::FloatLinearChannel* fc = dynamic_cast(channel); - if (fc) - { - osgAnimation::FloatTarget* ft = new osgAnimation::FloatTarget; - _weightTargets[weightIndex] = ft; - ft->setValue(-1); - fc->setTarget(ft); - return true; - } - } + osgAnimation::FloatLinearChannel* fc = dynamic_cast(channel); + if (fc) + { + osgAnimation::FloatTarget* ft = _weightTargets[weightIndex].get(); + if (ft == 0) + { + ft = new osgAnimation::FloatTarget; + _weightTargets[weightIndex] = ft; + } + fc->setTarget(ft); + return true; + } + } else - { - osg::notify(osg::WARN) << "Channel " << channel->getName() << " does not contain a valid symbolic name for this class" << std::endl; - } - return false; + { + osg::notify(osg::WARN) << "Channel " << channel->getName() << " does not contain a valid symbolic name for this class" << std::endl; + } + return false; }