Fix "RigGeometry rendering with no skeleton" warnings in rare cases

move
scrawl 9 years ago
parent 1e5b4bea0a
commit 8791063110

@ -38,6 +38,8 @@ Skeleton::Skeleton()
, mNeedToUpdateBoneMatrices(true)
, mActive(true)
, mLastFrameNumber(0)
, mTraversedEvenFrame(false)
, mTraversedOddFrame(false)
{
}
@ -48,6 +50,8 @@ Skeleton::Skeleton(const Skeleton &copy, const osg::CopyOp &copyop)
, mNeedToUpdateBoneMatrices(true)
, mActive(copy.mActive)
, mLastFrameNumber(0)
, mTraversedEvenFrame(false)
, mTraversedOddFrame(false)
{
}
@ -111,6 +115,11 @@ void Skeleton::updateBoneMatrices(osg::NodeVisitor* nv)
mLastFrameNumber = nv->getTraversalNumber();
if (mLastFrameNumber % 2 == 0)
mTraversedEvenFrame = true;
else
mTraversedOddFrame = true;
if (mNeedToUpdateBoneMatrices)
{
if (mRootBone.get())
@ -140,7 +149,7 @@ void Skeleton::traverse(osg::NodeVisitor& nv)
if (!getActive() && nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR
// need to process at least 2 frames before shutting off update, since we need to have both frame-alternating RigGeometries initialized
// this would be more naturally handled if the double-buffering was implemented in RigGeometry itself rather than in a FrameSwitch decorator node
&& mLastFrameNumber != 0 && mLastFrameNumber+2 <= nv.getTraversalNumber())
&& mLastFrameNumber != 0 && mTraversedEvenFrame && mTraversedOddFrame)
return;
osg::Group::traverse(nv);
}

@ -69,6 +69,8 @@ namespace SceneUtil
bool mActive;
unsigned int mLastFrameNumber;
bool mTraversedEvenFrame;
bool mTraversedOddFrame;
};
}

Loading…
Cancel
Save