X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWeatherCM%2FFGLocalWeatherDatabase.h;h=60063fa173bbdc7ae5fe9a04a42f9204e01f44f2;hb=7d3448294bc7486af3f4c1f0ff5c8493b03ffc90;hp=c3d5d1a3ccd26de7436e35e48f0e5f05437f6003;hpb=20f50d349f6011439ea5559a134abc7bd6a9ecf3;p=flightgear.git diff --git a/src/WeatherCM/FGLocalWeatherDatabase.h b/src/WeatherCM/FGLocalWeatherDatabase.h index c3d5d1a3c..60063fa17 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.h +++ b/src/WeatherCM/FGLocalWeatherDatabase.h @@ -60,12 +60,16 @@ HISTORY #include +#include
+ +#include +#include + #include "sphrintp.h" #include "FGPhysicalProperties.h" #include "FGPhysicalProperty.h" - #include "FGWeatherFeature.h" #include "FGWeatherDefs.h" #include "FGThunderstorm.h" @@ -90,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; @@ -188,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 */ /************************************************************************/