From 97f8cdaaea4de6703d5ba1f80025f52cf38825a4 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Tue, 16 Feb 2016 17:33:40 +0100 Subject: [PATCH] Fix for the particle system. The problem was that the change to make FGScenery a standard subsystem caused the particle OSG group to no longer be inserted into the scene graph. The solution was to convert the particle group to be set up as a standard branch of the scene graph, alongside the terrain, models, aircraft, and interior branches. The particle system is now set up as part of the init() subsystem function call, so it is compatible with the new subsystem design. --- src/Main/fg_init.cxx | 8 -------- src/Scenery/scenery.cxx | 7 +++++++ src/Scenery/scenery.hxx | 3 +++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index b2639671d..61d342588 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -742,14 +742,6 @@ void fgCreateSubsystems(bool duringReset) { globals->add_subsystem( "http", new FGHTTPClient ); } - //////////////////////////////////////////////////////////////////// - // Initialize the scenery management subsystem. - //////////////////////////////////////////////////////////////////// - - globals->get_scenery()->get_scene_graph() - ->addChild(simgear::Particles::getCommonRoot()); - simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true)); - //////////////////////////////////////////////////////////////////// // Initialize the flight model subsystem. //////////////////////////////////////////////////////////////////// diff --git a/src/Scenery/scenery.cxx b/src/Scenery/scenery.cxx index f160b4267..8ec3e5703 100644 --- a/src/Scenery/scenery.cxx +++ b/src/Scenery/scenery.cxx @@ -327,6 +327,12 @@ void FGScenery::init() { interiorLOD->addChild(interior_branch.get(), 0.0, 50.0); aircraft_branch->addChild( interiorLOD ); + // Set up the particle system as a directly accessible branch of the scene graph. + particles_branch = simgear::Particles::getCommonRoot(); + particles_branch->setName("Particles"); + scene_graph->addChild(particles_branch.get()); + simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true)); + // Initials values needed by the draw-time object loader sgUserDataInit( globals->get_props() ); @@ -341,6 +347,7 @@ void FGScenery::shutdown() terrain_branch = NULL; models_branch = NULL; aircraft_branch = NULL; + particles_branch = NULL; } diff --git a/src/Scenery/scenery.hxx b/src/Scenery/scenery.hxx index cc659882c..593707d14 100644 --- a/src/Scenery/scenery.hxx +++ b/src/Scenery/scenery.hxx @@ -34,6 +34,7 @@ #include #include +#include #include #include "SceneryPager.hxx" @@ -55,6 +56,7 @@ class FGScenery : public SGSubsystem osg::ref_ptr models_branch; osg::ref_ptr aircraft_branch; osg::ref_ptr interior_branch; + osg::ref_ptr particles_branch; osg::ref_ptr _pager; ScenerySwitchListener* _listener; @@ -114,6 +116,7 @@ public: osg::Group *get_models_branch () const { return models_branch.get(); } osg::Group *get_aircraft_branch () const { return aircraft_branch.get(); } osg::Group *get_interior_branch () const { return interior_branch.get(); } + osg::Group *get_particles_branch () const { return particles_branch.get(); } /// Returns true if scenery is available for the given lat, lon position /// within a range of range_m.