void AnimationCleanerVisitor::cleanAnimation(osgAnimation::Animation& animation) {
    // remove animation's invalid channels
    osgAnimation::ChannelList& channels = animation.getChannels();
    osgAnimation::ChannelList invalids;

    for(osgAnimation::ChannelList::iterator channel = channels.begin() ; channel != channels.end() ; ++ channel) {
        if(channel->valid()) {
            cleanChannel(*channel->get());
        }

        if(!channel->valid() || !isValidChannel(*channel->get())) {
            invalids.push_back(channel->get());
        }
    }

    for(osgAnimation::ChannelList::iterator invalid = invalids.begin() ; invalid != invalids.end() ; ++ invalid) {
        animation.removeChannel(invalid->get());
    }
}
bool AnimationCleanerVisitor::isValidAnimation(const osgAnimation::Animation& animation) const {
    // a valid animation has at least one channel and all channels must be valid
    const osgAnimation::ChannelList& channels = animation.getChannels();

    for(osgAnimation::ChannelList::const_iterator channel = channels.begin() ; channel != channels.end() ; ++ channel) {
        if(!channel->valid() || !isValidChannel(*channel->get())) {
            return false;
        }
    }

    return channels.size() > 0;
}
Пример #3
0
Animation::Animation(const osgAnimation::Animation& anim, const osg::CopyOp& copyop): osg::Object(anim, copyop),
    _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());
    }
}