Looped replay feature
New option for continuously repeated replay (LinuxTag FlightGear demo mode :) )
This commit is contained in:
parent
13db36f679
commit
6c3cd27a57
2 changed files with 19 additions and 7 deletions
|
@ -100,6 +100,7 @@ void FGReplay::init()
|
|||
disable_replay = fgGetNode( "/sim/replay/disable", true );
|
||||
replay_master = fgGetNode( "/sim/freeze/replay-state", true );
|
||||
replay_time = fgGetNode( "/sim/replay/time", true);
|
||||
replay_looped = fgGetNode( "/sim/replay/looped", true);
|
||||
reinit();
|
||||
}
|
||||
|
||||
|
@ -194,10 +195,15 @@ void FGReplay::update( double dt )
|
|||
// replay inactive, keep recording
|
||||
break;
|
||||
case 1:
|
||||
// replay active
|
||||
replay( replay_time->getDoubleValue() );
|
||||
replay_time->setDoubleValue( replay_time->getDoubleValue()
|
||||
+ ( dt * fgGetInt("/sim/speed-up") ) );
|
||||
{
|
||||
// replay active
|
||||
bool IsFinished = replay( replay_time->getDoubleValue() );
|
||||
if ((IsFinished)&&(replay_looped->getBoolValue()))
|
||||
replay_time->setDoubleValue(0.0);
|
||||
else
|
||||
replay_time->setDoubleValue( replay_time->getDoubleValue()
|
||||
+ ( dt * fgGetInt("/sim/speed-up") ) );
|
||||
}
|
||||
return; // don't record the replay session
|
||||
case 2:
|
||||
// replay paused, no-op
|
||||
|
@ -279,7 +285,7 @@ void FGReplay::update( double dt )
|
|||
|
||||
FGReplayData *lt_front = long_term.front();
|
||||
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 ) {
|
||||
lt_front = long_term.front();
|
||||
recycler.push_back(lt_front);
|
||||
|
@ -558,9 +564,10 @@ static void interpolate( double time, const replay_list_type &list ) {
|
|||
/**
|
||||
* Replay a saved frame based on time, interpolate from the two
|
||||
* 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 << " ";
|
||||
// find the two frames to interpolate between
|
||||
double t1, t2;
|
||||
|
@ -571,6 +578,8 @@ void FGReplay::replay( double time ) {
|
|||
if ( time > t1 ) {
|
||||
// replay the most recent frame
|
||||
update_fdm( (*short_term.back()) );
|
||||
// replay is finished now
|
||||
return true;
|
||||
// cout << "first frame" << endl;
|
||||
} else if ( time <= t1 && time >= t2 ) {
|
||||
interpolate( time, short_term );
|
||||
|
@ -624,7 +633,9 @@ void FGReplay::replay( double time ) {
|
|||
}
|
||||
} else {
|
||||
// nothing to replay
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
virtual void unbind();
|
||||
virtual void update( double dt );
|
||||
|
||||
void replay( double time );
|
||||
bool replay( double time );
|
||||
double get_start_time();
|
||||
double get_end_time();
|
||||
|
||||
|
@ -101,6 +101,7 @@ private:
|
|||
SGPropertyNode_ptr disable_replay;
|
||||
SGPropertyNode_ptr replay_master;
|
||||
SGPropertyNode_ptr replay_time;
|
||||
SGPropertyNode_ptr replay_looped;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue