16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 04:19:19 +02:00

build 180622. time zone bias calculation fix, track events fix, passenger stop distance calculation fix

This commit is contained in:
tmj-fstate
2018-06-22 18:24:48 +02:00
parent c0bf973c58
commit c40d0abcf9
9 changed files with 79 additions and 45 deletions

32
sun.cpp
View File

@@ -21,34 +21,17 @@ cSun::~cSun() { gluDeleteQuadric( sunsphere ); }
void
cSun::init() {
m_observer.timezone = -1.0 * simulation::Time.zone_bias();
sunsphere = gluNewQuadric();
gluQuadricNormals( sunsphere, GLU_SMOOTH );
// calculate and set timezone for the current date of the simulation
// TODO: timezone dependant on geographic location
TIME_ZONE_INFORMATION timezoneinfo;
::GetTimeZoneInformation( &timezoneinfo );
// account for potential daylight/normal time bias
// NOTE: we're using xp-compatible time zone information and current year, instead of 'historically proper' values
auto zonebias { timezoneinfo.Bias };
auto const year { simulation::Time.data().wYear };
auto const yearday { simulation::Time.year_day() };
if( yearday < simulation::Time.year_day( timezoneinfo.DaylightDate.wDay, timezoneinfo.DaylightDate.wMonth, year ) ) {
zonebias += timezoneinfo.StandardBias;
}
else if( yearday < simulation::Time.year_day( timezoneinfo.StandardDate.wDay, timezoneinfo.StandardDate.wMonth, year ) ) {
zonebias += timezoneinfo.DaylightBias;
}
else {
zonebias += timezoneinfo.StandardBias;
}
m_observer.timezone = -zonebias / 60.0f;
}
void
cSun::update() {
m_observer.temp = Global.AirTemperature;
move();
glm::vec3 position( 0.f, 0.f, -1.f );
position = glm::rotateX( position, glm::radians( static_cast<float>( m_body.elevref ) ) );
@@ -141,7 +124,7 @@ void cSun::move() {
if( m_observer.minute >= 0 ) { localtime.wMinute = m_observer.minute; }
if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; }
double ut =
double localut =
localtime.wHour
+ localtime.wMinute / 60.0 // too low resolution, noticeable skips
+ localtime.wSecond / 3600.0; // good enough in normal circumstances
@@ -154,11 +137,10 @@ void cSun::move() {
+ 275 * localtime.wMonth / 9
+ localtime.wDay
- 730530
+ ( ut / 24.0 );
+ ( localut / 24.0 );
// Universal Coordinated (Greenwich standard) time
m_observer.utime = ut * 3600.0;
m_observer.utime = m_observer.utime / 3600.0 - m_observer.timezone;
m_observer.utime = localut - m_observer.timezone;
// perihelion longitude
m_body.phlong = 282.9404 + 4.70935e-5 * daynumber; // w
// orbit eccentricity