forked from mirror/openmw-tes3mp
Add framenumber checks in various cull callbacks, so we don't update more than once per frame when multiple cameras are used
This commit is contained in:
parent
169d76b49b
commit
8e69c80bf6
3 changed files with 20 additions and 6 deletions
|
@ -113,6 +113,7 @@ namespace
|
||||||
|
|
||||||
// NodeCallback used to have a transform always oriented towards the camera. Can have translation and scale
|
// NodeCallback used to have a transform always oriented towards the camera. Can have translation and scale
|
||||||
// set just like a regular MatrixTransform, but the rotation set will be overridden in order to face the camera.
|
// set just like a regular MatrixTransform, but the rotation set will be overridden in order to face the camera.
|
||||||
|
// Must be set as a cull callback.
|
||||||
class BillboardCallback : public osg::NodeCallback
|
class BillboardCallback : public osg::NodeCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -160,24 +161,34 @@ namespace
|
||||||
struct UpdateMorphGeometry : public osg::Drawable::CullCallback
|
struct UpdateMorphGeometry : public osg::Drawable::CullCallback
|
||||||
{
|
{
|
||||||
UpdateMorphGeometry()
|
UpdateMorphGeometry()
|
||||||
|
: mLastFrameNumber(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMorphGeometry(const UpdateMorphGeometry& copy, const osg::CopyOp& copyop)
|
UpdateMorphGeometry(const UpdateMorphGeometry& copy, const osg::CopyOp& copyop)
|
||||||
: osg::Drawable::CullCallback(copy, copyop)
|
: osg::Drawable::CullCallback(copy, copyop)
|
||||||
|
, mLastFrameNumber(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
META_Object(NifOsg, UpdateMorphGeometry)
|
META_Object(NifOsg, UpdateMorphGeometry)
|
||||||
|
|
||||||
virtual bool cull(osg::NodeVisitor *, osg::Drawable * drw, osg::State *) const
|
virtual bool cull(osg::NodeVisitor* nv, osg::Drawable * drw, osg::State *) const
|
||||||
{
|
{
|
||||||
osgAnimation::MorphGeometry* geom = static_cast<osgAnimation::MorphGeometry*>(drw);
|
osgAnimation::MorphGeometry* geom = static_cast<osgAnimation::MorphGeometry*>(drw);
|
||||||
if (!geom)
|
if (!geom)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (mLastFrameNumber == nv->getFrameStamp()->getFrameNumber())
|
||||||
|
return false;
|
||||||
|
mLastFrameNumber = nv->getFrameStamp()->getFrameNumber();
|
||||||
|
|
||||||
geom->transformSoftwareMethod();
|
geom->transformSoftwareMethod();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable unsigned int mLastFrameNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback to return a static bounding box for a MorphGeometry. The idea is to not recalculate the bounding box
|
// Callback to return a static bounding box for a MorphGeometry. The idea is to not recalculate the bounding box
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
|
|
||||||
RigGeometry::RigGeometry()
|
RigGeometry::RigGeometry()
|
||||||
: mSkeleton(NULL)
|
: mSkeleton(NULL)
|
||||||
, mFirstFrame(true)
|
, mLastFrameNumber(0)
|
||||||
, mBoundsFirstFrame(true)
|
, mBoundsFirstFrame(true)
|
||||||
{
|
{
|
||||||
setCullCallback(new UpdateRigGeometry);
|
setCullCallback(new UpdateRigGeometry);
|
||||||
|
@ -72,7 +72,7 @@ RigGeometry::RigGeometry(const RigGeometry ©, const osg::CopyOp ©op)
|
||||||
: osg::Geometry(copy, copyop)
|
: osg::Geometry(copy, copyop)
|
||||||
, mSkeleton(NULL)
|
, mSkeleton(NULL)
|
||||||
, mInfluenceMap(copy.mInfluenceMap)
|
, mInfluenceMap(copy.mInfluenceMap)
|
||||||
, mFirstFrame(copy.mFirstFrame)
|
, mLastFrameNumber(0)
|
||||||
, mBoundsFirstFrame(copy.mBoundsFirstFrame)
|
, mBoundsFirstFrame(copy.mBoundsFirstFrame)
|
||||||
{
|
{
|
||||||
setSourceGeometry(copy.mSourceGeometry);
|
setSourceGeometry(copy.mSourceGeometry);
|
||||||
|
@ -206,9 +206,12 @@ void RigGeometry::update(osg::NodeVisitor* nv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSkeleton->getActive() && !mFirstFrame)
|
if (!mSkeleton->getActive() && mLastFrameNumber != 0)
|
||||||
return;
|
return;
|
||||||
mFirstFrame = false;
|
|
||||||
|
if (mLastFrameNumber == nv->getFrameStamp()->getFrameNumber())
|
||||||
|
return;
|
||||||
|
mLastFrameNumber = nv->getFrameStamp()->getFrameNumber();
|
||||||
|
|
||||||
mSkeleton->updateBoneMatrices(nv);
|
mSkeleton->updateBoneMatrices(nv);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace SceneUtil
|
||||||
|
|
||||||
BoneSphereMap mBoneSphereMap;
|
BoneSphereMap mBoneSphereMap;
|
||||||
|
|
||||||
bool mFirstFrame;
|
unsigned int mLastFrameNumber;
|
||||||
bool mBoundsFirstFrame;
|
bool mBoundsFirstFrame;
|
||||||
|
|
||||||
bool initFromParentSkeleton(osg::NodeVisitor* nv);
|
bool initFromParentSkeleton(osg::NodeVisitor* nv);
|
||||||
|
|
Loading…
Reference in a new issue