1
0
Fork 0

#600, for Curt... ;-) allow speed-up value to use fractions

"speed-up" can now also be used for slow-motion (i.e. 0.5 / 0.25 / ...)
or fractional speeds (3.141...). This was already working for instruments
(for replay) before, now it's also considered by FDM simulation.
This commit is contained in:
ThorstenB 2012-11-17 20:01:19 +01:00
parent 8a954f8338
commit adc95a4b55
5 changed files with 12 additions and 8 deletions

View file

@ -269,10 +269,10 @@ void FGLaRCsim::update( double dt ) {
}
// copy control positions into the LaRCsim structure
Lat_control = globals->get_controls()->get_aileron() / speed_up->getIntValue();
Lat_control = globals->get_controls()->get_aileron() / speed_up->getDoubleValue();
Long_control = globals->get_controls()->get_elevator();
Long_trim = globals->get_controls()->get_elevator_trim();
Rudder_pedal = globals->get_controls()->get_rudder() / speed_up->getIntValue();
Rudder_pedal = globals->get_controls()->get_rudder() / speed_up->getDoubleValue();
// IO360.cxx for the C172 thrust is broken (not sure why).
// So force C172 to use engine model in c172_engine.c instead of the IO360.cxx.

View file

@ -69,9 +69,11 @@ FGInterface::_calc_multiloop (double dt)
// roundoff problems when we already have nearly accurate values.
// Only the speedup thing must be still handled here
int hz = fgGetInt("/sim/model-hz");
int multiloop = SGMiscd::roundToInt(dt*hz);
int speedup = fgGetInt("/sim/speed-up");
return multiloop * speedup;
double speedup = fgGetDouble("/sim/speed-up");
double loops = dt * hz * speedup + delta_loops;
int iloops = SGMiscd::roundToInt(loops);
delta_loops = loops-iloops; // delta_loops required for speed-ups < 1 (to do one iteration every n-th step)
return iloops;
}
@ -119,6 +121,7 @@ FGInterface::_setup ()
climb_rate=0;
altitude_agl=0;
track=0;
delta_loops = 0.0;
}
void

View file

@ -191,6 +191,7 @@ private:
double climb_rate; // in feet per second
double altitude_agl;
double track;
double delta_loops;
simgear::TiedPropertyList _tiedProperties;

View file

@ -190,7 +190,7 @@ fgSetDefaults ()
fgSetString("/sim/flight-model", "jsb");
fgSetString("/sim/aero", "c172");
fgSetInt("/sim/model-hz", NEW_DEFAULT_MODEL_HZ);
fgSetInt("/sim/speed-up", 1);
fgSetDouble("/sim/speed-up", 1.0);
// Rendering options
fgSetString("/sim/rendering/fog", "nicest");
@ -1392,7 +1392,7 @@ struct OptionDesc {
{"aircraft-dir", true, OPTION_IGNORE, "", false, "", 0 },
{"model-hz", true, OPTION_INT, "/sim/model-hz", false, "", 0 },
{"max-fps", true, OPTION_DOUBLE, "/sim/frame-rate-throttle-hz", false, "", 0 },
{"speed", true, OPTION_INT, "/sim/speed-up", false, "", 0 },
{"speed", true, OPTION_DOUBLE, "/sim/speed-up", false, "", 0 },
{"trim", false, OPTION_BOOL, "/sim/presets/trim", true, "", 0 },
{"notrim", false, OPTION_BOOL, "/sim/presets/trim", false, "", 0 },
{"on-ground", false, OPTION_BOOL, "/sim/presets/onground", true, "", 0 },

View file

@ -452,7 +452,7 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
node->setDoubleValue( "nav/frequencies/selected-mhz[0]", net->nav_1 );
node->setDoubleValue( "nav[1]/frequencies/selected-mhz[0]", net->nav_2 );
fgSetInt( "/sim/speed-up", net->speedup );
fgSetDouble( "/sim/speed-up", net->speedup );
if ( honor_freezes ) {
node = fgGetNode( "/sim/freeze", true );