X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWeatherCM%2FFGLocalWeatherDatabase.h;h=60063fa173bbdc7ae5fe9a04a42f9204e01f44f2;hb=7d3448294bc7486af3f4c1f0ff5c8493b03ffc90;hp=655356aeb7349c75416b466b30cfb843fe0626af;hpb=4a40bb1151a8a5fe9fae21e07a866a5cf7cd2d26;p=flightgear.git diff --git a/src/WeatherCM/FGLocalWeatherDatabase.h b/src/WeatherCM/FGLocalWeatherDatabase.h index 655356aeb..60063fa17 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.h +++ b/src/WeatherCM/FGLocalWeatherDatabase.h @@ -60,8 +60,10 @@ HISTORY #include -#include +#include
+ #include +#include #include "sphrintp.h" @@ -92,11 +94,33 @@ struct _FGLocalWeatherDatabaseCache FGPhysicalProperty last_known_property; }; -class FGLocalWeatherDatabase +class FGLocalWeatherDatabase : public FGSubsystem { private: protected: - SphereInterpolate *database; + SphereInterpolate *database_logic; + vector database_data; +#ifndef macintosh + FGPhysicalProperties DatabaseEvaluate(const sgVec2& p) const + { + sgVec2 p_converted = {p[0]*(SGD_2PI/360.0), + p[1]*(SGD_2PI/360.0)}; + EvaluateData d = database_logic->Evaluate(p_converted); + return database_data[d.index[0]]*d.percentage[0] + + database_data[d.index[1]]*d.percentage[1] + + database_data[d.index[2]]*d.percentage[2] ; + } +#endif + FGPhysicalProperties DatabaseEvaluate(const sgVec3& p) const + { + sgVec3 p_converted = {p[0]*(SGD_2PI/360.0), + p[1]*(SGD_2PI/360.0), + p[2] }; + EvaluateData d = database_logic->Evaluate(p_converted); + return database_data[d.index[0]]*d.percentage[0] + + database_data[d.index[1]]*d.percentage[1] + + database_data[d.index[2]]*d.percentage[2] ; + } typedef vector pointVector; typedef vector tileVector; @@ -190,6 +214,14 @@ public: void update(const sgVec3& p); //position has changed void update(const sgVec3& p, const WeatherPrecision dt); //time and/or position has changed + /************************************************************************/ + /* define methods requited for FGSubsystem */ + /************************************************************************/ + virtual void init () { /* do nothing; that's done in the constructor */ }; + virtual void bind (); + virtual void unbind (); + virtual void update (int dt) { update((float) dt); }; + /************************************************************************/ /* Get the physical properties on the specified point p */ /************************************************************************/