From Cedric Pinson, Fix Skeleton to compute correctly bind matrix, fix compile issue on osganimationhardware after fixing Skeleton
This commit is contained in:
parent
cd2d69506b
commit
5842677662
@ -1,5 +1,5 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
|
||||
* Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
@ -12,12 +12,11 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGANIMATION_SKELETON_H
|
||||
#define OSGANIMATION_SKELETON_H
|
||||
#ifndef OSGANIMATION_SKELETON
|
||||
#define OSGANIMATION_SKELETON 1
|
||||
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osgAnimation/Bone>
|
||||
#include <osgAnimation/Export>
|
||||
#include <osgAnimation/Bone>
|
||||
|
||||
namespace osgAnimation
|
||||
{
|
||||
@ -31,18 +30,19 @@ namespace osgAnimation
|
||||
{
|
||||
public:
|
||||
META_Object(osgAnimation, UpdateSkeleton);
|
||||
UpdateSkeleton() : _needValidate(true) {}
|
||||
UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop) { _needValidate = true;}
|
||||
UpdateSkeleton();
|
||||
UpdateSkeleton(const UpdateSkeleton&, const osg::CopyOp&);
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
|
||||
|
||||
bool needToValidate() const;
|
||||
protected:
|
||||
bool _needValidate;
|
||||
};
|
||||
|
||||
Skeleton(const Skeleton& b, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : Bone(b,copyop) {}
|
||||
Skeleton();
|
||||
void setDefaultUpdateCallback(void);
|
||||
void computeBindMatrix() { _invBindInSkeletonSpace = osg::Matrix::inverse(_bindInBoneSpace); _needToRecomputeBindMatrix = false; }
|
||||
Skeleton(const Skeleton&, const osg::CopyOp&);
|
||||
|
||||
void setDefaultUpdateCallback();
|
||||
void computeBindMatrix();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,20 @@
|
||||
|
||||
using namespace osgAnimation;
|
||||
|
||||
Skeleton::Skeleton() {}
|
||||
Skeleton::Skeleton(const Skeleton& b, const osg::CopyOp& copyop) : Bone(b,copyop) {}
|
||||
|
||||
Skeleton::UpdateSkeleton::UpdateSkeleton() : _needValidate(true) {}
|
||||
Skeleton::UpdateSkeleton::UpdateSkeleton(const UpdateSkeleton& us, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY) : osg::Object(us, copyop), osg::NodeCallback(us, copyop)
|
||||
{
|
||||
_needValidate = true;
|
||||
}
|
||||
bool Skeleton::UpdateSkeleton::needToValidate() const
|
||||
{
|
||||
return _needValidate;
|
||||
}
|
||||
|
||||
|
||||
class ValidateSkeletonVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
@ -56,25 +70,28 @@ public:
|
||||
|
||||
void Skeleton::UpdateSkeleton::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
if (_needValidate && nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
||||
if (nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
||||
{
|
||||
Skeleton* b = dynamic_cast<Skeleton*>(node);
|
||||
if (b)
|
||||
Skeleton* skeleton = dynamic_cast<Skeleton*>(node);
|
||||
if (_needValidate && skeleton)
|
||||
{
|
||||
ValidateSkeletonVisitor visitor;
|
||||
node->accept(visitor);
|
||||
_needValidate = false;
|
||||
}
|
||||
|
||||
_needValidate = false;
|
||||
if (skeleton->needToComputeBindMatrix())
|
||||
skeleton->computeBindMatrix();
|
||||
}
|
||||
traverse(node,nv);
|
||||
}
|
||||
|
||||
Skeleton::Skeleton()
|
||||
{
|
||||
}
|
||||
|
||||
void Skeleton::setDefaultUpdateCallback()
|
||||
{
|
||||
setUpdateCallback(new Skeleton::UpdateSkeleton );
|
||||
}
|
||||
|
||||
void Skeleton::computeBindMatrix()
|
||||
{
|
||||
_invBindInSkeletonSpace = osg::Matrix::inverse(_bindInBoneSpace);
|
||||
_needToRecomputeBindMatrix = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user