void StackedTransform::update(float t)
{
    int dirty = 0;
    for (StackedTransform::iterator it = begin(); it != end(); ++it)
    {
        StackedTransformElement* element = it->get();
        if (!element)
            continue;
        // update and check if there are changes
        element->update(t);
        if (element->isIdentity())
            continue;
        dirty++;
    }

    if (!dirty)
        return;


    // dirty update matrix
    _matrix.makeIdentity();
    for (StackedTransform::iterator it = begin(); it != end(); ++it)
    {
        StackedTransformElement* element = it->get();
        if (!element || element->isIdentity())
            continue;
        element->applyToMatrix(_matrix);
    }
}
bool UpdateMatrixTransform::link(osgAnimation::Channel* channel)
{
    const std::string& channelName = channel->getName();

    // check if we can link a StackedTransformElement to the current Channel
    for (StackedTransform::iterator it = _transforms.begin(); it != _transforms.end(); ++it)
    {
        StackedTransformElement* element = it->get();
        if (element && !element->getName().empty() && channelName == element->getName())
        {
            Target* target = element->getOrCreateTarget();
            if (target && channel->setTarget(target))
                return true;
        }
    }

    OSG_INFO << "UpdateMatrixTransform::link Channel " << channel->getName() << " does not contain a symbolic name that can be linked to a StackedTransformElement." << std::endl;

    return false;
}