1
0
Fork 0

Optimisation: avoid property name lookups

This commit is contained in:
James Turner 2020-04-01 16:20:29 +01:00
parent 4addaa9b00
commit 005ddf7c98
2 changed files with 13 additions and 25 deletions

View file

@ -326,28 +326,6 @@ getGMTString ()
return buf; return buf;
} }
/**
* Return the current heading in degrees.
*/
static double
getHeadingMag ()
{
double magheading = fgGetDouble("/orientation/heading-deg") -
fgGetDouble("/environment/magnetic-variation-deg");
return SGMiscd::normalizePeriodic(0, 360, magheading );
}
/**
* Return the current track in degrees.
*/
static double
getTrackMag ()
{
double magtrack = fgGetDouble("/orientation/track-deg") -
fgGetDouble("/environment/magnetic-variation-deg");
return SGMiscd::normalizePeriodic(0, 360, magtrack );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Tie the properties. // Tie the properties.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -439,9 +417,11 @@ FGProperties::bind ()
_tiedProperties.Tie<const char*>("/position/latitude-string", getLatitudeString); _tiedProperties.Tie<const char*>("/position/latitude-string", getLatitudeString);
_tiedProperties.Tie<const char*>("/position/longitude-string", getLongitudeString); _tiedProperties.Tie<const char*>("/position/longitude-string", getLongitudeString);
// Orientation _headingMagnetic = fgGetNode("/orientation/heading-magnetic-deg", true);
_tiedProperties.Tie<double>("/orientation/heading-magnetic-deg", getHeadingMag); _trackMagnetic = fgGetNode("/orientation/track-magnetic-deg", true);
_tiedProperties.Tie<double>("/orientation/track-magnetic-deg", getTrackMag); _magVar = fgGetNode("/environment/magnetic-variation-deg", true);
_trueHeading = fgGetNode("/orientatino/heading-deg", true);
_trueTrack = fgGetNode("/orientation/track-deg", true);
} }
void void
@ -481,6 +461,10 @@ FGProperties::update (double dt)
_rmin->setIntValue(r->tm_min); _rmin->setIntValue(r->tm_min);
_rsec->setIntValue(r->tm_sec); _rsec->setIntValue(r->tm_sec);
_rwday->setIntValue(r->tm_wday); _rwday->setIntValue(r->tm_wday);
const double magvar = _magVar->getDoubleValue();
_headingMagnetic->setDoubleValue(_trueHeading->getDoubleValue() - magvar);
_trackMagnetic->setDoubleValue(_trueTrack->getDoubleValue() - magvar);
} }

View file

@ -43,6 +43,10 @@ private:
SGPropertyNode_ptr _offset; SGPropertyNode_ptr _offset;
SGPropertyNode_ptr _uyear, _umonth, _uday, _uhour, _umin, _usec, _uwday, _udsec; SGPropertyNode_ptr _uyear, _umonth, _uday, _uhour, _umin, _usec, _uwday, _udsec;
SGPropertyNode_ptr _ryear, _rmonth, _rday, _rhour, _rmin, _rsec, _rwday, _rdsec; SGPropertyNode_ptr _ryear, _rmonth, _rday, _rhour, _rmin, _rsec, _rwday, _rdsec;
SGPropertyNode_ptr _headingMagnetic, _trackMagnetic;
SGPropertyNode_ptr _magVar;
SGPropertyNode_ptr _trueHeading, _trueTrack;
}; };