From 86f6b9430043518232152db8c6baa6ebd699083a Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 16 Aug 2020 12:32:06 +0100 Subject: [PATCH] Use new thread-safe particles manager. Requires corresponding SG commit --- src/Environment/environment_mgr.cxx | 5 +++-- src/Main/fg_init.cxx | 2 +- src/Main/fg_props.cxx | 3 ++- src/Scenery/scenery.cxx | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Environment/environment_mgr.cxx b/src/Environment/environment_mgr.cxx index be2d985f8..90db03be3 100644 --- a/src/Environment/environment_mgr.cxx +++ b/src/Environment/environment_mgr.cxx @@ -266,8 +266,9 @@ FGEnvironmentMgr::update (double dt) SGGeod aircraftPos(globals->get_aircraft_position()); _environment->set_elevation_ft( aircraftPos.getElevationFt() ); - simgear::Particles::setWindFrom( _environment->get_wind_from_heading_deg(), - _environment->get_wind_speed_kt() ); + auto particlesManager = simgear::ParticlesGlobalManager::instance(); + particlesManager->setWindFrom(_environment->get_wind_from_heading_deg(), + _environment->get_wind_speed_kt()); if( _cloudLayersDirty ) { _cloudLayersDirty = false; fgClouds->set_update_event( fgClouds->get_update_event()+1 ); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 8c024b9f3..914a557d9 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1309,7 +1309,7 @@ void fgStartNewReset() simgear::clearSharedTreeGeometry(); simgear::clearEffectCache(); simgear::SGModelLib::resetPropertyRoot(); - simgear::GlobalParticleCallback::setSwitch(NULL); + simgear::ParticlesGlobalManager::clear(); simgear::UniformFactory::instance()->reset(); flightgear::addons::AddonManager::reset(); diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index ca48f5446..767a44ec3 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -229,7 +229,8 @@ setFreeze (bool f) frozen = f; // Pause the particle system - simgear::Particles::setFrozen(f); + auto p = simgear::ParticlesGlobalManager::instance(); + p->setFrozen(f); } diff --git a/src/Scenery/scenery.cxx b/src/Scenery/scenery.cxx index 0ce86801b..33c80a32c 100644 --- a/src/Scenery/scenery.cxx +++ b/src/Scenery/scenery.cxx @@ -391,10 +391,11 @@ void FGScenery::init() { aircraft_branch->addChild( interiorLOD ); // Set up the particle system as a directly accessible branch of the scene graph. - particles_branch = simgear::Particles::getCommonRoot(); + auto paricles = simgear::ParticlesGlobalManager::instance(); + particles_branch = paricles->getCommonRoot(); particles_branch->setName("Particles"); scene_graph->addChild(particles_branch.get()); - simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true)); + paricles->setSwitchNode(fgGetNode("/sim/rendering/particles", true)); // Set up the precipitation system. precipitation_branch = new osg::Group;