Fix inactive RigGeometry not rendering correctly

openmw-38
scrawl 9 years ago
parent e0c9265148
commit eb458bf9c8

@ -82,7 +82,7 @@ RigGeometry::RigGeometry(const RigGeometry &copy, const osg::CopyOp &copyop)
, mSkeleton(NULL) , mSkeleton(NULL)
, mInfluenceMap(copy.mInfluenceMap) , mInfluenceMap(copy.mInfluenceMap)
, mLastFrameNumber(0) , mLastFrameNumber(0)
, mBoundsFirstFrame(copy.mBoundsFirstFrame) , mBoundsFirstFrame(true)
{ {
setSourceGeometry(copy.mSourceGeometry); setSourceGeometry(copy.mSourceGeometry);
} }
@ -211,6 +211,8 @@ void RigGeometry::update(osg::NodeVisitor* nv)
{ {
if (!mSkeleton) if (!mSkeleton)
{ {
std::cerr << "RigGeometry rendering with no skeleton, should have been initialized by UpdateVisitor" << std::endl;
// try to recover anyway, though rendering is likely to be incorrect.
if (!initFromParentSkeleton(nv)) if (!initFromParentSkeleton(nv))
return; return;
} }

@ -135,7 +135,10 @@ bool Skeleton::getActive() const
void Skeleton::traverse(osg::NodeVisitor& nv) void Skeleton::traverse(osg::NodeVisitor& nv)
{ {
if (!mActive && nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR && mLastFrameNumber != 0) 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())
return; return;
osg::Group::traverse(nv); osg::Group::traverse(nv);
} }

Loading…
Cancel
Save