1
0
Fork 0

Restructured the 'freeze' property a bit. We now have

/sim/freeze/master      (implimented)
  /sim/freeze/fuel        (implimented)
  /sim/freeze/position    (not implimented)
  /sim/freeze/time-of-day (not implimented)

/sim/freeze/master is bound to the 'p' key via keyboard.xml, however,
/sim/freeze/fuel is not bound to anything at the moment so you must
change it via the external property interface, or specify an initial
value on the command line.
This commit is contained in:
curt 2002-01-20 03:52:36 +00:00
parent 4e0ab72766
commit dea7284cc7
16 changed files with 227 additions and 135 deletions

View file

@ -125,7 +125,7 @@ FGJSBsim::FGJSBsim( double dt )
init_gear();
// Set initial fuel levels if provided.
for (int i = 0; i < Propulsion->GetNumTanks(); i++) {
for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
if (node->getChild("level-gal_us", 0, false) != 0)
Propulsion->GetTank(i)
@ -240,7 +240,7 @@ FGJSBsim::update( int multiloop ) {
int i;
double save_alt = 0.0;
// double save_alt = 0.0;
copy_to_JSBsim();
@ -291,7 +291,7 @@ FGJSBsim::update( int multiloop ) {
// Convert from the FGInterface struct to the JSBsim generic_ struct
bool FGJSBsim::copy_to_JSBsim() {
int i;
unsigned int i;
// copy control positions into the JSBsim structure
@ -463,12 +463,19 @@ bool FGJSBsim::copy_from_JSBsim() {
node->setBoolValue("cranking", eng->GetCranking());
}
// Copy the fuel levels from JSBSim.
for (i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
double contents = Propulsion->GetTank(i)->GetContents();
node->setDoubleValue("level-gal_us", contents/6.6);
// node->setDoubleValue("level-lb", contents);
static const SGPropertyNode *fuel_freeze
= fgGetNode("/sim/freeze/fuel");
// Copy the fuel levels from JSBSim if fuel
// freeze not enabled.
if ( ! fuel_freeze->getBoolValue() ) {
for (i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node
= fgGetNode("/consumables/fuel/tank", i, true);
double contents = Propulsion->GetTank(i)->GetContents();
node->setDoubleValue("level-gal_us", contents/6.6);
// node->setDoubleValue("level-lb", contents);
}
}
update_gear();

View file

@ -119,15 +119,20 @@ void FGLaRCsim::update( int multiloop ) {
fgSetDouble("/engines/engine/running", eng.getRunningFlag());
fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
//Assume we are using both tanks equally for now
fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
fgGetDouble("/consumables/fuel/tank[0]")
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
* get_delta_t());
fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
fgGetDouble("/consumables/fuel/tank[1]")
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
* get_delta_t());
static const SGPropertyNode *fuel_freeze
= fgGetNode("/sim/freeze/fuel");
if ( ! fuel_freeze->getBoolValue() ) {
//Assume we are using both tanks equally for now
fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
fgGetDouble("/consumables/fuel/tank[0]")
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
* get_delta_t());
fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
fgGetDouble("/consumables/fuel/tank[1]")
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
* get_delta_t());
}
F_X_engine = eng.get_prop_thrust_lbs();
// cout << "F_X_engine = " << F_X_engine << '\n';

View file

@ -55,6 +55,8 @@ void AptDialog_OK (puObject *)
= fgGetNode("/position/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/position/latitude-deg");
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
SGPath path( globals->get_fg_root() );
path.append( "Airports" );
@ -63,9 +65,10 @@ void AptDialog_OK (puObject *)
FGAirport a;
int freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
char *s;
AptDialogInput->getValue(&s);
@ -97,15 +100,8 @@ void AptDialog_OK (puObject *)
SGD_RADIANS_TO_DEGREES);
// BusyCursor(0);
fgReInitSubsystems();
// if ( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update( longitude->getDoubleValue(),
latitude->getDoubleValue() );
// } else {
// SG_LOG( SG_GENERAL, SG_ALERT,
// "Error in Tile Manager initialization!" );
// exit(-1);
// }
// BusyCursor(1);
} else {
AptId += " not in database.";
@ -113,7 +109,7 @@ void AptDialog_OK (puObject *)
}
}
if ( !freeze ) {
globals->set_freeze( false );
fgSetBool("/sim/freeze/master", false);
}
}

View file

@ -493,9 +493,13 @@ void fgHiResDump()
char *filename = new char [24];
static int count = 1;
int freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
if(gui_menu_on) {
show_menu = true;
@ -668,8 +672,9 @@ void fgHiResDump()
puShowCursor();
}
if(!freeze)
globals->set_freeze( false );
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
}
#endif // #if defined( TR_HIRES_SNAP)
@ -760,9 +765,13 @@ void fgDumpSnapShot () {
string message;
static int count = 1;
int freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
mainMenuBar->hide();
TurnCursorOff();
@ -812,8 +821,9 @@ void fgDumpSnapShot () {
mainMenuBar->reveal();
}
if(!freeze)
globals->set_freeze( false );
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
}
#ifdef FG_NETWORK_OLK

View file

@ -54,9 +54,13 @@ void reInit(puObject *cb)
// BusyCursor(0);
Quat0();
int freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
cur_fdm_state->unbind();
@ -89,7 +93,7 @@ void reInit(puObject *cb)
// BusyCursor(1);
if ( !freeze ) {
globals->set_freeze( false );
fgSetBool("/sim/freeze/master", false);
}
}

View file

@ -67,27 +67,33 @@ void NetIdDialog_Cancel(puObject *)
void NetIdDialog_OK (puObject *)
{
string NetId;
string NetId;
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
bool freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
/*
The following needs some cleanup because
"string options.NetId" and "char *net_callsign"
*/
NetIdDialogInput->getValue(&net_callsign);
NetId = net_callsign;
NetIdDialogInput->getValue(&net_callsign);
NetId = net_callsign;
NetIdDialog_Cancel( NULL );
fgSetString("/networking/call-sign", NetId.c_str() );
strcpy( fgd_callsign, net_callsign);
NetIdDialog_Cancel( NULL );
fgSetString("/networking/call-sign", NetId.c_str() );
strcpy( fgd_callsign, net_callsign);
// strcpy( fgd_callsign, fgGetString("/sim/networking/call-sign").c_str());
/* Entering a callsign indicates : user wants Net HUD Info */
net_hud_display = 1;
net_hud_display = 1;
if(!freeze)
globals->set_freeze( false );
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
}
void NewCallSign(puObject *cb)
@ -164,57 +170,72 @@ void NetFGDDialog_Cancel(puObject *)
void NetFGDDialog_OK (puObject *)
{
char *NetFGD;
char *NetFGD;
bool freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
NetFGDHostDialogInput->getValue( &NetFGD );
strcpy( fgd_host, NetFGD);
NetFGDPortLoDialogInput->getValue( (int *) &base_port );
NetFGDPortHiDialogInput->getValue( (int *) &end_port );
NetFGDDialog_Cancel( NULL );
if(!freeze)
globals->set_freeze( false );
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
NetFGDHostDialogInput->getValue( &NetFGD );
strcpy( fgd_host, NetFGD);
NetFGDPortLoDialogInput->getValue( (int *) &base_port );
NetFGDPortHiDialogInput->getValue( (int *) &end_port );
NetFGDDialog_Cancel( NULL );
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
}
void NetFGDDialog_SCAN (puObject *)
{
char *NetFGD;
int fgd_port;
char *NetFGD;
int fgd_port;
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
bool freeze = globals->get_freeze();
if(!freeze)
globals->set_freeze( true );
// printf("Vor getvalue %s\n");
NetFGDHostDialogInput->getValue( &NetFGD );
NetFGDHostDialogInput->getValue( &NetFGD );
// printf("Vor strcpy %s\n", (char *) NetFGD);
strcpy( fgd_host, NetFGD);
NetFGDPortLoDialogInput->getValue( (int *) &base_port );
NetFGDPortHiDialogInput->getValue( (int *) &end_port );
printf("FGD: %s Port-Start: %d Port-End: %d\n", fgd_host,
base_port, end_port);
net_resolv_fgd(fgd_host);
printf("Resolve : %d\n", net_r);
if(!freeze)
globals->set_freeze( false );
if ( net_r == 0 ) {
fgd_port = 10000;
strcpy( fgd_name, "");
for( current_port = base_port; ( current_port <= end_port); current_port++) {
fgd_send_com("0" , FGFS_host);
sprintf( NewNetFGDLabel , "Scanning for deamon Port: %d", current_port);
printf("FGD: searching %s\n", fgd_name);
if ( strcmp( fgd_name, "") != 0 ) {
sprintf( NewNetFGDLabel , "Found %s at Port: %d",
fgd_name, current_port);
fgd_port = current_port;
current_port = end_port+1;
}
}
current_port = end_port = base_port = fgd_port;
strcpy( fgd_host, NetFGD);
NetFGDPortLoDialogInput->getValue( (int *) &base_port );
NetFGDPortHiDialogInput->getValue( (int *) &end_port );
printf("FGD: %s Port-Start: %d Port-End: %d\n", fgd_host,
base_port, end_port);
net_resolv_fgd(fgd_host);
printf("Resolve : %d\n", net_r);
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
if ( net_r == 0 ) {
fgd_port = 10000;
strcpy( fgd_name, "");
for( current_port = base_port; ( current_port <= end_port); current_port++) {
fgd_send_com("0" , FGFS_host);
sprintf( NewNetFGDLabel , "Scanning for deamon Port: %d", current_port);
printf("FGD: searching %s\n", fgd_name);
if ( strcmp( fgd_name, "") != 0 ) {
sprintf( NewNetFGDLabel , "Found %s at Port: %d",
fgd_name, current_port);
fgd_port = current_port;
current_port = end_port+1;
}
}
NetFGDDialog_Cancel( NULL );
current_port = end_port = base_port = fgd_port;
}
NetFGDDialog_Cancel( NULL );
}

View file

@ -267,24 +267,28 @@ do_screen_capture (const SGPropertyNode * arg, SGCommandState ** state)
static bool
do_tile_cache_reload (const SGPropertyNode * arg, SGCommandState ** state)
{
bool freeze = globals->get_freeze();
SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
if ( !freeze )
globals->set_freeze( true );
// BusyCursor(0);
if ( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
fgGetDouble("/position/latitude-deg"));
} else {
SG_LOG( SG_GENERAL, SG_ALERT,
"Error in Tile Manager initialization!" );
exit(-1);
}
// BusyCursor(1);
if ( !freeze )
globals->set_freeze( false );
return true;
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
// BusyCursor(0);
if ( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
fgGetDouble("/position/latitude-deg"));
} else {
SG_LOG( SG_GENERAL, SG_ALERT,
"Error in Tile Manager initialization!" );
exit(-1);
}
// BusyCursor(1);
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
return true;
}

View file

@ -916,13 +916,15 @@ void fgReInitSubsystems( void )
= fgGetNode("/position/latitude-deg");
static const SGPropertyNode *altitude
= fgGetNode("/position/altitude-ft");
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
SG_LOG( SG_GENERAL, SG_INFO,
"/position/altitude = " << altitude->getDoubleValue() );
bool freeze = globals->get_freeze();
if( !freeze ) {
globals->set_freeze( true );
bool freeze = master_freeze->getBoolValue();
if ( !freeze ) {
fgSetBool("/sim/freeze/master", true);
}
// Initialize the Scenery Management subsystem
@ -1002,6 +1004,7 @@ void fgReInitSubsystems( void )
cur_light_params.Update();
fgUpdateLocalTime();
if( !freeze )
globals->set_freeze( false );
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);
}
}

View file

@ -264,6 +264,7 @@ setLoggingPriority (string priority)
}
#if 0
/**
* Get the pause state of the sim.
*/
@ -290,6 +291,7 @@ setFreeze (bool freeze)
current_atcdisplay->CancelRepeatingMessage();
}
}
#endif
/**
* Return the current aircraft directory (UIUC) as a string.
@ -1088,7 +1090,7 @@ fgInitProps ()
// Simulation
fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
fgTie("/sim/freeze", getFreeze, setFreeze);
// fgTie("/sim/freeze", getFreeze, setFreeze);
fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
fgTie("/sim/view/offset-deg", getViewOffset, setViewOffset, false);
fgSetArchivable("/sim/view/offset-deg");

View file

@ -36,7 +36,6 @@ FGGlobals *globals;
// Constructor
FGGlobals::FGGlobals() :
freeze( false ),
#if defined(FX) && defined(XMESA)
fullscreen( true ),
#endif

View file

@ -60,8 +60,10 @@ private:
// Root of FlightGear scenery tree
string fg_scenery;
#if 0
// Freeze sim
bool freeze;
#endif
// Fullscreen mode for old 3DFX cards.
#if defined(FX) && defined(XMESA)
@ -123,8 +125,10 @@ public:
fg_scenery = scenery;
}
#if 0
inline bool get_freeze() const { return freeze; }
inline void set_freeze( bool f ) { freeze = f; }
#endif
#if defined(FX) && defined(XMESA)
inline bool get_fullscreen() const { return fullscreen; }

View file

@ -899,6 +899,8 @@ void fgRenderFrame( void ) {
// Update internal time dependent calculations (i.e. flight model)
void fgUpdateTimeDepCalcs() {
static bool inited = false;
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
// cout << "Updating time dep calcs()" << endl;
@ -926,7 +928,7 @@ void fgUpdateTimeDepCalcs() {
// instance ...
if ( !cur_fdm_state->get_inited() ) {
// do nothing, fdm isn't inited yet
} else if ( globals->get_freeze() ) {
} else if ( master_freeze->getBoolValue() ) {
// we are frozen, run the fdm's with 0 time slices in case
// they want to do something with that.
@ -1516,16 +1518,6 @@ int mainLoop( int argc, char **argv ) {
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ;
#endif
#if 0
#ifdef GL_EXT_texture_filter_anisotropic
float max_anisotropy;
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
max_anisotropy );
cout << "Max anisotropy = " << max_anisotropy << endl;
#endif
#endif
// set current_options lon/lat if an airport id is specified
// cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl;
if ( fgGetString("/sim/startup/airport-id").length() ) {

View file

@ -187,6 +187,12 @@ fgSetDefaults ()
fgSetBool("/sim/networking/network-olk", false);
fgSetString("/sim/networking/call-sign", "Johnny");
// Freeze options
fgSetBool("/sim/freeze/master", false);
fgSetBool("/sim/freeze/position", false);
fgSetBool("/sim/freeze/fuel", false);
fgSetBool("/sim/freeze/time-of-day", false);
}
@ -548,9 +554,9 @@ parse_option (const string& arg)
} else if ( arg == "--enable-mouse-pointer" ) {
fgSetString("/sim/startup/mouse-pointer", "enabled");
} else if ( arg == "--disable-freeze" ) {
fgSetBool("/sim/freeze", false);
fgSetBool("/sim/freeze/master", false);
} else if ( arg == "--enable-freeze" ) {
fgSetBool("/sim/freeze", true);
fgSetBool("/sim/freeze/master", true);
} else if ( arg == "--disable-anti-alias-hud" ) {
fgSetBool("/sim/hud/antialiased", false);
} else if ( arg == "--enable-anti-alias-hud" ) {

View file

@ -217,3 +217,5 @@ void FGMaterialLib::load_next_deferred() {
return;
}
}

View file

@ -202,6 +202,15 @@ FGNewMat::build_ssg_state (bool defer_tex_load)
textured->enable( GL_TEXTURE_2D );
textured->disable( GL_BLEND );
textured->disable( GL_ALPHA_TEST );
#if 0
# ifdef GL_EXT_texture_filter_anisotropic
float max_anisotropy;
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
max_anisotropy );
cout << "Max anisotropy = " << max_anisotropy << endl;
# endif
#endif
if ( !defer_tex_load ) {
textured->setTexture( (char *)texture_path.c_str(), wrapu, wrapv );
texture_loaded = true;

View file

@ -868,6 +868,32 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
}
// Set up lights rendering call backs
static int fgLightsPredraw( ssgEntity *e ) {
#ifdef GL_EXT_point_parameters
if (glutExtensionSupported("GL_EXT_point_parameters")) {
static float quadratic[3] = {1.0, 0.01, 0.0001};
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quadratic);
glPointParameterfEXT(GL_POINT_SIZE_MIN_EXT, 1.0);
glPointSize(4.0);
}
#endif
return true;
}
static int fgLightsPostdraw( ssgEntity *e ) {
#ifdef GL_EXT_point_parameters
if (glutExtensionSupported("GL_EXT_point_parameters")) {
static float default_attenuation[3] = {1.0, 0.0, 0.0};
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT,
default_attenuation);
glPointSize(1.0);
}
#endif
return true;
}
ssgLeaf* FGTileEntry::gen_lights( ssgVertexArray *lights, int inc, float bright ) {
// generate a repeatable random seed
float *p1 = lights->get( 0 );
@ -920,6 +946,8 @@ ssgLeaf* FGTileEntry::gen_lights( ssgVertexArray *lights, int inc, float bright
// assign state
FGNewMat *newmat = material_lib.find( "LIGHTS" );
leaf->setState( newmat->get_state() );
leaf->setCallback( SSG_CALLBACK_PREDRAW, fgLightsPredraw );
leaf->setCallback( SSG_CALLBACK_POSTDRAW, fgLightsPostdraw );
return leaf;
}