Show
Ignore:
Timestamp:
11/13/09 14:39:21 (5 years ago)
Author:
cedricpinson
Message:

From Cedric Pinson, Fix Skeleton to compute correctly bind matrix, fix compile issue on osganimationhardware after fixing Skeleton

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgAnimation/Skeleton.cpp

    r10558 r10751  
    1717 
    1818using namespace osgAnimation; 
     19 
     20Skeleton::Skeleton() {} 
     21Skeleton::Skeleton(const Skeleton& b, const osg::CopyOp& copyop) : Bone(b,copyop) {} 
     22 
     23Skeleton::UpdateSkeleton::UpdateSkeleton() : _needValidate(true) {} 
     24Skeleton::UpdateSkeleton::UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop)  
     25{ 
     26    _needValidate = true; 
     27} 
     28bool Skeleton::UpdateSkeleton::needToValidate() const 
     29{ 
     30    return _needValidate; 
     31} 
     32 
    1933 
    2034class ValidateSkeletonVisitor : public osg::NodeVisitor 
     
    5771void Skeleton::UpdateSkeleton::operator()(osg::Node* node, osg::NodeVisitor* nv) 
    5872{  
    59     if (_needValidate && nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)  
     73    if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR) 
    6074    { 
    61         Skeleton* b = dynamic_cast<Skeleton*>(node); 
    62         if (b)  
     75        Skeleton* skeleton = dynamic_cast<Skeleton*>(node); 
     76        if (_needValidate && skeleton) 
    6377        { 
    6478            ValidateSkeletonVisitor visitor; 
    6579            node->accept(visitor); 
     80            _needValidate = false; 
    6681        } 
    67  
    68         _needValidate = false; 
     82        if (skeleton->needToComputeBindMatrix()) 
     83            skeleton->computeBindMatrix(); 
    6984    } 
    7085    traverse(node,nv); 
    71 } 
    72  
    73 Skeleton::Skeleton() 
    74 { 
    7586} 
    7687 
     
    7990    setUpdateCallback(new Skeleton::UpdateSkeleton ); 
    8091} 
     92 
     93void Skeleton::computeBindMatrix()  
     94{ 
     95    _invBindInSkeletonSpace = osg::Matrix::inverse(_bindInBoneSpace);  
     96    _needToRecomputeBindMatrix = false;  
     97}