1
0
Fork 0

Move three more subsystems into the init + update scheme - fixes some crashes found by papillion.

This commit is contained in:
James Turner 2010-10-22 12:22:00 +01:00
parent f5c2c630eb
commit d573cb43a0
8 changed files with 63 additions and 94 deletions

View file

@ -237,7 +237,7 @@ void FGRouteMgr::postinit()
SG_LOG(SG_AUTOPILOT, SG_INFO, "loaded initial waypoints:" << _route.size());
}
weightOnWheels = fgGetNode("/gear/gear[0]/wow", false);
weightOnWheels = fgGetNode("/gear/gear[0]/wow", true);
// check airbone flag agrees with presets
}

View file

@ -97,11 +97,6 @@ void runway_instr::draw()
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
//Assuming that the "Cockpit View" is always at position zero!!!
if (curr_view_id != 0) {
globals->get_viewmgr()->set_view(0);
globals->get_viewmgr()->copyToCurrent();
}
//Set the camera to the cockpit view to get the view of the runway from the cockpit
// OSGFIXME
// ssgSetCamera((sgVec4 *)cockpit_view->get_VIEW());
@ -156,15 +151,6 @@ void runway_instr::draw()
drawArrow(); //draw indication arrow
}
//Restore the current view and any offsets
if (curr_view_id != 0) {
globals->get_viewmgr()->set_view(curr_view_id);
globals->get_viewmgr()->copyToCurrent();
curr_view->setHeadingOffset_deg(ho);
curr_view->setPitchOffset_deg(po);
curr_view->setGoalHeadingOffset_deg(gho);
curr_view->setGoalPitchOffset_deg(gpo);
}
//Set the camera back to the current view
// OSGFIXME
// ssgSetCamera((sgVec4 *)curr_view);

View file

@ -93,11 +93,6 @@ void HUD::Runway::draw()
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
//Assuming that the "Cockpit View" is always at position zero!!!
if (curr_view_id != 0) {
globals->get_viewmgr()->set_view(0);
globals->get_viewmgr()->copyToCurrent();
}
//Set the camera to the cockpit view to get the view of the runway from the cockpit
// OSGFIXME
// ssgSetCamera((sgVec4 *)_cockpit_view->get_VIEW());
@ -152,15 +147,6 @@ void HUD::Runway::draw()
drawArrow(); //draw indication arrow
}
//Restore the current view and any offsets
if (curr_view_id != 0) {
globals->get_viewmgr()->set_view(curr_view_id);
globals->get_viewmgr()->copyToCurrent();
curr_view->setHeadingOffset_deg(ho);
curr_view->setPitchOffset_deg(po);
curr_view->setGoalHeadingOffset_deg(gho);
curr_view->setGoalPitchOffset_deg(gpo);
}
//Set the camera back to the current view
// OSGFIXME
// ssgSetCamera((sgVec4 *)curr_view);

View file

@ -93,6 +93,7 @@
#include <Input/input.hxx>
#include <Instrumentation/instrument_mgr.hxx>
#include <Model/acmodel.hxx>
#include <Model/modelmgr.hxx>
#include <AIModel/submodel.hxx>
#include <AIModel/AIManager.hxx>
#include <Navaids/navdb.hxx>
@ -1309,9 +1310,6 @@ bool fgInitSubsystems() {
// Initialize the scenery management subsystem.
////////////////////////////////////////////////////////////////////
globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
SGSubsystemMgr::DISPLAY);
globals->get_scenery()->get_scene_graph()
->addChild(simgear::Particles::getCommonRoot());
simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
@ -1361,23 +1359,12 @@ bool fgInitSubsystems() {
globals->add_subsystem("gui", new NewGUI, SGSubsystemMgr::INIT);
////////////////////////////////////////////////////////////////////
// Initialize the lighting subsystem.
////////////////////////////////////////////////////////////////////
globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
//////////////////////////////////////////////////////////////////////
// Initialize the 2D cloud subsystem.
////////////////////////////////////////////////////////////////////
fgGetBool("/sim/rendering/bump-mapping", false);
#ifdef ENABLE_AUDIO_SUPPORT
////////////////////////////////////////////////////////////////////
// Initialize the sound-effects subsystem.
////////////////////////////////////////////////////////////////////
globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
#endif
////////////////////////////////////////////////////////////////////
// Initialise the ATC Manager
@ -1461,7 +1448,37 @@ bool fgInitSubsystems() {
////////////////////////////////////////////////////////////////////
globals->add_subsystem("replay", new FGReplay);
#ifdef ENABLE_AUDIO_SUPPORT
////////////////////////////////////////////////////////////////////
// Initialize the sound-effects subsystem.
////////////////////////////////////////////////////////////////////
globals->add_subsystem("voice", new FGVoiceMgr, SGSubsystemMgr::DISPLAY);
#endif
////////////////////////////////////////////////////////////////////
// Initialize the lighting subsystem.
////////////////////////////////////////////////////////////////////
globals->add_subsystem("lighting", new FGLight, SGSubsystemMgr::DISPLAY);
// ordering here is important : Nasal (via events), then models, then views
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
FGAircraftModel* acm = new FGAircraftModel;
globals->set_aircraft_model(acm);
globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
FGModelMgr* mm = new FGModelMgr;
globals->set_model_mgr(mm);
globals->add_subsystem("model-manager", mm, SGSubsystemMgr::DISPLAY);
FGViewMgr *viewmgr = new FGViewMgr;
globals->set_viewmgr( viewmgr );
globals->add_subsystem("view-manager", viewmgr, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("tile-manager", globals->get_tile_mgr(),
SGSubsystemMgr::DISPLAY);
////////////////////////////////////////////////////////////////////
// Bind and initialize subsystems.
////////////////////////////////////////////////////////////////////

View file

@ -170,7 +170,6 @@ FGGlobals::~FGGlobals()
subsystem_mgr->unbind();
delete subsystem_mgr;
delete event_mgr;
delete time_params;
delete mag;
@ -180,10 +179,7 @@ FGGlobals::~FGGlobals()
delete ATC_mgr;
delete controls;
delete viewmgr;
// delete commands;
delete model_mgr;
delete channel_options_list;
delete initial_waypoints;
delete scenery;

View file

@ -54,7 +54,6 @@
#include <Cockpit/cockpit.hxx>
#include <Cockpit/hud.hxx>
#include <Model/panelnode.hxx>
#include <Model/modelmgr.hxx>
#include <Model/acmodel.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
@ -149,16 +148,6 @@ static void fgMainLoop( void ) {
globals->get_subsystem_mgr()->update(sim_dt);
// run Nasal's settimer() loops right before the view manager
globals->get_event_mgr()->update(sim_dt);
// pick up model coordidnates that Nasal code may have set relative to the
// aircraft's
globals->get_model_mgr()->update(sim_dt);
// update the view angle as late as possible, but before sound calculations
globals->get_viewmgr()->update(real_dt);
// Update the sound manager last so it can use the CPU while the GPU
// is processing the scenery (doubled the frame-rate for me) -EMH-
#ifdef ENABLE_AUDIO_SUPPORT
@ -375,33 +364,12 @@ static void fgIdleFunction ( void ) {
globals->set_tile_mgr( new FGTileMgr );
////////////////////////////////////////////////////////////////////
// Initialize the general model subsystem.
////////////////////////////////////////////////////////////////////
globals->set_model_mgr(new FGModelMgr);
globals->get_model_mgr()->init();
globals->get_model_mgr()->bind();
fgSplashProgress("loading aircraft");
} else if ( idle_state == 5 ) {
idle_state++;
////////////////////////////////////////////////////////////////////
// Initialize the 3D aircraft model subsystem (has a dependency on
// the scenery subsystem.)
////////////////////////////////////////////////////////////////////
FGAircraftModel* acm = new FGAircraftModel;
globals->set_aircraft_model(acm);
globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
////////////////////////////////////////////////////////////////////
// Initialize the view manager subsystem.
////////////////////////////////////////////////////////////////////
FGViewMgr *viewmgr = new FGViewMgr;
globals->set_viewmgr( viewmgr );
viewmgr->init();
viewmgr->bind();
fgSplashProgress("generating sky elements");

View file

@ -39,6 +39,7 @@
FGViewMgr::FGViewMgr( void ) :
axis_long(0),
axis_lat(0),
inited(false),
view_number(fgGetNode("/sim/current-view/view-number", true)),
config_list(fgGetNode("/sim", true)->getChildren("view")),
current(0)
@ -53,6 +54,13 @@ FGViewMgr::~FGViewMgr( void ) {
void
FGViewMgr::init ()
{
if (inited) {
SG_LOG(SG_GENERAL, SG_WARN, "duplicate init of view manager");
return;
}
inited = true;
double aspect_ratio_multiplier
= fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
@ -118,6 +126,7 @@ FGViewMgr::init ()
}
copyToCurrent();
do_bind();
}
void
@ -160,7 +169,14 @@ FGViewMgr::reinit ()
typedef double (FGViewMgr::*double_getter)() const;
void
FGViewMgr::bind ()
FGViewMgr::bind()
{
// view-manager code was designed to init before bind, so
// this is a no-op; init() calls the real bind() impl below
}
void
FGViewMgr::do_bind()
{
// these are bound to the current view properties
fgTie("/sim/current-view/heading-offset-deg", this,
@ -352,6 +368,10 @@ FGViewMgr::update (double dt)
void
FGViewMgr::copyToCurrent()
{
if (!inited) {
return;
}
SGPropertyNode *n = config_list[current];
fgSetString("/sim/current-view/name", n->getStringValue("name"));
fgSetString("/sim/current-view/type", n->getStringValue("type"));
@ -719,15 +739,9 @@ FGViewMgr::setView (int newview)
newview = 0;
// set new view
set_view(newview);
current = newview;
// copy in view data
copyToCurrent();
// Copy the fdm's position into the SGLocation which is shared with
// some views ...
globals->get_aircraft_model()->update(0);
// Do the update ...
update(0);
}
@ -755,7 +769,7 @@ FGViewMgr::getARM_deg () const
void
FGViewMgr::setARM_deg (double aspect_ratio_multiplier)
{
{
FGViewer * view = get_current_view();
if (view != 0)
view->set_aspect_ratio_multiplier(aspect_ratio_multiplier);

View file

@ -69,14 +69,12 @@ public:
// setters
void clear();
inline void set_view( const int v ) { current = v; }
void add_view( FGViewer * v );
// copies current offset settings to current-view path...
void copyToCurrent ();
private:
void do_bind();
list<const char*> tied_props;
double axis_long;
@ -136,6 +134,10 @@ private:
bool stationary () const;
// copies current offset settings to current-view path...
void copyToCurrent ();
bool inited;
SGPropertyNode_ptr view_number;
vector<SGPropertyNode_ptr> config_list;
typedef std::vector<FGViewerPtr> viewer_list;