Changeset 10751

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

Location:
OpenSceneGraph/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgAnimation/Skeleton

    r10656 r10751  
    11/*  -*-c++-*-  
    2  *  Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net> 
     2 *  Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net> 
    33 * 
    44 * This library is open source and may be redistributed and/or modified under   
     
    1313*/ 
    1414 
    15 #ifndef OSGANIMATION_SKELETON_H 
    16 #define OSGANIMATION_SKELETON_H 
     15#ifndef OSGANIMATION_SKELETON 
     16#define OSGANIMATION_SKELETON 1 
    1717 
    18 #include <osg/MatrixTransform> 
     18#include <osgAnimation/Export> 
    1919#include <osgAnimation/Bone> 
    20 #include <osgAnimation/Export> 
    2120 
    2221namespace osgAnimation  
     
    3231        public: 
    3332            META_Object(osgAnimation, UpdateSkeleton); 
    34             UpdateSkeleton() : _needValidate(true) {} 
    35             UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop) { _needValidate = true;} 
     33            UpdateSkeleton(); 
     34            UpdateSkeleton(const UpdateSkeleton&, const osg::CopyOp&); 
    3635            virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); 
    37  
     36            bool needToValidate() const; 
    3837        protected: 
    3938            bool _needValidate; 
    4039        }; 
    4140 
    42         Skeleton(const Skeleton& b, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : Bone(b,copyop) {} 
    4341        Skeleton(); 
    44         void setDefaultUpdateCallback(void); 
    45         void computeBindMatrix() { _invBindInSkeletonSpace = osg::Matrix::inverse(_bindInBoneSpace); _needToRecomputeBindMatrix = false; } 
     42        Skeleton(const Skeleton&, const osg::CopyOp&); 
     43 
     44        void setDefaultUpdateCallback(); 
     45        void computeBindMatrix(); 
    4646    }; 
    4747 
  • 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}