From 5103729ca0dfcb0b40a42a42119dfd87fe28c474 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 8 Aug 2000 00:39:52 +0000 Subject: [PATCH] Updates to use new SGMagVar class from simgear. --- src/Main/bfi.cxx | 4 ++-- src/Main/globals.hxx | 7 +++++++ src/Main/main.cxx | 12 ++++++++---- src/Time/tmp.cxx | 18 ------------------ src/Time/tmp.hxx | 20 -------------------- 5 files changed, 17 insertions(+), 44 deletions(-) diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 73ad21679..1b085438f 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -1457,7 +1457,7 @@ FGBFI::setCloudsASL (double cloudsASL) double FGBFI::getMagVar () { - return cur_magvar.get_magvar() * RAD_TO_DEG; + return globals->get_mag()->get_magvar() * RAD_TO_DEG; } @@ -1467,7 +1467,7 @@ FGBFI::getMagVar () double FGBFI::getMagDip () { - return cur_magvar.get_magdip() * RAD_TO_DEG; + return globals->get_mag()->get_magdip() * RAD_TO_DEG; } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 9c2f59902..ebe8a8262 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -26,6 +26,7 @@ #include +#include #include @@ -50,6 +51,9 @@ private: // Sky structures SGEphemeris *ephem; + // Magnetic Variation + SGMagVar *mag; + public: FGGlobals(); @@ -71,6 +75,9 @@ public: inline SGEphemeris *get_ephem() const { return ephem; } inline void set_ephem( SGEphemeris *e ) { ephem = e; } + + inline SGMagVar *get_mag() const { return mag; } + inline void set_mag( SGMagVar *m ) { mag = m; } }; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index ce4189d4e..57b2056eb 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -810,10 +810,10 @@ static void fgMainLoop( void ) { } // update magvar model - cur_magvar.update( cur_fdm_state->get_Longitude(), - cur_fdm_state->get_Latitude(), - cur_fdm_state->get_Altitude()* FEET_TO_METER, - globals->get_time_params()->getJD() ); + globals->get_mag()->update( cur_fdm_state->get_Longitude(), + cur_fdm_state->get_Latitude(), + cur_fdm_state->get_Altitude()* FEET_TO_METER, + globals->get_time_params()->getJD() ); // Get elapsed time (in usec) for this past frame elapsed = fgGetTimeInterval(); @@ -1428,6 +1428,10 @@ int main( int argc, char **argv ) { // thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST ); // thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS ); + // Initialize MagVar model + SGMagVar *magvar = new SGMagVar(); + globals->set_mag( magvar ); + // Terrain branch terrain = new ssgBranch; terrain->setName( "Terrain" ); diff --git a/src/Time/tmp.cxx b/src/Time/tmp.cxx index 5d7ff2d34..c8e47b413 100644 --- a/src/Time/tmp.cxx +++ b/src/Time/tmp.cxx @@ -38,24 +38,6 @@ #include "tmp.hxx" -FGMagVar::FGMagVar() { -} - -FGMagVar::~FGMagVar() { -} - - -void FGMagVar::update( double lon, double lat, double alt_m, double jd ) { - // Calculate local magnetic variation - double field[6]; - // cout << "alt_m = " << alt_m << endl; - magvar = SGMagVar( lat, lon, alt_m / 1000.0, (long)jd, field ); - magdip = atan(field[5]/sqrt(field[3]*field[3]+field[4]*field[4])); -} - -FGMagVar cur_magvar; - - // periodic time updater wrapper void fgUpdateLocalTime() { FGPath zone( current_options.get_fg_root() ); diff --git a/src/Time/tmp.hxx b/src/Time/tmp.hxx index 5bbff299e..a4f506ed6 100644 --- a/src/Time/tmp.hxx +++ b/src/Time/tmp.hxx @@ -41,25 +41,5 @@ void fgUpdateLocalTime(); // update sky and lighting parameters void fgUpdateSkyAndLightingParams(); -class FGMagVar { - -private: - - double magvar; - double magdip; - -public: - - FGMagVar(); - ~FGMagVar(); - - void update( double lon, double lat, double alt_m, double jd ); - - double get_magvar() const { return magvar; } - double get_magdip() const { return magdip; } -}; - -extern FGMagVar cur_magvar; - #endif // _LIGHT_HXX -- 2.39.5