diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index cc0785c93..03e003c6c 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -168,6 +168,7 @@ FGCroppedTexture::getTexture () static fntRenderer text_renderer; static fntTexFont *default_font = 0; static fntTexFont *led_font = 0; +static sgVec4 panel_color; /** * Constructor. @@ -183,7 +184,8 @@ FGPanel::FGPanel () _jitter(fgGetNode("/sim/panel/jitter", true)), _flipx(fgGetNode("/sim/panel/flip-x", true)), _xsize_node(fgGetNode("/sim/startup/xsize", true)), - _ysize_node(fgGetNode("/sim/startup/ysize", true)) + _ysize_node(fgGetNode("/sim/startup/ysize", true)), + _enable_depth_test(false) { } @@ -382,8 +384,10 @@ FGPanel::draw() glEnable(GL_COLOR_MATERIAL); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); - glDisable(GL_DEPTH_TEST); - sgVec4 panel_color; + if( _enable_depth_test ) + glDepthFunc(GL_ALWAYS); + else + glDisable(GL_DEPTH_TEST); FGLight *l = (FGLight *)(globals->get_subsystem("lighting")); sgCopyVec4( panel_color, l->scene_diffuse()); @@ -451,6 +455,8 @@ FGPanel::draw() // restore some original state + if( _enable_depth_test ) + glDepthFunc(GL_LESS); glPopAttrib(); glPolygonOffset(0, 0); glDisable(GL_POLYGON_OFFSET_FILL); @@ -584,6 +590,10 @@ FGPanel::doMouseAction (int button, int updown, int x, int y) return doLocalMouseAction(button, updown, x, y); } +void FGPanel::setDepthTest (bool enable) { + _enable_depth_test = enable; +} + ////////////////////////////////////////////////////////////////////////. @@ -947,15 +957,6 @@ FGTexturedLayer::draw () // From Curt: turn on the panel // lights after sundown. - sgVec4 panel_color; - - FGLight *l = (FGLight *)(globals->get_subsystem("lighting")); - sgCopyVec4( panel_color, l->scene_diffuse()); - if ( fgGetDouble("/systems/electrical/outputs/instrument-lights") > 1.0 ) { - if ( panel_color[0] < 0.7 ) panel_color[0] = 0.7; - if ( panel_color[1] < 0.2 ) panel_color[1] = 0.2; - if ( panel_color[2] < 0.2 ) panel_color[2] = 0.2; - } glColor4fv( panel_color ); glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2); diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 7cfdf0e2e..46db96d30 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -183,6 +183,8 @@ public: virtual bool doMouseAction (int button, int updown, int x, int y); virtual bool doLocalMouseAction(int button, int updown, int x, int y); + virtual void setDepthTest (bool enable); + private: void setupVirtualCockpit(); void cleanupVirtualCockpit(); @@ -209,6 +211,7 @@ private: ssgTexture * _mbg[8]; // List of instruments in panel. instrument_list_type _instruments; + bool _enable_depth_test; }; diff --git a/src/Environment/fgclouds.cxx b/src/Environment/fgclouds.cxx index 044fb885f..9821a92b6 100644 --- a/src/Environment/fgclouds.cxx +++ b/src/Environment/fgclouds.cxx @@ -44,10 +44,13 @@ extern SGSky *thesky; FGClouds::FGClouds(FGEnvironmentCtrl * controller) : station_elevation_ft(0.0), _controller( controller ), - snd_lightning(NULL) + snd_lightning(NULL), + last_scenario( "none" ), + last_env_config( new SGPropertyNode() ), + last_env_clouds( new SGPropertyNode() ) { update_event = 0; - fgSetString("/environment/weather-scenario", "METAR"); + fgSetString("/environment/weather-scenario", last_scenario.c_str()); } FGClouds::~FGClouds() { } @@ -433,6 +436,15 @@ void FGClouds::buildScenario( string scenario ) { void FGClouds::build(void) { string scenario = fgGetString("/environment/weather-scenario", "METAR"); + if( scenario == last_scenario) + return; + if( last_scenario == "none" ) { + // save clouds and weather conditions + SGPropertyNode *param = fgGetNode("/environment/config", true); + copyProperties( param, last_env_config ); + param = fgGetNode("/environment/clouds", true); + copyProperties( param, last_env_clouds ); + } if( scenario == "METAR" ) { string realMetar = fgGetString("/environment/metar/real-metar", ""); if( realMetar != "" ) { @@ -445,8 +457,22 @@ void FGClouds::build(void) { } buildMETAR(); } + else if( scenario == "none" ) { + // restore clouds and weather conditions + SGPropertyNode *param = fgGetNode("/environment/config", true); + copyProperties( last_env_config, param ); + param = fgGetNode("/environment/clouds", true); + copyProperties( last_env_clouds, param ); + fgSetDouble("/environment/metar/rain-norm", 0.0); + fgSetDouble("/environment/metar/snow-norm", 0.0); +// update_env_config(); + // propagate aloft tables + _controller->reinit(); + buildMETAR(); + } else buildScenario( scenario ); + last_scenario = scenario; // ... if( snd_lightning == NULL ) diff --git a/src/Environment/fgclouds.hxx b/src/Environment/fgclouds.hxx index 2dff64427..c078d0f01 100644 --- a/src/Environment/fgclouds.hxx +++ b/src/Environment/fgclouds.hxx @@ -59,6 +59,8 @@ private: SGSoundSample *snd_lightning; FGEnvironmentCtrl * _controller; float station_elevation_ft; + string last_scenario; + SGPropertyNode *last_env_config, *last_env_clouds; public: FGClouds(FGEnvironmentCtrl * controller); diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 1960cad28..603473124 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -71,7 +71,7 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : last_x(0.0), name("nav"), num(0), - _time_before_search_sec(0.0) + _time_before_search_sec(-1.0) { SGPath path( globals->get_fg_root() ); SGPath term = path; diff --git a/src/Model/panelnode.cxx b/src/Model/panelnode.cxx index 55973b003..bf553e203 100644 --- a/src/Model/panelnode.cxx +++ b/src/Model/panelnode.cxx @@ -47,6 +47,8 @@ FGPanelNode::FGPanelNode(SGPropertyNode* props) // panels). This is a memory leak and should be fixed!` _panel->init(); + _panel->setDepthTest( props->getBoolValue("depth-test") ); + // Initialize the matrices to the identity. PLib prints warnings // when trying to invert singular matrices (e.g. when not using a // 3D panel). diff --git a/src/Replay/replay.cxx b/src/Replay/replay.cxx index b9475c6ec..b53ffce02 100644 --- a/src/Replay/replay.cxx +++ b/src/Replay/replay.cxx @@ -105,8 +105,13 @@ void FGReplay::update( double dt ) { static SGPropertyNode *replay_master = fgGetNode( "/sim/freeze/replay", true ); - if( disable_replay->getBoolValue() ) + if( disable_replay->getBoolValue() ) { + if( sim_time != 0.0 ) { + // we were recording data + init(); + } return; + } if ( replay_master->getBoolValue() ) { // don't record the replay session diff --git a/src/Systems/electrical.cxx b/src/Systems/electrical.cxx index 73682045e..9c17a7c1b 100644 --- a/src/Systems/electrical.cxx +++ b/src/Systems/electrical.cxx @@ -110,6 +110,7 @@ float FGElectricalSupplier::apply_load( float amps, float dt ) { return available_amps - amps; } else if ( model == FG_EXTERNAL ) { // cout << "external amps = " << 0.0 << endl; + float available_amps = ideal_amps; return available_amps - amps; } else { SG_LOG( SG_ALL, SG_ALERT, "unknown supplier type" );