1
0
Fork 0

Minor FDM shell performance improvement

Don't resolve all properties at run-time.
This commit is contained in:
ThorstenB 2011-10-09 12:24:16 +02:00
parent ed30b0c9a3
commit 5b8ab277fd
2 changed files with 23 additions and 9 deletions

View file

@ -72,6 +72,16 @@ void FDMShell::init()
{ {
_props = globals->get_props(); _props = globals->get_props();
fgSetBool("/sim/fdm-initialized", false); fgSetBool("/sim/fdm-initialized", false);
_wind_north = _props->getNode("environment/wind-from-north-fps", true);
_wind_east = _props->getNode("environment/wind-from-east-fps", true);
_wind_down = _props->getNode("environment/wind-from-down-fps", true);
_control_fdm_atmo = _props->getNode("environment/params/control-fdm-atmosphere", true);
_temp_degc = _props->getNode("environment/temperature-degc", true);
_pressure_inhg = _props->getNode("environment/pressure-inhg", true);
_density_slugft = _props->getNode("environment/density-slugft3", true);
_data_logging = _props->getNode("/sim/temp/fdm-data-logging", true);
createImplementation(); createImplementation();
} }
@ -138,23 +148,23 @@ void FDMShell::update(double dt)
// pull environmental data in, since the FDMs are lazy // pull environmental data in, since the FDMs are lazy
_impl->set_Velocities_Local_Airmass( _impl->set_Velocities_Local_Airmass(
_props->getDoubleValue("environment/wind-from-north-fps", 0.0), _wind_north->getDoubleValue(),
_props->getDoubleValue("environment/wind-from-east-fps", 0.0), _wind_east->getDoubleValue(),
_props->getDoubleValue("environment/wind-from-down-fps", 0.0)); _wind_down->getDoubleValue());
if (_props->getBoolValue("environment/params/control-fdm-atmosphere")) { if (_control_fdm_atmo->getBoolValue()) {
// convert from Rankine to Celsius // convert from Rankine to Celsius
double tempDegC = _props->getDoubleValue("environment/temperature-degc"); double tempDegC = _temp_degc->getDoubleValue();
_impl->set_Static_temperature((9.0/5.0) * (tempDegC + 273.15)); _impl->set_Static_temperature((9.0/5.0) * (tempDegC + 273.15));
// convert from inHG to PSF // convert from inHG to PSF
double pressureInHg = _props->getDoubleValue("environment/pressure-inhg"); double pressureInHg = _pressure_inhg->getDoubleValue();
_impl->set_Static_pressure(pressureInHg * 70.726566); _impl->set_Static_pressure(pressureInHg * 70.726566);
// keep in slugs/ft^3 // keep in slugs/ft^3
_impl->set_Density(_props->getDoubleValue("environment/density-slugft3")); _impl->set_Density(_density_slugft->getDoubleValue());
} }
bool doLog = _props->getBoolValue("/sim/temp/fdm-data-logging", false); bool doLog = _data_logging->getBoolValue();
if (doLog != _dataLogging) { if (doLog != _dataLogging) {
_dataLogging = doLog; _dataLogging = doLog;
_impl->ToggleDataLogging(doLog); _impl->ToggleDataLogging(doLog);

View file

@ -58,8 +58,12 @@ private:
TankPropertiesList _tankProperties; TankPropertiesList _tankProperties;
FGInterface* _impl; FGInterface* _impl;
SGPropertyNode* _props; // root property tree for this FDM instance SGPropertyNode_ptr _props; // root property tree for this FDM instance
bool _dataLogging; bool _dataLogging;
SGPropertyNode_ptr _wind_north, _wind_east,_wind_down;
SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg;
SGPropertyNode_ptr _density_slugft, _data_logging;
}; };
#endif // of FG_FDM_SHELL_HXX #endif // of FG_FDM_SHELL_HXX