From Cedric Pinson, fix copy constructor for clone operation for Bone, add a missing contructor with quaternion for Target

This commit is contained in:
Cedric Pinson 2009-06-14 23:30:47 +00:00
parent c78e41ede6
commit b2943aa50a
3 changed files with 18 additions and 6 deletions

View File

@ -93,7 +93,7 @@ namespace osgAnimation
class OSGANIMATION_EXPORT UpdateBone : public AnimationUpdateCallback class OSGANIMATION_EXPORT UpdateBone : public AnimationUpdateCallback
{ {
public: protected:
osg::ref_ptr<osgAnimation::Vec3Target> _position; osg::ref_ptr<osgAnimation::Vec3Target> _position;
osg::ref_ptr<osgAnimation::QuatTarget> _quaternion; osg::ref_ptr<osgAnimation::QuatTarget> _quaternion;
osg::ref_ptr<osgAnimation::Vec3Target> _scale; osg::ref_ptr<osgAnimation::Vec3Target> _scale;

View File

@ -90,7 +90,7 @@ namespace osgAnimation
public: public:
TemplateTarget () {} TemplateTarget () {}
TemplateTarget (const osg::Quat& q) { setValue(q); }
const osg::Quat& getValue() const { return _target;} const osg::Quat& getValue() const { return _target;}
void update(float weight, const osg::Quat& val) void update(float weight, const osg::Quat& val)
{ {

View File

@ -17,11 +17,11 @@
#include <osgAnimation/Skeleton> #include <osgAnimation/Skeleton>
osgAnimation::Bone::UpdateBone::UpdateBone(const osgAnimation::Bone::UpdateBone& apc,const osg::CopyOp& copyop) : osgAnimation::Bone::UpdateBone::UpdateBone(const osgAnimation::Bone::UpdateBone& apc,const osg::CopyOp& copyop) :
osgAnimation::AnimationUpdateCallback(apc, copyop), osgAnimation::AnimationUpdateCallback(apc, copyop)
_position(apc._position),
_quaternion(apc._quaternion),
_scale(apc._scale)
{ {
_quaternion = new osgAnimation::QuatTarget(apc._quaternion->getValue());
_position = new osgAnimation::Vec3Target(apc._position->getValue());
_scale = new osgAnimation::Vec3Target(apc._scale->getValue());
} }
@ -30,8 +30,20 @@ osgAnimation::Bone::Bone(const Bone& b, const osg::CopyOp& copyop) :
_position(b._position), _position(b._position),
_rotation(b._rotation), _rotation(b._rotation),
_scale(b._scale), _scale(b._scale),
_bindInBoneSpace(b._bindInBoneSpace),
_invBindInSkeletonSpace(b._invBindInSkeletonSpace),
_boneInSkeletonSpace(b._boneInSkeletonSpace),
_needToRecomputeBindMatrix(true) _needToRecomputeBindMatrix(true)
{ {
osg::ref_ptr<osg::NodeCallback> updatecallback = getUpdateCallback();
setUpdateCallback(0);
while (updatecallback.valid()) {
osg::NodeCallback* ucb = dynamic_cast<osg::NodeCallback*>(updatecallback->clone(copyop));
ucb->setNestedCallback(0);
ucb->setName(updatecallback->getName());
addUpdateCallback(ucb);
updatecallback = updatecallback->getNestedCallback();
}
} }
osgAnimation::Bone::Bone(const std::string& name) osgAnimation::Bone::Bone(const std::string& name)