Replaced frame delta computation that was originally based on a local static variable, replacing it with member variable to tracking the previous frame time. This fixes a bug in the wind computation when multiple PrecipitaionEffects are in the scene.

This commit is contained in:
Robert Osfield
2009-06-11 14:56:54 +00:00
parent e5a436b131
commit 27cf68b22d
2 changed files with 8 additions and 4 deletions

View File

@@ -256,6 +256,8 @@ namespace osgParticle
osg::Vec3 _inverse_dv;
osg::Vec3 _inverse_dw;
double _previousFrameTime;
};
}

View File

@@ -105,7 +105,8 @@ static osg::Image* createSpotLightImage(const osg::Vec4& centerColour, const osg
}
PrecipitationEffect::PrecipitationEffect()
PrecipitationEffect::PrecipitationEffect():
_previousFrameTime(FLT_MAX)
{
setNumChildrenRequiringUpdateTraversal(1);
@@ -201,10 +202,11 @@ void PrecipitationEffect::traverse(osg::NodeVisitor& nv)
if (nv.getFrameStamp())
{
double currentTime = nv.getFrameStamp()->getSimulationTime();
static double previousTime = currentTime;
double delta = currentTime - previousTime;
if (_previousFrameTime==FLT_MAX) _previousFrameTime = currentTime;
double delta = currentTime - _previousFrameTime;
_origin += _wind * delta;
previousTime = currentTime;
_previousFrameTime = currentTime;
}
return;