diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx
index fac7dc628..d5411b8af 100644
--- a/src/Autopilot/route_mgr.cxx
+++ b/src/Autopilot/route_mgr.cxx
@@ -237,7 +237,7 @@ void FGRouteMgr::postinit()
SG_LOG(SG_AUTOPILOT, SG_INFO, "loaded initial waypoints:" << _route.size());
}
- weightOnWheels = fgGetNode("/gear/gear[0]/wow", false);
+ weightOnWheels = fgGetNode("/gear/gear[0]/wow", true);
// check airbone flag agrees with presets
}
diff --git a/src/Cockpit/hud_rwy.cxx b/src/Cockpit/hud_rwy.cxx
index e884c7cfb..222975fdb 100644
--- a/src/Cockpit/hud_rwy.cxx
+++ b/src/Cockpit/hud_rwy.cxx
@@ -97,11 +97,6 @@ void runway_instr::draw()
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
- //Assuming that the "Cockpit View" is always at position zero!!!
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(0);
- globals->get_viewmgr()->copyToCurrent();
- }
//Set the camera to the cockpit view to get the view of the runway from the cockpit
// OSGFIXME
// ssgSetCamera((sgVec4 *)cockpit_view->get_VIEW());
@@ -156,15 +151,6 @@ void runway_instr::draw()
drawArrow(); //draw indication arrow
}
- //Restore the current view and any offsets
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(curr_view_id);
- globals->get_viewmgr()->copyToCurrent();
- curr_view->setHeadingOffset_deg(ho);
- curr_view->setPitchOffset_deg(po);
- curr_view->setGoalHeadingOffset_deg(gho);
- curr_view->setGoalPitchOffset_deg(gpo);
- }
//Set the camera back to the current view
// OSGFIXME
// ssgSetCamera((sgVec4 *)curr_view);
diff --git a/src/Instrumentation/HUD/HUD_runway.cxx b/src/Instrumentation/HUD/HUD_runway.cxx
index a31d0ff60..fcf4f1127 100644
--- a/src/Instrumentation/HUD/HUD_runway.cxx
+++ b/src/Instrumentation/HUD/HUD_runway.cxx
@@ -93,11 +93,6 @@ void HUD::Runway::draw()
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
- //Assuming that the "Cockpit View" is always at position zero!!!
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(0);
- globals->get_viewmgr()->copyToCurrent();
- }
//Set the camera to the cockpit view to get the view of the runway from the cockpit
// OSGFIXME
// ssgSetCamera((sgVec4 *)_cockpit_view->get_VIEW());
@@ -152,15 +147,6 @@ void HUD::Runway::draw()
drawArrow(); //draw indication arrow
}
- //Restore the current view and any offsets
- if (curr_view_id != 0) {
- globals->get_viewmgr()->set_view(curr_view_id);
- globals->get_viewmgr()->copyToCurrent();
- curr_view->setHeadingOffset_deg(ho);
- curr_view->setPitchOffset_deg(po);
- curr_view->setGoalHeadingOffset_deg(gho);
- curr_view->setGoalPitchOffset_deg(gpo);
- }
//Set the camera back to the current view
// OSGFIXME
// ssgSetCamera((sgVec4 *)curr_view);
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index fa2cc45a5..f154ab658 100644
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -93,6 +93,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -1309,9 +1310,6 @@ bool fgInitSubsystems() {
// Initialize the scenery management subsystem.
////////////////////////////////////////////////////////////////////
- globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
- SGSubsystemMgr::DISPLAY);
-
globals->get_scenery()->get_scene_graph()
->addChild(simgear::Particles::getCommonRoot());
simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
@@ -1361,23 +1359,12 @@ bool fgInitSubsystems() {
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
- ////////////////////////////////////////////////////////////////////
- // Initialize the lighting subsystem.
- ////////////////////////////////////////////////////////////////////
-
- globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
-
//////////////////////////////////////////////////////////////////////
// Initialize the 2D cloud subsystem.
////////////////////////////////////////////////////////////////////
fgGetBool("/sim/rendering/bump-mapping", false);
-#ifdef ENABLE_AUDIO_SUPPORT
- ////////////////////////////////////////////////////////////////////
- // Initialize the sound-effects subsystem.
- ////////////////////////////////////////////////////////////////////
- globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
-#endif
+
////////////////////////////////////////////////////////////////////
// Initialise the ATC Manager
@@ -1461,7 +1448,37 @@ bool fgInitSubsystems() {
////////////////////////////////////////////////////////////////////
globals->add_subsystem("replay", new FGReplay);
+#ifdef ENABLE_AUDIO_SUPPORT
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the sound-effects subsystem.
+ ////////////////////////////////////////////////////////////////////
+ globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
+#endif
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the lighting subsystem.
+ ////////////////////////////////////////////////////////////////////
+
+ globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
+
+ // ordering here is important : Nasal (via events), then models, then views
+ globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
+
+ FGAircraftModel* acm = new FGAircraftModel;
+ globals->set_aircraft_model(acm);
+ globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
+
+ FGModelMgr* mm = new FGModelMgr;
+ globals->set_model_mgr(mm);
+ globals->add_subsystem("model-manager", mm, SGSubsystemMgr::DISPLAY);
+
+ FGViewMgr *viewmgr = new FGViewMgr;
+ globals->set_viewmgr( viewmgr );
+ globals->add_subsystem("view-manager", viewmgr, SGSubsystemMgr::DISPLAY);
+
+ globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
+ SGSubsystemMgr::DISPLAY);
+
////////////////////////////////////////////////////////////////////
// Bind and initialize subsystems.
////////////////////////////////////////////////////////////////////
diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx
index 7fafd0516..ee5fcf2fd 100644
--- a/src/Main/globals.cxx
+++ b/src/Main/globals.cxx
@@ -170,7 +170,6 @@ FGGlobals::~FGGlobals()
subsystem_mgr->unbind();
delete subsystem_mgr;
- delete event_mgr;
delete time_params;
delete mag;
@@ -180,10 +179,7 @@ FGGlobals::~FGGlobals()
delete ATC_mgr;
delete controls;
- delete viewmgr;
-// delete commands;
- delete model_mgr;
delete channel_options_list;
delete initial_waypoints;
delete scenery;
diff --git a/src/Main/main.cxx b/src/Main/main.cxx
index 1cfe91ba2..8849644b3 100644
--- a/src/Main/main.cxx
+++ b/src/Main/main.cxx
@@ -54,7 +54,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -149,16 +148,6 @@ static void fgMainLoop( void ) {
globals->get_subsystem_mgr()->update(sim_dt);
- // run Nasal's settimer() loops right before the view manager
- globals->get_event_mgr()->update(sim_dt);
-
- // pick up model coordidnates that Nasal code may have set relative to the
- // aircraft's
- globals->get_model_mgr()->update(sim_dt);
-
- // update the view angle as late as possible, but before sound calculations
- globals->get_viewmgr()->update(real_dt);
-
// Update the sound manager last so it can use the CPU while the GPU
// is processing the scenery (doubled the frame-rate for me) -EMH-
#ifdef ENABLE_AUDIO_SUPPORT
@@ -375,33 +364,12 @@ static void fgIdleFunction ( void ) {
globals->set_tile_mgr( new FGTileMgr );
- ////////////////////////////////////////////////////////////////////
- // Initialize the general model subsystem.
- ////////////////////////////////////////////////////////////////////
- globals->set_model_mgr(new FGModelMgr);
- globals->get_model_mgr()->init();
- globals->get_model_mgr()->bind();
fgSplashProgress("loading aircraft");
} else if ( idle_state == 5 ) {
idle_state++;
- ////////////////////////////////////////////////////////////////////
- // Initialize the 3D aircraft model subsystem (has a dependency on
- // the scenery subsystem.)
- ////////////////////////////////////////////////////////////////////
- FGAircraftModel* acm = new FGAircraftModel;
- globals->set_aircraft_model(acm);
- globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
-
- ////////////////////////////////////////////////////////////////////
- // Initialize the view manager subsystem.
- ////////////////////////////////////////////////////////////////////
- FGViewMgr *viewmgr = new FGViewMgr;
- globals->set_viewmgr( viewmgr );
- viewmgr->init();
- viewmgr->bind();
fgSplashProgress("generating sky elements");
diff --git a/src/Main/viewmgr.cxx b/src/Main/viewmgr.cxx
index 6859c8f41..5a978be63 100644
--- a/src/Main/viewmgr.cxx
+++ b/src/Main/viewmgr.cxx
@@ -39,6 +39,7 @@
FGViewMgr::FGViewMgr( void ) :
axis_long(0),
axis_lat(0),
+ inited(false),
view_number(fgGetNode("/sim/current-view/view-number", true)),
config_list(fgGetNode("/sim", true)->getChildren("view")),
current(0)
@@ -53,6 +54,13 @@ FGViewMgr::~FGViewMgr( void ) {
void
FGViewMgr::init ()
{
+ if (inited) {
+ SG_LOG(SG_GENERAL, SG_WARN, "duplicate init of view manager");
+ return;
+ }
+
+ inited = true;
+
double aspect_ratio_multiplier
= fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
@@ -118,6 +126,7 @@ FGViewMgr::init ()
}
copyToCurrent();
+ do_bind();
}
void
@@ -160,7 +169,14 @@ FGViewMgr::reinit ()
typedef double (FGViewMgr::*double_getter)() const;
void
-FGViewMgr::bind ()
+FGViewMgr::bind()
+{
+ // view-manager code was designed to init before bind, so
+ // this is a no-op; init() calls the real bind() impl below
+}
+
+void
+FGViewMgr::do_bind()
{
// these are bound to the current view properties
fgTie("/sim/current-view/heading-offset-deg", this,
@@ -352,6 +368,10 @@ FGViewMgr::update (double dt)
void
FGViewMgr::copyToCurrent()
{
+ if (!inited) {
+ return;
+ }
+
SGPropertyNode *n = config_list[current];
fgSetString("/sim/current-view/name", n->getStringValue("name"));
fgSetString("/sim/current-view/type", n->getStringValue("type"));
@@ -719,15 +739,9 @@ FGViewMgr::setView (int newview)
newview = 0;
// set new view
- set_view(newview);
+ current = newview;
// copy in view data
copyToCurrent();
-
- // Copy the fdm's position into the SGLocation which is shared with
- // some views ...
- globals->get_aircraft_model()->update(0);
- // Do the update ...
- update(0);
}
@@ -755,7 +769,7 @@ FGViewMgr::getARM_deg () const
void
FGViewMgr::setARM_deg (double aspect_ratio_multiplier)
-{
+{
FGViewer * view = get_current_view();
if (view != 0)
view->set_aspect_ratio_multiplier(aspect_ratio_multiplier);
diff --git a/src/Main/viewmgr.hxx b/src/Main/viewmgr.hxx
index c296b7155..c14347e26 100644
--- a/src/Main/viewmgr.hxx
+++ b/src/Main/viewmgr.hxx
@@ -69,14 +69,12 @@ public:
// setters
void clear();
- inline void set_view( const int v ) { current = v; }
+
void add_view( FGViewer * v );
- // copies current offset settings to current-view path...
- void copyToCurrent ();
-
private:
-
+ void do_bind();
+
list tied_props;
double axis_long;
@@ -136,6 +134,10 @@ private:
bool stationary () const;
+ // copies current offset settings to current-view path...
+ void copyToCurrent ();
+
+ bool inited;
SGPropertyNode_ptr view_number;
vector config_list;
typedef std::vector viewer_list;