1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 09:36:43 +00:00

Skeleton update fix

This commit is contained in:
scrawl 2015-04-21 20:22:32 +02:00
parent bd88758962
commit 9246a668b9
3 changed files with 13 additions and 5 deletions

View file

@ -135,7 +135,7 @@ void RigGeometry::update(osg::NodeVisitor* nv)
return; return;
} }
mSkeleton->updateBoneMatrices(); mSkeleton->updateBoneMatrices(nv);
osg::NodePath path; osg::NodePath path;
bool foundSkel = false; bool foundSkel = false;

View file

@ -34,6 +34,7 @@ private:
Skeleton::Skeleton() Skeleton::Skeleton()
: mBoneCacheInit(false) : mBoneCacheInit(false)
, mNeedToUpdateBoneMatrices(true) , mNeedToUpdateBoneMatrices(true)
, mLastFrameNumber(0)
{ {
} }
@ -42,6 +43,7 @@ Skeleton::Skeleton(const Skeleton &copy, const osg::CopyOp &copyop)
: osg::Group(copy, copyop) : osg::Group(copy, copyop)
, mBoneCacheInit(false) , mBoneCacheInit(false)
, mNeedToUpdateBoneMatrices(true) , mNeedToUpdateBoneMatrices(true)
, mLastFrameNumber(0)
{ {
} }
@ -100,11 +102,15 @@ Bone* Skeleton::getBone(const std::string &name)
return bone; return bone;
} }
void Skeleton::updateBoneMatrices() void Skeleton::updateBoneMatrices(osg::NodeVisitor* nv)
{ {
//if (mNeedToUpdateBoneMatrices) if (nv->getFrameStamp()->getFrameNumber() != mLastFrameNumber)
{ mNeedToUpdateBoneMatrices = true;
mLastFrameNumber = nv->getFrameStamp()->getFrameNumber();
if (mNeedToUpdateBoneMatrices)
{
if (mRootBone.get()) if (mRootBone.get())
{ {
for (unsigned int i=0; i<mRootBone->mChildren.size(); ++i) for (unsigned int i=0; i<mRootBone->mChildren.size(); ++i)

View file

@ -39,7 +39,7 @@ namespace NifOsg
META_Node(NifOsg, Skeleton) META_Node(NifOsg, Skeleton)
void updateBoneMatrices(); void updateBoneMatrices(osg::NodeVisitor* nv);
private: private:
// The root bone is not a "real" bone, it has no corresponding node in the scene graph. // The root bone is not a "real" bone, it has no corresponding node in the scene graph.
@ -51,6 +51,8 @@ namespace NifOsg
bool mBoneCacheInit; bool mBoneCacheInit;
bool mNeedToUpdateBoneMatrices; bool mNeedToUpdateBoneMatrices;
unsigned int mLastFrameNumber;
}; };
} }