1
0
Fork 0

Pull Ephemeris out of FGGlobals

This commit is contained in:
James Turner 2015-12-30 23:11:06 -06:00
parent ebc10ee44f
commit ba56c42eb4
6 changed files with 37 additions and 24 deletions

View file

@ -41,7 +41,11 @@ Ephemeris::Ephemeris() :
Ephemeris::~Ephemeris()
{
delete _impl;
}
SGEphemeris* Ephemeris::data()
{
return _impl;
}
void Ephemeris::init()
@ -49,21 +53,26 @@ void Ephemeris::init()
SGPath ephem_data_path(globals->get_fg_root());
ephem_data_path.append("Astro");
_impl = new SGEphemeris(ephem_data_path.c_str());
globals->set_ephem(_impl);
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
tieStar("/ephemeris/sun/ze", _impl->get_sun(), &Star::getze);
tieStar("/ephemeris/sun/ye", _impl->get_sun(), &Star::getye);
tieStar("/ephemeris/sun/lat-deg", _impl->get_sun(), &Star::getLat);
_latProp = fgGetNode("/position/latitude-deg", true);
update(0.0);
_latProp = fgGetNode("/position/latitude-deg", true);
update(0.0);
}
void Ephemeris::shutdown()
{
delete _impl;
_impl = NULL;
}
void Ephemeris::postinit()
{
}
void Ephemeris::bind()
@ -72,10 +81,11 @@ void Ephemeris::bind()
void Ephemeris::unbind()
{
_latProp = 0;
}
void Ephemeris::update(double)
{
SGTime* st = globals->get_time_params();
_impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());
SGTime* st = globals->get_time_params();
_impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());
}

View file

@ -42,8 +42,12 @@ public:
virtual void unbind();
virtual void update(double dt);
virtual void init();
virtual void postinit();
virtual void shutdown();
virtual void postinit();
static const char* subsystemName() { return "ephemeris"; }
SGEphemeris* data();
private:
SGEphemeris* _impl;
SGPropertyNode* _latProp;

View file

@ -762,7 +762,7 @@ void fgCreateSubsystems(bool duringReset) {
// Initialize the weather modeling subsystem
globals->add_subsystem("environment", new FGEnvironmentMgr);
globals->add_subsystem("ephemeris", new Ephemeris);
globals->add_new_subsystem<Ephemeris>();
////////////////////////////////////////////////////////////////////
// Initialize the aircraft systems and instrumentation (before the

View file

@ -157,7 +157,6 @@ FGGlobals::FGGlobals() :
fg_root( "" ),
fg_home( "" ),
time_params( NULL ),
ephem( NULL ),
commands( SGCommandMgr::instance() ),
channel_options_list( NULL ),
initial_waypoints( NULL ),

View file

@ -46,7 +46,6 @@ typedef std::vector<SGPath> PathList;
// pointers, we don't need to know anything about the class details
// anyway.
class SGEphemeris;
class SGCommandMgr;
class SGMaterialLib;
class SGPropertyNode;
@ -114,9 +113,6 @@ private:
// Time structure
SGTime *time_params;
// Sky structures
SGEphemeris *ephem;
// Material properties library
SGSharedPtr<SGMaterialLib> matlib;
@ -289,9 +285,6 @@ public:
inline SGTime *get_time_params() const { return time_params; }
inline void set_time_params( SGTime *t ) { time_params = t; }
inline SGEphemeris *get_ephem() const { return ephem; }
inline void set_ephem( SGEphemeris *e ) { ephem = e; }
inline SGMaterialLib *get_matlib() const { return matlib; }
void set_matlib( SGMaterialLib *m );

View file

@ -102,6 +102,7 @@
#include <Instrumentation/HUD/HUD.hxx>
#include <Environment/precipitation_mgr.hxx>
#include <Environment/environment_mgr.hxx>
#include <Environment/ephemeris.hxx>
//#include <Main/main.hxx>
#include "viewer.hxx"
@ -1448,7 +1449,10 @@ FGRenderer::setupView( void )
setupRoot();
// build the sky
// build the sky
Ephemeris* ephemerisSub = globals->get_subsystem<Ephemeris>();
// The sun and moon diameters are scaled down numbers of the
// actual diameters. This was needed to fit both the sun and the
// moon within the distance to the far clip plane.
@ -1459,7 +1463,7 @@ FGRenderer::setupView( void )
opt->setPropertyNode(globals->get_props());
_sky->build( 80000.0, 80000.0,
463.3, 361.8,
*globals->get_ephem(),
*ephemerisSub->data(),
fgGetNode("/environment", true),
opt.get());
@ -1685,6 +1689,8 @@ FGRenderer::updateSky()
} else {
sun_horiz_eff = moon_horiz_eff = 1.0;
}
SGSkyState sstate;
sstate.pos = globals->get_current_view()->getViewPosition();
@ -1703,10 +1709,11 @@ FGRenderer::updateSky()
scolor.cloud_color = SGVec3f(l->cloud_color().data());
scolor.sun_angle = l->get_sun_angle();
scolor.moon_angle = l->get_moon_angle();
Ephemeris* ephemerisSub = globals->get_subsystem<Ephemeris>();
double delta_time_sec = _sim_delta_sec->getDoubleValue();
_sky->reposition( sstate, *globals->get_ephem(), delta_time_sec );
_sky->repaint( scolor, *globals->get_ephem() );
_sky->reposition( sstate, *ephemerisSub->data(), delta_time_sec );
_sky->repaint( scolor, *ephemerisSub->data() );
}
void