diff --git a/include/osgParticle/ParticleProcessor b/include/osgParticle/ParticleProcessor index c2b23913b..2a20a5255 100644 --- a/include/osgParticle/ParticleProcessor +++ b/include/osgParticle/ParticleProcessor @@ -171,6 +171,8 @@ namespace osgParticle //added- 1/17/06- bgandere@nps.edu //a var to keep from doing multiple updates int _frameNumber; + + OpenThreads::Mutex _cullUpdatelMutex; }; // INLINE FUNCTIONS diff --git a/include/osgParticle/ParticleSystemUpdater b/include/osgParticle/ParticleSystemUpdater index 5ab10886b..abf3070c2 100644 --- a/include/osgParticle/ParticleSystemUpdater +++ b/include/osgParticle/ParticleSystemUpdater @@ -91,6 +91,8 @@ namespace osgParticle //added 1/17/06- bgandere@nps.edu //a var to keep from doing multiple updates per frame int _frameNumber; + + OpenThreads::Mutex _cullUpdatelMutex; }; // INLINE FUNCTIONS diff --git a/src/osgParticle/ParticleProcessor.cpp b/src/osgParticle/ParticleProcessor.cpp index 39580b087..ee15abc0d 100644 --- a/src/osgParticle/ParticleProcessor.cpp +++ b/src/osgParticle/ParticleProcessor.cpp @@ -62,9 +62,10 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv) // continue only if the particle system is valid if (_ps.valid()) { - if (nv.getFrameStamp()) { + OpenThreads::ScopedLock lock(_cullUpdatelMutex); + //added- 1/17/06- bgandere@nps.edu //a check to make sure we havent updated yet this frame if(_frameNumber < nv.getFrameStamp()->getFrameNumber()) diff --git a/src/osgParticle/ParticleSystemUpdater.cpp b/src/osgParticle/ParticleSystemUpdater.cpp index b76650954..75ff99a30 100644 --- a/src/osgParticle/ParticleSystemUpdater.cpp +++ b/src/osgParticle/ParticleSystemUpdater.cpp @@ -23,14 +23,18 @@ osgParticle::ParticleSystemUpdater::ParticleSystemUpdater(const ParticleSystemUp void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv) { osgUtil::CullVisitor *cv = dynamic_cast(&nv); - if (cv) { + if (cv) + { if (nv.getFrameStamp()) { - //added 1/17/06- bgandere@nps.edu - //ensures ParticleSystem will only be updated once per frame - //regardless of the number of cameras viewing it - if( _frameNumber < nv.getFrameStamp()->getFrameNumber()) - { + + OpenThreads::ScopedLock lock(_cullUpdatelMutex); + + //added 1/17/06- bgandere@nps.edu + //ensures ParticleSystem will only be updated once per frame + //regardless of the number of cameras viewing it + if( _frameNumber < nv.getFrameStamp()->getFrameNumber()) + { double t = nv.getFrameStamp()->getReferenceTime(); if (_t0 != -1) { @@ -44,10 +48,11 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv) } } _t0 = t; - } - //added- 1/17/06- bgandere@nps.edu - //set frame number to the current frame number - _frameNumber = nv.getFrameStamp()->getFrameNumber(); + } + + //added- 1/17/06- bgandere@nps.edu + //set frame number to the current frame number + _frameNumber = nv.getFrameStamp()->getFrameNumber(); } else {