diff --git a/include/osgParticle/PrecipitationEffect b/include/osgParticle/PrecipitationEffect index 4d7485058..4e855c11c 100644 --- a/include/osgParticle/PrecipitationEffect +++ b/include/osgParticle/PrecipitationEffect @@ -256,6 +256,8 @@ namespace osgParticle osg::Vec3 _inverse_dv; osg::Vec3 _inverse_dw; + double _previousFrameTime; + }; } diff --git a/src/osgParticle/PrecipitationEffect.cpp b/src/osgParticle/PrecipitationEffect.cpp index 62467fc97..5a22e6a90 100644 --- a/src/osgParticle/PrecipitationEffect.cpp +++ b/src/osgParticle/PrecipitationEffect.cpp @@ -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;