Changeset 10751
- Timestamp:
- 11/13/09 14:39:21 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 2 modified
-
include/osgAnimation/Skeleton (modified) (3 diffs)
-
src/osgAnimation/Skeleton.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgAnimation/Skeleton
r10656 r10751 1 1 /* -*-c++-*- 2 * Copyright (C) 2008 Cedric Pinson < mornifle@plopbyte.net>2 * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net> 3 3 * 4 4 * This library is open source and may be redistributed and/or modified under … … 13 13 */ 14 14 15 #ifndef OSGANIMATION_SKELETON _H16 #define OSGANIMATION_SKELETON _H15 #ifndef OSGANIMATION_SKELETON 16 #define OSGANIMATION_SKELETON 1 17 17 18 #include <osg /MatrixTransform>18 #include <osgAnimation/Export> 19 19 #include <osgAnimation/Bone> 20 #include <osgAnimation/Export>21 20 22 21 namespace osgAnimation … … 32 31 public: 33 32 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&); 36 35 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); 37 36 bool needToValidate() const; 38 37 protected: 39 38 bool _needValidate; 40 39 }; 41 40 42 Skeleton(const Skeleton& b, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : Bone(b,copyop) {}43 41 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(); 46 46 }; 47 47 -
OpenSceneGraph/trunk/src/osgAnimation/Skeleton.cpp
r10558 r10751 17 17 18 18 using namespace osgAnimation; 19 20 Skeleton::Skeleton() {} 21 Skeleton::Skeleton(const Skeleton& b, const osg::CopyOp& copyop) : Bone(b,copyop) {} 22 23 Skeleton::UpdateSkeleton::UpdateSkeleton() : _needValidate(true) {} 24 Skeleton::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 } 28 bool Skeleton::UpdateSkeleton::needToValidate() const 29 { 30 return _needValidate; 31 } 32 19 33 20 34 class ValidateSkeletonVisitor : public osg::NodeVisitor … … 57 71 void Skeleton::UpdateSkeleton::operator()(osg::Node* node, osg::NodeVisitor* nv) 58 72 { 59 if ( _needValidate && nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)73 if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR) 60 74 { 61 Skeleton* b= dynamic_cast<Skeleton*>(node);62 if ( b)75 Skeleton* skeleton = dynamic_cast<Skeleton*>(node); 76 if (_needValidate && skeleton) 63 77 { 64 78 ValidateSkeletonVisitor visitor; 65 79 node->accept(visitor); 80 _needValidate = false; 66 81 } 67 68 _needValidate = false;82 if (skeleton->needToComputeBindMatrix()) 83 skeleton->computeBindMatrix(); 69 84 } 70 85 traverse(node,nv); 71 }72 73 Skeleton::Skeleton()74 {75 86 } 76 87 … … 79 90 setUpdateCallback(new Skeleton::UpdateSkeleton ); 80 91 } 92 93 void Skeleton::computeBindMatrix() 94 { 95 _invBindInSkeletonSpace = osg::Matrix::inverse(_bindInBoneSpace); 96 _needToRecomputeBindMatrix = false; 97 }
