mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Fix "RigGeometry rendering with no skeleton" warnings in rare cases
This commit is contained in:
parent
1e5b4bea0a
commit
8791063110
2 changed files with 12 additions and 1 deletions
|
@ -38,6 +38,8 @@ Skeleton::Skeleton()
|
|||
, mNeedToUpdateBoneMatrices(true)
|
||||
, mActive(true)
|
||||
, mLastFrameNumber(0)
|
||||
, mTraversedEvenFrame(false)
|
||||
, mTraversedOddFrame(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -48,6 +50,8 @@ Skeleton::Skeleton(const Skeleton ©, const osg::CopyOp ©op)
|
|||
, 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…
Reference in a new issue