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);
subsystem_mgr->shutdown();
subsystem_mgr->unbind();
- subsystem_mgr->remove("aircraft-model");
-
subsystem_mgr->remove(FGTileMgr::subsystemName());
osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer());
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();
}
virtual SGModelPlacement * get3DModel() { return _aircraft.get(); }
virtual SGVec3d& getVelocity() { return _velocity; }
+ static const char* subsystemName() { return "aircraft-model"; }
private:
void deinit ();