// to be updated in every loop.
// Sound manager is updated last so it can use the CPU while the GPU
// is processing the scenery (doubled the frame-rate for me) -EMH-
- globals->add_subsystem("sound", new FGSoundManager, SGSubsystemMgr::SOUND);
+ globals->add_new_subsystem<FGSoundManager>(SGSubsystemMgr::SOUND);
////////////////////////////////////////////////////////////////////
// Initialize the event manager subsystem.
////////////////////////////////////////////////////////////////////
// Add the FlightGear property utilities.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem("airport-dynamics", new flightgear::AirportDynamicsManager);
+ globals->add_new_subsystem<flightgear::AirportDynamicsManager>();
////////////////////////////////////////////////////////////////////
// Add the performance monitoring system.
globals->add_subsystem("aircraft-model", new FGAircraftModel, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("model-manager", new FGModelMgr, SGSubsystemMgr::DISPLAY);
- globals->add_subsystem("view-manager", new FGViewMgr, SGSubsystemMgr::DISPLAY);
-
- globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
- SGSubsystemMgr::DISPLAY);
+ globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);
}
void fgPostInitSubsystems()
// order is important here since tile-manager shutdown needs to
// access the scenery object
- globals->set_tile_mgr(NULL);
- globals->set_scenery(NULL);
+ subsystemManger->remove(FGTileMgr::subsystemName());
+ subsystemManger->remove(FGScenery::subsystemName());
+
FGScenery::getPagerSingleton()->clearRequests();
flightgear::CameraGroup::setDefault(NULL);
fg_home( "" ),
time_params( NULL ),
ephem( NULL ),
- viewmgr( NULL ),
commands( SGCommandMgr::instance() ),
channel_options_list( NULL ),
initial_waypoints( NULL ),
subsystem_mgr->unbind();
subsystem_mgr->remove("aircraft-model");
- subsystem_mgr->remove("tile-manager");
subsystem_mgr->remove("model-manager");
- _tile_mgr.clear();
+
+ subsystem_mgr->remove(FGTileMgr::subsystemName());
osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer());
if (vw) {
}
osgDB::Registry::instance()->clearObjectCache();
+ subsystem_mgr->remove(FGScenery::subsystemName());
// renderer touches subsystems during its destruction
set_renderer(NULL);
- _scenery.clear();
_chatter_queue.clear();
delete subsystem_mgr;
}
}
-FGViewer *
-FGGlobals::get_current_view () const
-{
- return viewmgr->get_current_view();
-}
-
long int FGGlobals::get_warp() const
{
return fgGetInt("/sim/time/warp");
FGScenery* FGGlobals::get_scenery () const
{
- return _scenery.get();
+ return get_subsystem<FGScenery>();
}
-void FGGlobals::set_scenery ( FGScenery *s )
+FGTileMgr* FGGlobals::get_tile_mgr () const
{
- _scenery = s;
+ return get_subsystem<FGTileMgr>();
}
-FGTileMgr* FGGlobals::get_tile_mgr () const
+FGViewMgr *FGGlobals::get_viewmgr() const
{
- return _tile_mgr.get();
+ return get_subsystem<FGViewMgr>();
}
-void FGGlobals::set_tile_mgr ( FGTileMgr *t )
+FGViewer* FGGlobals::get_current_view () const
{
- _tile_mgr = t;
+ FGViewMgr* vm = get_viewmgr();
+ return vm ? vm->get_current_view() : 0;
}
void FGGlobals::set_matlib( SGMaterialLib *m )
// Material properties library
SGSharedPtr<SGMaterialLib> matlib;
- // viewer manager
- FGViewMgr *viewmgr;
-
SGCommandMgr *commands;
// list of serial port-like configurations
// and or flight-plan file during initialization
string_list *initial_waypoints;
- // FlightGear scenery manager
- SGSharedPtr<FGScenery> _scenery;
-
- // Tile manager
- SGSharedPtr<FGTileMgr> _tile_mgr;
-
FGFontCache *fontcache;
// Navigational Aids
inline SGMaterialLib *get_matlib() const { return matlib; }
void set_matlib( SGMaterialLib *m );
- inline FGViewMgr *get_viewmgr() const { return viewmgr; }
- inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
- FGViewer *get_current_view() const;
-
inline SGPropertyNode *get_props () { return props; }
/**
initial_waypoints = list;
}
+ FGViewMgr *get_viewmgr() const;
+ FGViewer *get_current_view() const;
+
FGControls *get_controls() const;
FGScenery * get_scenery () const;
- void set_scenery ( FGScenery *s );
FGTileMgr * get_tile_mgr () const;
- void set_tile_mgr ( FGTileMgr *t );
inline FGFontCache *get_fontcache() const { return fontcache; }
// Initialize the TG scenery subsystem.
////////////////////////////////////////////////////////////////////
- globals->set_scenery( new FGScenery );
+ globals->add_new_subsystem<FGScenery>(SGSubsystemMgr::DISPLAY);
globals->get_scenery()->init();
globals->get_scenery()->bind();
- globals->set_tile_mgr( new FGTileMgr );
+ globals->add_new_subsystem<FGTileMgr>(SGSubsystemMgr::DISPLAY);
fgSplashProgress("creating-subsystems");
} else if (( idle_state == 7 ) || (idle_state == 2007)) {
~FGSoundManager() {}
void update(double dt) {}
+
+ static const char* subsystemName() { return "sound"; }
};
#endif // ENABLE_AUDIO_SUPPORT
throw sg_io_exception("Error loading materials file", mpath);
}
- globals->set_scenery( new FGScenery );
- globals->get_scenery()->init();
- globals->get_scenery()->bind();
+ FGScenery* scenery = globals->add_new_subsystem<FGScenery>();
+ scenery->init();
+ scenery->bind();
// The file path list must be set in the registry.
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
current_view_orientation(SGQuatd::zeros()),
current_view_or_offset(SGQuatd::zeros())
{
- globals->set_viewmgr(this);
}
// Destructor
FGViewMgr::~FGViewMgr( void )
{
- globals->set_viewmgr(NULL);
}
void
void add_view( FGViewer * v );
+ static const char* subsystemName() { return "view-mgr"; }
private:
void do_bind();