1
0
Fork 0

Make FGAircraftModel more subsystem-alike, move update to fgMainLoop.

This commit is contained in:
James Turner 2010-06-12 15:52:21 +02:00 committed by James Turner
parent 47c956b516
commit 3fbf3aa080
4 changed files with 34 additions and 33 deletions

View file

@ -204,14 +204,8 @@ fgLoadAircraft (const SGPropertyNode * arg)
globals->get_current_panel()->update(0);
}
// Load the new 3D model
//
globals->get_aircraft_model()->unbind();
delete globals->get_aircraft_model();
globals->set_aircraft_model(new FGAircraftModel);
globals->get_aircraft_model()->init();
globals->get_aircraft_model()->bind();
globals->get_aircraft_model()->reinit();
// TODO:
// load new electrical system
//
@ -227,11 +221,7 @@ fgLoadAircraft (const SGPropertyNode * arg)
t = fgInitTime();
globals->set_time_params( t );
globals->get_viewmgr()->reinit();
globals->get_controls()->reset_all();
globals->get_aircraft_model()->reinit();
globals->get_subsystem("xml-autopilot")->reinit();
fgReInitSubsystems();
if ( !freeze ) {

View file

@ -183,8 +183,6 @@ void fgUpdateTimeDepCalcs() {
// do nothing, fdm isn't inited yet
}
globals->get_aircraft_model()->update(delta_time_sec);
// Update solar system
globals->get_ephem()->update( globals->get_time_params()->getMjd(),
globals->get_time_params()->getLst(),
@ -455,7 +453,8 @@ static void fgMainLoop( void ) {
SG_LOG( SG_ALL, SG_DEBUG,
"Elapsed time is zero ... we're zinging" );
}
globals->get_aircraft_model()->update(delta_time_sec);
globals->get_subsystem_mgr()->update(delta_time_sec);
//
@ -697,9 +696,11 @@ static void fgIdleFunction ( void ) {
// Initialize the 3D aircraft model subsystem (has a dependency on
// the scenery subsystem.)
////////////////////////////////////////////////////////////////////
globals->set_aircraft_model(new FGAircraftModel);
globals->get_aircraft_model()->init();
globals->get_aircraft_model()->bind();
FGAircraftModel* acm = new FGAircraftModel;
globals->set_aircraft_model(acm);
//globals->add_subsystem("aircraft-model", acm);
acm->init();
acm->bind();
////////////////////////////////////////////////////////////////////
// Initialize the view manager subsystem.

View file

@ -55,10 +55,7 @@ FGAircraftModel::FGAircraftModel ()
FGAircraftModel::~FGAircraftModel ()
{
osg::Node* node = _aircraft->getSceneGraph();
globals->get_scenery()->get_aircraft_branch()->removeChild(node);
delete _aircraft;
deinit();
}
void
@ -83,6 +80,27 @@ FGAircraftModel::init ()
globals->get_scenery()->get_aircraft_branch()->addChild(node);
}
void
FGAircraftModel::reinit()
{
deinit();
init();
}
void
FGAircraftModel::deinit()
{
if (!_aircraft) {
return;
}
osg::Node* node = _aircraft->getSceneGraph();
globals->get_scenery()->get_aircraft_branch()->removeChild(node);
delete _aircraft;
_aircraft = NULL;
}
void
FGAircraftModel::bind ()
{

View file

@ -6,16 +6,6 @@
#ifndef __ACMODEL_HXX
#define __ACMODEL_HXX 1
#ifndef __cplusplus
# error This library requires C++
#endif
#include <vector>
#include <string>
using std::string;
using std::vector;
#include <osg/ref_ptr>
#include <osg/Group>
#include <osg/Switch>
@ -35,6 +25,7 @@ public:
virtual ~FGAircraftModel ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
@ -42,7 +33,8 @@ public:
virtual SGVec3d& getVelocity() { return _velocity; }
private:
void deinit ();
SGModelPlacement * _aircraft;
SGVec3d _velocity;
SGSharedPtr<FGFX> _fx;