1#pragma once
2
3static void CheckGridTurbulence(
Viewscreen& view,
grid& terrain, Receiver& receiver, Network& network)
4{
9 auto full=Packet(true,{1019,1019},0,1000,0,7);
10 for(int i=0;i<4096;++i) full[17+i*12+1]=51;
11 const unsigned char values[]{0,64,128,255};
12 for(int q=0;q<2;++q)for(int r=0;r<2;++r)
13 full[17+((31+q)*64+31+r)*12+1]=values[q*2+r];
17 && Near(local.
turbulence,91.8125f/255.f,.000001f),
18 "turbulence byte normalization or unequal bilinear weights changed");
21 "zero/full turbulence endpoints are not preserved");
22 auto position=[&](float u,float v,float altitude) {
25 };
26 position(1019.25f,1019.75f,.4f);
27 const float expected=91.8125f/255.f;
30 Check(Near(
weather.
GetTurbulence(),expected,.00001f),
"turbulence incorrectly requires loaded terrain");
34
35
39 for(float speed:{0.f,.25f,4.5f}) {
43 }
45 receiver.Receive(Weather1Packet(0,0));receiver.Receive(Weather1Packet(252));
47 position(1020,1019,.4f);
49
50 auto global=std::make_shared<CloudWeather::Map>();
51 global->mips.push_back({8,4,std::vector<uint8_t>(32,204)});
52 network.cloudWeather.latest=global;
53 position(1019.25f,1019.75f,.4f);
55
56
57 for(bool above:{false,true}) {
59 for(float altitude:{9.499f,9.5f,9.501f,10.f,16.f,22.f,9.501f,9.5f,9.499f}) {
60 position(1019.25f,1019.75f,altitude);
62 "turbulence source ignored the 9.5 km MSL boundary");
63 }
64 }
66 auto missing=full;missing[17+(31*64+32)*12]=0;
73 position(1200,1019,.4f);
75
79 "ascent lost turbulence with suspended local grid");
80 for(float altitude:{10.1f,30.f,62.999f,63.f,80.f,150.f,62.999f,30.f,9.7f}) {
81 position(1019.25f,1019.75f,altitude);
85 "atmospheric/suborbital/orbital/re-entry turbulence envelope changed");
87 "space retained gust energy for re-entry");
88 }
94 "fresh descent fixture rejected current request token");
97 weather.FrameTurbulenceReset();receiver.Receive(Weather1Packet(0,0));receiver.Receive(Weather1Packet(252));
99 "simulator retained turbulence or gust memory");
102 "simulator exit replayed gust memory or failed to resume current weather");
105 "reposition retained gust memory or old local generation");
106
107
108
109 for(int i=0;i<32;++i)global->mips[0].pixels[i]=static_cast<uint8_t>(i*7);
111 for(int x=0;x<8;++x)for(int y=0;y<4;++y) {
116 Check(
Near(
weather.
GetTurbulence(),(y*8+x)*7.f/255,.00001f),
"global turbulence has wrong hemisphere or orientation");
117 }
120 position(1019,1019,.4f);
playerships[0].
mslKm=std::numeric_limits<float>::quiet_NaN();
122 position(1019,1019,.4f);network.cloudWeather.latest.reset();
125}
bool Interpolate(unsigned cube, double u, double v, uint16_t token, LocalSample &result) const
RiseMath::Matrix matrixLook
float GetTurbulence() const
void QueuePlotWeatherReset()
uint16_t weatherRequestToken
void ResetPlotWeatherConnection()
void UpdatePlotWeatherConditions()
PlotWeather::Store plotWeather
s_network_objects playerships[MAX_SCAN]
bool Near(const Body &b, const Triangle &t, double extra)
RiseMath::Vector3 position
RiseMath::Vector3 velocity