Particles: fix a deadlock condition
This commit is contained in:
parent
84c15f6384
commit
3b41b0c6d3
@ -78,6 +78,21 @@ public:
|
|||||||
// _localWind = om.preMult(w);
|
// _localWind = om.preMult(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only call this with the lock held!
|
||||||
|
osg::Group* internalGetCommonRoot()
|
||||||
|
{
|
||||||
|
if (!_commonRoot.valid()) {
|
||||||
|
SG_LOG(SG_PARTICLES, SG_DEBUG, "Particle common root called.");
|
||||||
|
_commonRoot = new osg::Group;
|
||||||
|
_commonRoot->setName("common particle system root");
|
||||||
|
_commonGeode->setName("common particle system geode");
|
||||||
|
_commonRoot->addChild(_commonGeode);
|
||||||
|
_commonRoot->addChild(_updater);
|
||||||
|
_commonRoot->setNodeMask(~simgear::MODELLIGHT_BIT);
|
||||||
|
}
|
||||||
|
return _commonRoot.get();
|
||||||
|
}
|
||||||
|
|
||||||
std::mutex _lock;
|
std::mutex _lock;
|
||||||
bool _frozen = false;
|
bool _frozen = false;
|
||||||
osg::ref_ptr<osgParticle::ParticleSystemUpdater> _updater;
|
osg::ref_ptr<osgParticle::ParticleSystemUpdater> _updater;
|
||||||
@ -342,16 +357,7 @@ void ParticlesGlobalManager::setWindFrom(const double from_deg, const double spe
|
|||||||
osg::Group* ParticlesGlobalManager::getCommonRoot()
|
osg::Group* ParticlesGlobalManager::getCommonRoot()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> g(d->_lock);
|
std::lock_guard<std::mutex> g(d->_lock);
|
||||||
if (!d->_commonRoot.valid()) {
|
return d->internalGetCommonRoot();
|
||||||
SG_LOG(SG_PARTICLES, SG_DEBUG, "Particle common root called.");
|
|
||||||
d->_commonRoot = new osg::Group;
|
|
||||||
d->_commonRoot->setName("common particle system root");
|
|
||||||
d->_commonGeode->setName("common particle system geode");
|
|
||||||
d->_commonRoot->addChild(d->_commonGeode);
|
|
||||||
d->_commonRoot->addChild(d->_updater);
|
|
||||||
d->_commonRoot->setNodeMask(~simgear::MODELLIGHT_BIT);
|
|
||||||
}
|
|
||||||
return d->_commonRoot.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> ParticlesGlobalManager::appendParticles(const SGPropertyNode* configNode, SGPropertyNode* modelRoot, const osgDB::Options* options)
|
osg::ref_ptr<osg::Group> ParticlesGlobalManager::appendParticles(const SGPropertyNode* configNode, SGPropertyNode* modelRoot, const osgDB::Options* options)
|
||||||
@ -722,12 +728,13 @@ osg::ref_ptr<osg::Group> ParticlesGlobalManager::appendParticles(const SGPropert
|
|||||||
}
|
}
|
||||||
|
|
||||||
// touch shared data now (and not before)
|
// touch shared data now (and not before)
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> g(d->_lock);
|
std::lock_guard<std::mutex> g(d->_lock);
|
||||||
d->_updater->addParticleSystem(particleSys);
|
d->_updater->addParticleSystem(particleSys);
|
||||||
|
|
||||||
if (attach != "local") {
|
if (attach != "local") {
|
||||||
getCommonRoot()->addChild(callback()->particleFrame);
|
d->internalGetCommonRoot()->addChild(callback()->particleFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->_globalCallbackRegistered) {
|
if (!d->_globalCallbackRegistered) {
|
||||||
|
Loading…
Reference in New Issue
Block a user