diff --git a/include/osgParticle/ParticleSystem b/include/osgParticle/ParticleSystem index 67f3ffb4e..dd49ea5a3 100644 --- a/include/osgParticle/ParticleSystem +++ b/include/osgParticle/ParticleSystem @@ -166,7 +166,7 @@ namespace osgParticle virtual osg::BoundingBox computeBound() const; - osgDB::ReadWriteMutex& getReadWriteMutex() const { return _readWriteMutex; } + osgDB::ReadWriteMutex* getReadWriteMutex() const { return &_readWriteMutex; } protected: diff --git a/src/osgParticle/ConnectedParticleSystem.cpp b/src/osgParticle/ConnectedParticleSystem.cpp index 1138e830f..120ea3149 100644 --- a/src/osgParticle/ConnectedParticleSystem.cpp +++ b/src/osgParticle/ConnectedParticleSystem.cpp @@ -114,9 +114,12 @@ void ConnectedParticleSystem::reuseParticle(int particleIndex) void ConnectedParticleSystem::drawImplementation(osg::State& state) const { + osgDB::ScopedReadLock lock(_readWriteMutex); + const Particle* particle = (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0; if (!particle) return; + osg::Vec4 pixelSizeVector = osg::CullingSet::computePixelSizeVector(*state.getCurrentViewport(),state.getProjectionMatrix(),state.getModelViewMatrix()); float unitPixelSize = fabs(1.0/(particle->getPosition()*pixelSizeVector)); float pixelSizeOfFirstParticle = unitPixelSize * particle->getCurrentSize(); diff --git a/src/osgParticle/ParticleProcessor.cpp b/src/osgParticle/ParticleProcessor.cpp index bf72416b8..58bf00c5f 100644 --- a/src/osgParticle/ParticleProcessor.cpp +++ b/src/osgParticle/ParticleProcessor.cpp @@ -64,7 +64,7 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv) { if (nv.getFrameStamp()) { - osgDB::ScopedWriteLock lock(_ps->getReadWriteMutex()); + osgDB::ScopedWriteLock lock(*(_ps->getReadWriteMutex())); //added- 1/17/06- bgandere@nps.edu //a check to make sure we havent updated yet this frame diff --git a/src/osgParticle/ParticleSystemUpdater.cpp b/src/osgParticle/ParticleSystemUpdater.cpp index 2266fca42..02c1ef5cb 100644 --- a/src/osgParticle/ParticleSystemUpdater.cpp +++ b/src/osgParticle/ParticleSystemUpdater.cpp @@ -40,7 +40,7 @@ void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv) { ParticleSystem* ps = i->get(); - osgDB::ScopedWriteLock lock(ps->getReadWriteMutex()); + osgDB::ScopedWriteLock lock(*(ps->getReadWriteMutex())); if (!ps->isFrozen() && (ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps->getFreezeOnCull())) {