]> git.mxchange.org Git - flightgear.git/commitdiff
Harald JOHNSEN:
authorehofman <ehofman>
Mon, 22 Aug 2005 17:49:50 +0000 (17:49 +0000)
committerehofman <ehofman>
Mon, 22 Aug 2005 17:49:50 +0000 (17:49 +0000)
- replay.cxx :
  corrected a bug, now reinitialize the recording data when replay is
  deactivated

- fgclouds.cxx :
  cloud layers and weather condition are saved when choosing a weather scenario,
  added a new scenario 'none' so we can switch back to standard flightgear
  weather

- navradio.cxx :
  force a search() on init to initialize some variables, preventing a nearly
  infinite loop  when delta-time == 0 on the first update()

- electrical.cxx :
  uninitialized variable in apply_load() for FG_EXTERNAL supplier

- panel.cxx, panelnode.cxx :
  added a property "depth-test" for 2.5D panels so that they update the depth
  buffer and are no more visible from the outside of the aircraft when the
  aircraft uses textures without an alpha channel

- panel.cxx :
  moved the computation of the instruments diffuse color outside the
  texturelayer code since this is constant during a frame, this is a big speedup
  for 2D panels

src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Environment/fgclouds.cxx
src/Environment/fgclouds.hxx
src/Instrumentation/navradio.cxx
src/Model/panelnode.cxx
src/Replay/replay.cxx
src/Systems/electrical.cxx

index cc0785c9347d72f8944922b8a6832d296bf01026..03e003c6c218d34375b8975f6c16e3919240849c 100644 (file)
@@ -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;
+}
+
 
 \f
 ////////////////////////////////////////////////////////////////////////.
@@ -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);
index 7cfdf0e2eb72fe6f49566e6a6bfb15ece1de5c54..46db96d3080be438399ef13e6263272ff8ba6308 100644 (file)
@@ -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;
 };
 
 
index 044fb885f50536e85c978441b4ed5ea991ca463e..9821a92b64e9d8e0d9be959bed5340e36dd1ba99 100644 (file)
@@ -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 )
index 2dff644271c0cca62269b6d3fc4158a6dc9a54dc..c078d0f01113ebe546de029e991b6b98b5cdffd3 100644 (file)
@@ -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);
index 1960cad28d0a26e38c756f5447e68687b4006a8e..60347312467e224391e119953dcb9f65575ea379 100644 (file)
@@ -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;
index 55973b0035ec670cc3220f4a8c5649522abb9173..bf553e2033b2231571cf1f0f1bc04175c38f28cb 100644 (file)
@@ -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).
index b9475c6ec87d80469be673b4daa40195049b6196..b53ffce021ab29a06c9638f9521261c5bf5a2c25 100644 (file)
@@ -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
index 73682045e64069fecfb5b3ea12cc5456c419ec46..9c17a7c1b8dc62838a32af2811f6c529b1dda6a1 100644 (file)
@@ -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" );