|
2 | 2 | from dataclasses import dataclass, field |
3 | 3 | from importlib.metadata import entry_points, EntryPoint |
4 | 4 | from typing import Generic, Any |
| 5 | +import warnings |
5 | 6 |
|
6 | 7 | from deprecated import deprecated |
7 | 8 | from typing_extensions import Union, List, Optional, TypeVar, Type |
@@ -170,39 +171,49 @@ def set_weapon_zero(self, shot: Shot, zero_distance: Union[float, Distance]) -> |
170 | 171 |
|
171 | 172 | def fire(self, shot: Shot, |
172 | 173 | trajectory_range: Union[float, Distance], |
173 | | - trajectory_step: Optional[Union[float, Distance]] = None, |
| 174 | + trajectory_step: Optional[Union[float, Distance]] = None, *, |
174 | 175 | extra_data: bool = False, |
| 176 | + dense_output: bool = False, |
175 | 177 | time_step: float = 0.0, |
| 178 | + flags: Union[TrajFlag, int] = TrajFlag.NONE, |
176 | 179 | raise_range_error: bool = True) -> HitResult: |
177 | 180 | """Calculates the trajectory for the given shot parameters. |
178 | 181 |
|
179 | 182 | Args: |
180 | | - shot (Shot): Initial shot parameters, including position and barrel angle. |
| 183 | + shot (Shot): Shot parameters, including position and barrel angle. |
181 | 184 | trajectory_range (float | Distance): Distance at which to stop computing the trajectory. |
182 | 185 | trajectory_step (float | Distance | None, optional): Distance between recorded trajectory points. |
183 | | - If 0 or None, defaults to `trajectory_range`. |
184 | | - extra_data (bool, optional): If True, requests all TrajFlags. Otherwise only requests TrajFlag.RANGE. |
185 | | - Defaults to False. |
| 186 | + If 0 or None, defaults to `trajectory_range`. |
| 187 | + extra_data (bool, optional): [DEPRECATED] Requests flags=TrajFlags.ALL |
| 188 | + and trajectory_step=PreferredUnits.distance(1). |
| 189 | + dense_output (bool, optional): HitResult stores all calculation steps so it can interpolate any point. |
186 | 190 | time_step (float, optional): Minimum time sampling interval in seconds. If > 0, data is |
187 | | - recorded at least this frequently. Defaults to 0.0. |
| 191 | + recorded at least this frequently. Defaults to 0.0. |
| 192 | + flags (TrajFlag, optional): Flags for specific points of interest. Defaults to TrajFlag.NONE. |
188 | 193 | raise_range_error (bool, optional): If True, raises RangeError if returned by integration. |
189 | 194 |
|
190 | 195 | Returns: |
191 | 196 | HitResult: Object containing computed trajectory. |
192 | 197 | """ |
193 | 198 | trajectory_range = PreferredUnits.distance(trajectory_range) |
194 | 199 | dist_step = trajectory_range |
195 | | - filter_flags = TrajFlag.RANGE |
| 200 | + filter_flags = flags |
196 | 201 | if trajectory_step: |
197 | 202 | dist_step = PreferredUnits.distance(trajectory_step) |
198 | | - filter_flags = TrajFlag.RANGE |
| 203 | + filter_flags |= TrajFlag.RANGE |
199 | 204 | if dist_step.raw_value > trajectory_range.raw_value: |
200 | 205 | dist_step = trajectory_range |
201 | 206 |
|
202 | 207 | if extra_data: |
| 208 | + warnings.warn("extra_data is deprecated and will be removed in future versions. " |
| 209 | + "Explicitly specify desired TrajectoryData frequency and flags.", |
| 210 | + DeprecationWarning |
| 211 | + ) |
| 212 | + #dist_step = PreferredUnits.distance(1.0) # << For compatibility with v2.1 |
203 | 213 | filter_flags = TrajFlag.ALL |
204 | 214 |
|
205 | | - result = self._engine_instance.integrate(shot, trajectory_range, dist_step, time_step, filter_flags) |
| 215 | + result = self._engine_instance.integrate(shot, trajectory_range, dist_step, time_step, |
| 216 | + filter_flags, dense_output=dense_output) |
206 | 217 | if result.error and raise_range_error: |
207 | 218 | raise result.error |
208 | 219 | return result |
|
0 commit comments