1
0
Fork 0

Aircraft-model subsystem behaves better

- make shutdown logic more robust
- shutdown is no longer special cased in globals.
This commit is contained in:
James Turner 2015-12-18 20:13:23 -08:00
parent 89065ea5c2
commit 0f590280c7
4 changed files with 13 additions and 11 deletions

View file

@ -894,7 +894,7 @@ void fgCreateSubsystems(bool duringReset) {
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY); globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
} }
globals->add_subsystem("aircraft-model", new FGAircraftModel, SGSubsystemMgr::DISPLAY); globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY); globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY); globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);

View file

@ -215,8 +215,6 @@ FGGlobals::~FGGlobals()
subsystem_mgr->shutdown(); subsystem_mgr->shutdown();
subsystem_mgr->unbind(); subsystem_mgr->unbind();
subsystem_mgr->remove("aircraft-model");
subsystem_mgr->remove(FGTileMgr::subsystemName()); subsystem_mgr->remove(FGTileMgr::subsystemName());
osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer()); osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer());

View file

@ -139,15 +139,18 @@ FGAircraftModel::reinit()
void void
FGAircraftModel::shutdown() FGAircraftModel::shutdown()
{ {
if (!_aircraft.get()) { FGScenery* scenery = globals->get_scenery();
return;
if (_aircraft.get()) {
if (scenery && scenery->get_aircraft_branch()) {
scenery->get_aircraft_branch()->removeChild(_aircraft->getSceneGraph());
}
} }
osg::Node* node = _aircraft->getSceneGraph();
globals->get_scenery()->get_aircraft_branch()->removeChild(node);
if (_interior.get()) { if (_interior.get()) {
globals->get_scenery()->get_interior_branch()->removeChild(_interior->getSceneGraph()); if (scenery && scenery->get_interior_branch()) {
scenery->get_interior_branch()->removeChild(_interior->getSceneGraph());
}
} }
_aircraft.reset(); _aircraft.reset();

View file

@ -34,6 +34,7 @@ public:
virtual SGModelPlacement * get3DModel() { return _aircraft.get(); } virtual SGModelPlacement * get3DModel() { return _aircraft.get(); }
virtual SGVec3d& getVelocity() { return _velocity; } virtual SGVec3d& getVelocity() { return _velocity; }
static const char* subsystemName() { return "aircraft-model"; }
private: private:
void deinit (); void deinit ();