1
0
Fork 0

Replay improvements

Clear replay buffers on sim reset.
Allow instant replay to be activated properly when sim is paused.
This commit is contained in:
ThorstenB 2011-03-20 14:59:19 +01:00
parent 51a6302f48
commit b6d70d2c71
4 changed files with 17 additions and 5 deletions

View file

@ -83,6 +83,14 @@ FGReplay::~FGReplay() {
*/ */
void FGReplay::init() { void FGReplay::init() {
reinit();
}
/**
* Reset replay queues.
*/
void FGReplay::reinit() {
sim_time = 0.0; sim_time = 0.0;
last_mt_time = 0.0; last_mt_time = 0.0;
last_lt_time = 0.0; last_lt_time = 0.0;
@ -110,17 +118,16 @@ void FGReplay::init() {
(lt_list_time*lt_dt)); (lt_list_time*lt_dt));
for (int i = 0; i < estNrObjects; i++) { for (int i = 0; i < estNrObjects; i++) {
recycler.push_back(new FGReplayData); recycler.push_back(new FGReplayData);
} }
} }
/** /**
* Bind to the property tree * Bind to the property tree
*/ */
void FGReplay::bind() { void FGReplay::bind() {
disable_replay = fgGetNode( "/sim/replay/disable", true ); disable_replay = fgGetNode( "/sim/replay/disable", true );
replay_master = fgGetNode( "/sim/freeze/replay-state", true );
} }
@ -140,8 +147,6 @@ void FGReplay::unbind() {
void FGReplay::update( double dt ) { void FGReplay::update( double dt ) {
timingInfo.clear(); timingInfo.clear();
stamp("begin"); stamp("begin");
static SGPropertyNode *replay_master
= fgGetNode( "/sim/freeze/replay-state", true );
if( disable_replay->getBoolValue() ) { if( disable_replay->getBoolValue() ) {
if ( sim_time != 0.0 ) { if ( sim_time != 0.0 ) {

View file

@ -69,6 +69,7 @@ public:
virtual ~FGReplay(); virtual ~FGReplay();
virtual void init(); virtual void init();
virtual void reinit();
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void update( double dt ); virtual void update( double dt );
@ -96,6 +97,7 @@ private:
replay_list_type long_term; replay_list_type long_term;
replay_list_type recycler; replay_list_type recycler;
SGPropertyNode_ptr disable_replay; SGPropertyNode_ptr disable_replay;
SGPropertyNode_ptr replay_master;
}; };

View file

@ -1243,8 +1243,10 @@ do_log_level (const SGPropertyNode * arg)
static bool static bool
do_replay (const SGPropertyNode * arg) do_replay (const SGPropertyNode * arg)
{ {
// freeze the master fdm // freeze the fdm, resume from sim pause
fgSetInt( "/sim/freeze/replay-state", 1 ); fgSetInt( "/sim/freeze/replay-state", 1 );
fgSetBool("/sim/freeze/master", 0 );
fgSetBool("/sim/freeze/clock", 0 );
FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" )); FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));

View file

@ -1553,6 +1553,9 @@ void fgReInitSubsystems()
// Initialize the FDM // Initialize the FDM
globals->get_subsystem("flight")->reinit(); globals->get_subsystem("flight")->reinit();
// reset replay buffers
globals->get_subsystem("replay")->reinit();
// reload offsets from config defaults // reload offsets from config defaults
globals->get_viewmgr()->reinit(); globals->get_viewmgr()->reinit();