1
0
Fork 0
flightgear/src/Aircraft/replay.hxx

109 lines
2.6 KiB
C++
Raw Normal View History

// replay.hxx - a system to record and replay FlightGear flights
//
// Written by Curtis Olson, started Juley 2003.
//
// Copyright (C) 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
2006-02-21 01:16:04 +00:00
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef _FG_REPLAY_HXX
#define _FG_REPLAY_HXX 1
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#include <deque>
#include <simgear/math/sg_types.hxx>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <Network/net_ctrls.hxx>
#include <Network/net_fdm.hxx>
using std::deque;
class FGReplayData {
public:
double sim_time;
FGNetFDM fdm;
FGNetCtrls ctrls;
};
typedef deque < FGReplayData *> replay_list_type;
/**
* A recording/replay module for FlightGear flights
*
*/
class FGReplay : public SGSubsystem
{
public:
FGReplay ();
virtual ~FGReplay();
virtual void init();
virtual void reinit();
virtual void bind();
virtual void unbind();
virtual void update( double dt );
bool replay( double time );
double get_start_time();
double get_end_time();
private:
void clear();
2003-07-18 08:14:21 +00:00
static const double st_list_time; // 60 secs of high res data
static const double mt_list_time; // 10 mins of 1 fps data
static const double lt_list_time; // 1 hr of 10 spf data
// short term sample rate is as every frame
2003-07-18 08:14:21 +00:00
static const double mt_dt; // medium term sample rate (sec)
static const double lt_dt; // long term sample rate (sec)
double sim_time;
double last_mt_time;
double last_lt_time;
int last_replay_state;
replay_list_type short_term;
replay_list_type medium_term;
replay_list_type long_term;
replay_list_type recycler;
Harald JOHNSEN: I did some profiling of the code and found a few interessant things. Some corrections are obvious like the one in the multiplayer code, the fps is no more divided by 2 or 3 when another plane is on screen. Other things like collision detection and computation of agl can not really be optimized. I changed a few things in hitlist.cxx but this only give a very low increase of fps. The groundcache eats a lot of cpu but I think that the real way to do it is to use a real collision system like OPCODE or something like that. And I added an option to disable the recording of replay data. It takes more cpu than we can think. Changes ======= - panel.cxx : moved the computation of the instruments diffuse color outside the texturelayer code since this is constant during a frame, this is a big speedup for 2D panels ; - hitlist.cxx : changed the computation of the intersection between ray and triangle, optimized the sphere culling by using a normalized direction vector. This can give a 35% speedup on the computation of elevation in some situations ; - renderer.cxx, acmodel.cxx : call ssgDrawAndCull with plane scene graph in external or internal view, calling ssgDrawAndCull with the root scene graph was drawing other players plane a second time in multiplayer mode ; - mplayer.cxx : removed the calls to ssgFlatten and ssgStripify because it was degenerating models, causing a massive drop in frame rate ; - replay.cxx : added an option to disable the recording of the flight - fgclouds.cxx : changed the path of cloudlayer properties to match preferences.xml ; set the altitude of clouds from scenarios to a more correct value if metar is not enabled ;
2005-07-31 09:04:18 +00:00
SGPropertyNode_ptr disable_replay;
SGPropertyNode_ptr replay_master;
SGPropertyNode_ptr replay_time;
SGPropertyNode_ptr replay_looped;
};
#endif // _FG_REPLAY_HXX