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("aircraft-model", new FGAircraftModel, SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGAircraftModel>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGModelMgr>(SGSubsystemMgr::DISPLAY);
globals->add_new_subsystem<FGViewMgr>(SGSubsystemMgr::DISPLAY);

View file

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

View file

@ -139,17 +139,20 @@ FGAircraftModel::reinit()
void
FGAircraftModel::shutdown()
{
if (!_aircraft.get()) {
return;
}
osg::Node* node = _aircraft->getSceneGraph();
globals->get_scenery()->get_aircraft_branch()->removeChild(node);
FGScenery* scenery = globals->get_scenery();
if (_aircraft.get()) {
if (scenery && scenery->get_aircraft_branch()) {
scenery->get_aircraft_branch()->removeChild(_aircraft->getSceneGraph());
}
}
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();
_interior.reset();
}

View file

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