Aircraft-model subsystem behaves better
- make shutdown logic more robust - shutdown is no longer special cased in globals.
This commit is contained in:
parent
89065ea5c2
commit
0f590280c7
4 changed files with 13 additions and 11 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -139,15 +139,18 @@ FGAircraftModel::reinit()
|
|||
void
|
||||
FGAircraftModel::shutdown()
|
||||
{
|
||||
if (!_aircraft.get()) {
|
||||
return;
|
||||
FGScenery* scenery = globals->get_scenery();
|
||||
|
||||
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()) {
|
||||
globals->get_scenery()->get_interior_branch()->removeChild(_interior->getSceneGraph());
|
||||
if (scenery && scenery->get_interior_branch()) {
|
||||
scenery->get_interior_branch()->removeChild(_interior->getSceneGraph());
|
||||
}
|
||||
}
|
||||
|
||||
_aircraft.reset();
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
Loading…
Reference in a new issue