Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ProjectileWindData.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true)]
3{
4 [Attribute("1", desc: "Init Speed Coef", params: "0 inf 0.01")]
5 protected float m_fInitSpeedCoef;
6
7 [Attribute("10", desc: "Speed of the wind")]
8 protected float m_fWindSpeed;
9
10 // two seprate arrays will keep the overall file size smaller than using something like ref array<ref Wrapper<TFloatArray>>, while stil being possible to be viewed in workbench
11
15 [Attribute(defvalue: "", desc: "Firing solution\n[X] elevation angle in radians\n[Y] horizontal distance to impact position\n[Z] peak altitude")]
17
21 [Attribute(defvalue: "", desc: "Data.\n[X] azimuth correction in milliradians for perpendicular wind\n[Y] difference between point of impact with parallel wind\n[Z] agle at which projectile has impacted the surface")]
22 protected ref TVectorArray m_aValues;
23
24 //------------------------------------------------------------------------------------------------
27 {
28 return m_fInitSpeedCoef;
29 }
30
31 //------------------------------------------------------------------------------------------------
34 {
35 return m_fWindSpeed;
36 }
37
38 //------------------------------------------------------------------------------------------------
47 array<float> GetDataByAngle(float angle)
48 {
49 if (angle <= 0 || angle > 90)
50 return null;
51
52 int lowId;
53 if (angle < m_aFiringSolution[lowId][0])
54 return null;
55
56 int highId = m_aFiringSolution.Count() - 1;
57 if (angle > m_aFiringSolution[highId][0])
58 return null;
59
60 int midId;
61 vector first;
62 vector second;
63 while (lowId < highId)
64 {
65 midId = (lowId + highId) * 0.5;
66
67 first = m_aFiringSolution[midId - 1];
68 second = m_aFiringSolution[midId];
69
70 if (first[0] > angle)
71 highId = --midId;
72 else if (second[0] <= angle)
73 lowId = ++midId;
74 else
75 break;
76 }
77
78 float t = Math.InverseLerp(first[0], second[0], angle);
79 vector fireSolutionOut = vector.Lerp(first, second, t);
80 vector valuesOut = vector.Lerp(m_aValues[midId-1], m_aValues[midId], t);
81 array<float> output = {
82 fireSolutionOut[0], // angle
83 fireSolutionOut[1], // distance
84 fireSolutionOut[2], // peak distance
85 valuesOut[0], // azimuth correction for perpendicular wind
86 valuesOut[1], // distance difference due to parallel wind
87 valuesOut[2] // peak altitude
88 };
89
90 return output;
91 }
92
93 //------------------------------------------------------------------------------------------------
103 array<float> GetDataByDisance(float distance, bool directFire)
104 {
105 if (distance < 0)
106 return null;
107
108 if (!m_aValues || m_aValues.IsEmpty())
109 return null;
110
111 int highId = m_aValues.Count() - 1;
112 if (highId != 89) // we expect this to have 90 entries
113 return null;
114
115 int lowId;
116 if (directFire)
117 {
118 highId = 44;
119 if (distance < m_aFiringSolution[lowId][1])
120 return null;
121
122 if (distance > m_aFiringSolution[highId][1])
123 return null;
124 }
125 else
126 {
127 lowId = 44;
128 if (distance > m_aFiringSolution[lowId][1])
129 return null;
130
131 if (distance < m_aFiringSolution[highId][1])
132 return null;
133 }
134
135 int midId;
136 vector first;
137 vector second;
138
139 while (lowId < highId)
140 {
141 midId = (lowId + highId) * 0.5;
142
143 first = m_aFiringSolution[midId - 1];
144 second = m_aFiringSolution[midId];
145
146 if (directFire)
147 {
148 if (first[1] > distance)
149 highId = --midId;
150 else if (second[1] <= distance)
151 lowId = ++midId;
152 else
153 break;
154 }
155 else
156 {
157 if (first[1] <= distance)
158 highId = --midId;
159 else if (second[1] > distance)
160 lowId = ++midId;
161 else
162 break;
163 }
164 }
165
166 float t = Math.InverseLerp(first[1], second[1], distance);
167 vector fireSolutionOut = vector.Lerp(first, second, t);
168 vector valuesOut = vector.Lerp(m_aValues[midId-1], m_aValues[midId], t);
169 array<float> output = {
170 fireSolutionOut[0], // angle
171 fireSolutionOut[1], // distance
172 fireSolutionOut[2], // peak distance
173 valuesOut[0], // azimuth correction for perpendicular wind
174 valuesOut[1], // distance difference due to parallel wind
175 valuesOut[2] // peak altitude
176 };
177
178 return output;
179 }
180
181 //------------------------------------------------------------------------------------------------
182 // constructor
187 void SCR_ProjectileWindData(float initSpeedCoef, float windSpeed, notnull TVectorArray values, notnull TVectorArray firingSolutions)
188 {
189 if (!values || !firingSolutions || values.Count() != firingSolutions.Count())
190 return;
191
192 m_fInitSpeedCoef = initSpeedCoef;
193 m_fWindSpeed = windSpeed;
194 m_aValues = values;
195 m_aFiringSolution = firingSolutions;
196 }
197}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
float distance
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
array< float > GetDataByAngle(float angle)
void SCR_ProjectileWindData(float initSpeedCoef, float windSpeed, notnull TVectorArray values, notnull TVectorArray firingSolutions)
array< float > GetDataByDisance(float distance, bool directFire)
SCR_FieldOfViewSettings Attribute
array< vector > TVectorArray
Definition Types.c:392