1
0
Fork 0

Merge branch 'next' of gitorious.org:fg/flightgear into next

This commit is contained in:
Curtis L. Olson 2011-05-16 09:05:52 -05:00
commit 800ac5a188
4 changed files with 34 additions and 19 deletions

View file

@ -100,6 +100,7 @@ void FGReplay::init()
disable_replay = fgGetNode( "/sim/replay/disable", true ); disable_replay = fgGetNode( "/sim/replay/disable", true );
replay_master = fgGetNode( "/sim/freeze/replay-state", true ); replay_master = fgGetNode( "/sim/freeze/replay-state", true );
replay_time = fgGetNode( "/sim/replay/time", true); replay_time = fgGetNode( "/sim/replay/time", true);
replay_looped = fgGetNode( "/sim/replay/looped", true);
reinit(); reinit();
} }
@ -194,10 +195,28 @@ void FGReplay::update( double dt )
// replay inactive, keep recording // replay inactive, keep recording
break; break;
case 1: case 1:
// replay active {
replay( replay_time->getDoubleValue() ); // replay active
replay_time->setDoubleValue( replay_time->getDoubleValue() double current_time = replay_time->getDoubleValue();
+ ( dt * fgGetInt("/sim/speed-up") ) ); if (current_time<0.0)
{
// initialize start time
fgSetDouble( "/sim/replay/start-time", get_start_time() );
fgSetDouble( "/sim/replay/end-time", get_end_time() );
double duration = fgGetDouble( "/sim/replay/duration" );
if( duration && duration < (get_end_time() - get_start_time()) ) {
current_time = get_end_time() - duration;
} else {
current_time = get_start_time();
}
}
bool IsFinished = replay( replay_time->getDoubleValue() );
if ((IsFinished)&&(replay_looped->getBoolValue()))
current_time = -1;
else
current_time += dt * fgGetInt("/sim/speed-up");
replay_time->setDoubleValue(current_time);
}
return; // don't record the replay session return; // don't record the replay session
case 2: case 2:
// replay paused, no-op // replay paused, no-op
@ -279,7 +298,7 @@ void FGReplay::update( double dt )
FGReplayData *lt_front = long_term.front(); FGReplayData *lt_front = long_term.front();
if ( sim_time - lt_front->sim_time > lt_list_time ) { if ( sim_time - lt_front->sim_time > lt_list_time ) {
//stamp("point_10"); //stamp("point_10");
while ( sim_time - lt_front->sim_time > lt_list_time ) { while ( sim_time - lt_front->sim_time > lt_list_time ) {
lt_front = long_term.front(); lt_front = long_term.front();
recycler.push_back(lt_front); recycler.push_back(lt_front);
@ -558,9 +577,10 @@ static void interpolate( double time, const replay_list_type &list ) {
/** /**
* Replay a saved frame based on time, interpolate from the two * Replay a saved frame based on time, interpolate from the two
* nearest saved frames. * nearest saved frames.
* Returns true when replay sequence has finished, false otherwise.
*/ */
void FGReplay::replay( double time ) { bool FGReplay::replay( double time ) {
// cout << "replay: " << time << " "; // cout << "replay: " << time << " ";
// find the two frames to interpolate between // find the two frames to interpolate between
double t1, t2; double t1, t2;
@ -571,6 +591,8 @@ void FGReplay::replay( double time ) {
if ( time > t1 ) { if ( time > t1 ) {
// replay the most recent frame // replay the most recent frame
update_fdm( (*short_term.back()) ); update_fdm( (*short_term.back()) );
// replay is finished now
return true;
// cout << "first frame" << endl; // cout << "first frame" << endl;
} else if ( time <= t1 && time >= t2 ) { } else if ( time <= t1 && time >= t2 ) {
interpolate( time, short_term ); interpolate( time, short_term );
@ -624,7 +646,9 @@ void FGReplay::replay( double time ) {
} }
} else { } else {
// nothing to replay // nothing to replay
return true;
} }
return false;
} }

View file

@ -74,7 +74,7 @@ public:
virtual void unbind(); virtual void unbind();
virtual void update( double dt ); virtual void update( double dt );
void replay( double time ); bool replay( double time );
double get_start_time(); double get_start_time();
double get_end_time(); double get_end_time();
@ -101,6 +101,7 @@ private:
SGPropertyNode_ptr disable_replay; SGPropertyNode_ptr disable_replay;
SGPropertyNode_ptr replay_master; SGPropertyNode_ptr replay_master;
SGPropertyNode_ptr replay_time; SGPropertyNode_ptr replay_time;
SGPropertyNode_ptr replay_looped;
}; };

View file

@ -729,7 +729,7 @@ bool FGJSBsim::copy_to_JSBsim()
// turbulence_gain normalized: 0: none, 1/3: light, 2/3: moderate, 3/3: severe // turbulence_gain normalized: 0: none, 1/3: light, 2/3: moderate, 3/3: severe
double tmp = turbulence_gain->getDoubleValue(); double tmp = turbulence_gain->getDoubleValue();
Atmosphere->SetProbabilityOfExceedence( Atmosphere->SetProbabilityOfExceedence(
round(TurbulenceSeverityTable.GetValue( tmp ) ) SGMiscd::roundToInt(TurbulenceSeverityTable.GetValue( tmp ) )
); );
Atmosphere->SetWindspeed20ft(ground_wind->getDoubleValue()); Atmosphere->SetWindspeed20ft(ground_wind->getDoubleValue());
break; break;

View file

@ -1247,17 +1247,7 @@ do_replay (const SGPropertyNode * arg)
fgSetInt( "/sim/freeze/replay-state", 1 ); fgSetInt( "/sim/freeze/replay-state", 1 );
fgSetBool("/sim/freeze/master", 0 ); fgSetBool("/sim/freeze/master", 0 );
fgSetBool("/sim/freeze/clock", 0 ); fgSetBool("/sim/freeze/clock", 0 );
fgSetDouble( "/sim/replay/time", -1 );
FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));
fgSetDouble( "/sim/replay/start-time", r->get_start_time() );
fgSetDouble( "/sim/replay/end-time", r->get_end_time() );
double duration = fgGetDouble( "/sim/replay/duration" );
if( duration && duration < (r->get_end_time() - r->get_start_time()) ) {
fgSetDouble( "/sim/replay/time", r->get_end_time() - duration );
} else {
fgSetDouble( "/sim/replay/time", r->get_start_time() );
}
// cout << "start = " << r->get_start_time() // cout << "start = " << r->get_start_time()
// << " end = " << r->get_end_time() << endl; // << " end = " << r->get_end_time() << endl;