1
0
Fork 0

Harald JOHNSEN:

- 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
This commit is contained in:
ehofman 2005-08-22 17:49:50 +00:00
parent 99276dd060
commit a760dcdf13
8 changed files with 56 additions and 16 deletions

View file

@ -168,6 +168,7 @@ FGCroppedTexture::getTexture ()
static fntRenderer text_renderer; static fntRenderer text_renderer;
static fntTexFont *default_font = 0; static fntTexFont *default_font = 0;
static fntTexFont *led_font = 0; static fntTexFont *led_font = 0;
static sgVec4 panel_color;
/** /**
* Constructor. * Constructor.
@ -183,7 +184,8 @@ FGPanel::FGPanel ()
_jitter(fgGetNode("/sim/panel/jitter", true)), _jitter(fgGetNode("/sim/panel/jitter", true)),
_flipx(fgGetNode("/sim/panel/flip-x", true)), _flipx(fgGetNode("/sim/panel/flip-x", true)),
_xsize_node(fgGetNode("/sim/startup/xsize", 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_COLOR_MATERIAL);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
glDisable(GL_DEPTH_TEST); if( _enable_depth_test )
sgVec4 panel_color; glDepthFunc(GL_ALWAYS);
else
glDisable(GL_DEPTH_TEST);
FGLight *l = (FGLight *)(globals->get_subsystem("lighting")); FGLight *l = (FGLight *)(globals->get_subsystem("lighting"));
sgCopyVec4( panel_color, l->scene_diffuse()); sgCopyVec4( panel_color, l->scene_diffuse());
@ -451,6 +455,8 @@ FGPanel::draw()
// restore some original state // restore some original state
if( _enable_depth_test )
glDepthFunc(GL_LESS);
glPopAttrib(); glPopAttrib();
glPolygonOffset(0, 0); glPolygonOffset(0, 0);
glDisable(GL_POLYGON_OFFSET_FILL); 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); 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 // From Curt: turn on the panel
// lights after sundown. // 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 ); glColor4fv( panel_color );
glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2); glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2);

View file

@ -183,6 +183,8 @@ public:
virtual bool doMouseAction (int button, int updown, int x, int y); virtual bool doMouseAction (int button, int updown, int x, int y);
virtual bool doLocalMouseAction(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: private:
void setupVirtualCockpit(); void setupVirtualCockpit();
void cleanupVirtualCockpit(); void cleanupVirtualCockpit();
@ -209,6 +211,7 @@ private:
ssgTexture * _mbg[8]; ssgTexture * _mbg[8];
// List of instruments in panel. // List of instruments in panel.
instrument_list_type _instruments; instrument_list_type _instruments;
bool _enable_depth_test;
}; };

View file

@ -44,10 +44,13 @@ extern SGSky *thesky;
FGClouds::FGClouds(FGEnvironmentCtrl * controller) : FGClouds::FGClouds(FGEnvironmentCtrl * controller) :
station_elevation_ft(0.0), station_elevation_ft(0.0),
_controller( controller ), _controller( controller ),
snd_lightning(NULL) snd_lightning(NULL),
last_scenario( "none" ),
last_env_config( new SGPropertyNode() ),
last_env_clouds( new SGPropertyNode() )
{ {
update_event = 0; update_event = 0;
fgSetString("/environment/weather-scenario", "METAR"); fgSetString("/environment/weather-scenario", last_scenario.c_str());
} }
FGClouds::~FGClouds() { FGClouds::~FGClouds() {
} }
@ -433,6 +436,15 @@ void FGClouds::buildScenario( string scenario ) {
void FGClouds::build(void) { void FGClouds::build(void) {
string scenario = fgGetString("/environment/weather-scenario", "METAR"); 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" ) { if( scenario == "METAR" ) {
string realMetar = fgGetString("/environment/metar/real-metar", ""); string realMetar = fgGetString("/environment/metar/real-metar", "");
if( realMetar != "" ) { if( realMetar != "" ) {
@ -445,8 +457,22 @@ void FGClouds::build(void) {
} }
buildMETAR(); 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 else
buildScenario( scenario ); buildScenario( scenario );
last_scenario = scenario;
// ... // ...
if( snd_lightning == NULL ) if( snd_lightning == NULL )

View file

@ -59,6 +59,8 @@ private:
SGSoundSample *snd_lightning; SGSoundSample *snd_lightning;
FGEnvironmentCtrl * _controller; FGEnvironmentCtrl * _controller;
float station_elevation_ft; float station_elevation_ft;
string last_scenario;
SGPropertyNode *last_env_config, *last_env_clouds;
public: public:
FGClouds(FGEnvironmentCtrl * controller); FGClouds(FGEnvironmentCtrl * controller);

View file

@ -71,7 +71,7 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) :
last_x(0.0), last_x(0.0),
name("nav"), name("nav"),
num(0), num(0),
_time_before_search_sec(0.0) _time_before_search_sec(-1.0)
{ {
SGPath path( globals->get_fg_root() ); SGPath path( globals->get_fg_root() );
SGPath term = path; SGPath term = path;

View file

@ -47,6 +47,8 @@ FGPanelNode::FGPanelNode(SGPropertyNode* props)
// panels). This is a memory leak and should be fixed!` // panels). This is a memory leak and should be fixed!`
_panel->init(); _panel->init();
_panel->setDepthTest( props->getBoolValue("depth-test") );
// Initialize the matrices to the identity. PLib prints warnings // Initialize the matrices to the identity. PLib prints warnings
// when trying to invert singular matrices (e.g. when not using a // when trying to invert singular matrices (e.g. when not using a
// 3D panel). // 3D panel).

View file

@ -105,8 +105,13 @@ void FGReplay::update( double dt ) {
static SGPropertyNode *replay_master static SGPropertyNode *replay_master
= fgGetNode( "/sim/freeze/replay", true ); = fgGetNode( "/sim/freeze/replay", true );
if( disable_replay->getBoolValue() ) if( disable_replay->getBoolValue() ) {
if( sim_time != 0.0 ) {
// we were recording data
init();
}
return; return;
}
if ( replay_master->getBoolValue() ) { if ( replay_master->getBoolValue() ) {
// don't record the replay session // don't record the replay session

View file

@ -110,6 +110,7 @@ float FGElectricalSupplier::apply_load( float amps, float dt ) {
return available_amps - amps; return available_amps - amps;
} else if ( model == FG_EXTERNAL ) { } else if ( model == FG_EXTERNAL ) {
// cout << "external amps = " << 0.0 << endl; // cout << "external amps = " << 0.0 << endl;
float available_amps = ideal_amps;
return available_amps - amps; return available_amps - amps;
} else { } else {
SG_LOG( SG_ALL, SG_ALERT, "unknown supplier type" ); SG_LOG( SG_ALL, SG_ALERT, "unknown supplier type" );