Ejemplo n.º 1
0
        void                                apply( osg::MatrixTransform& mt )
                                            {
                                                if ( !mt.getUpdateCallback() )
                                                    mt.traverse( *this );

                                                osg::AnimationPathCallback* p_ncb = dynamic_cast< osg::AnimationPathCallback* >( mt.getUpdateCallback() );
                                                if ( !p_ncb )
                                                    mt.traverse( *this );

                                                _p_animPath = p_ncb->getAnimationPath();
                                                if ( !_p_animPath )
                                                    mt.traverse( *this );
                                            }
void AnimationCleanerVisitor::apply(osg::MatrixTransform& transform) {
    HasGeometryVisitor hasData;
    transform.traverse(hasData);

    if(!hasData.geometry) {
        // if animation transforms have no child geometry they are cleanable
        osgAnimation::Skeleton* skeleton = dynamic_cast<osgAnimation::Skeleton*>(&transform);
        osgAnimation::Bone* bone = dynamic_cast<osgAnimation::Bone*>(&transform);
        if(skeleton) {
            _transforms.push_back(osg::ref_ptr<osgAnimation::Skeleton>(skeleton));
        }
        if(bone) {
            _transforms.push_back(osg::ref_ptr<osgAnimation::Bone>(bone));
        }
    }

    osgAnimation::UpdateMatrixTransform* update = getCallbackType<osgAnimation::UpdateMatrixTransform>(transform.getUpdateCallback());
    if(update) {
        _updates[update] = osg::ref_ptr<osg::Node>(&transform);
    }

    traverse(transform);
}