From 2f74e81ffe053c95cbb9c3934c7feeeacff729ed Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Wed, 15 Jun 2016 11:48:52 +0200 Subject: [PATCH] What am I doing --- addons/radar/functions/fnc_scan.sqf | 21 +++++++++++-- addons/radar/functions/fnc_scanPFH.sqf | 43 +++++++++++++++++--------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/addons/radar/functions/fnc_scan.sqf b/addons/radar/functions/fnc_scan.sqf index b541d07285..d797457d35 100644 --- a/addons/radar/functions/fnc_scan.sqf +++ b/addons/radar/functions/fnc_scan.sqf @@ -14,12 +14,27 @@ * Public: No */ #include "script_component.hpp" -params ["_aircraft", "_scanVector", "_scanConeH", "_scanConeV"]; +params ["_aircraft", "_fromToH", "_fromToV"]; +_fromToH params ["_fromH", "_toH"]; +_fromToV params ["_fromV", "_toV"]; + +private _scanConeH = _toH - _fromH; +private _scanConeV = _toH - _fromH; + +private _scanVectorH = [vectorDirVisual _aircraft, _fromH + (_scanConeH / 2)] call BIS_fnc_rotateVector2D; +private _scanVectorV = [vectorDirVisual _aircraft, _fromV + (_scanConeV / 2)] call BIS_fnc_rotateVector2D; -private _scanVectorH = _scanVector select [0, 2]; //[x, y] -private _scanVectorV = _scanVector select [1, 2]; //[y, z] private _detectedAircraft = []; +#ifdef DEBUG_MODE_FULL + private _scanVector = _scanVectorH + _scanVectorV; + drawLine3D [ + getPosATL _aircraft, + (getPosATL _aircraft) vectorAdd (_scanVector vectorMultiply 20), + [1, 0, 0, 1] + ]; +#endif + { if (_x != _aircraft && {(getPosATL _x) select 2 > 10}) then { private _dirToTarget = (getPosASL _x) vectorDiff (getPosASL _aircraft); diff --git a/addons/radar/functions/fnc_scanPFH.sqf b/addons/radar/functions/fnc_scanPFH.sqf index 81b8fa798c..42a7521198 100644 --- a/addons/radar/functions/fnc_scanPFH.sqf +++ b/addons/radar/functions/fnc_scanPFH.sqf @@ -34,8 +34,7 @@ _lastDir params ["_dirH", "_dirV"]; To simulate this we divide the base of the pyramid into rectangular areas that the beam went through between - now and the last call of the PFH. If we have an L - shaped area, we simply complete it to a rectangle. + now and the last call of the PFH. */ // First check if the cone was changed and we're outside of the cone @@ -53,28 +52,42 @@ if (_dirV < (_angleV / -2)) then { }; // 24 movement steps per second (60 deg horizontal) -private _steps = 1 max round ((CBA_time - _lastTick) * 24); +private _steps = round ((CBA_time - _lastTick) * 24); private _newDirH = _dirH; private _newDirV = _dirV; +// If the antenna has not moved yet, scan the last sector again +if (_steps == 0) then { + _steps == 1; + _dirH = [_dirH - 2.5, _dirH + 2.5] select _moveRight; + _newDirH = [_newDirH - 2.5, _newDirH + 2.5] select _moveRight; +}; + +private _detectedAircraft = []; + while {_steps > 0} do { + // Go one line lower when reaching the end of the cone + if (_newDirH <= _angleH) then { + _moveRight = !_moveRight; + _newDirV = _newDirV - 2.5; + + // If bottom of cone is reached go back to the top + if (_newDirV < (_angleV / -2)) then { + _newDirV = _angleV / 2; + }; + }; + while {_steps > 0 && {_newDirH < _angleH}} do { // Beam has an angle of 2.5 deg _newDirH = [_newDirH + 2.5, _newDirH - 2.5] select _moveRight; _steps = _steps - 1; }; - // If we still have steps to take, switch direction, go one line lower - if (_steps > 0) then { - _moveRight = !_moveRight; - _newDirV = _newDirV - 2.5; - - // If bottom of cone is reached, scan and back to the top. - if (_newDirV < (_angleV / -2)) then { - // scan here - _newDirV = _angleV / 2; - }; - }; + _detectedAircraft append ( + [_vehicle, [_dirH, _newDirH], [_dirV, _dirV + 2.5]] call FUNC(scan) + ); }; -// scan here +_args set [1, [_newDirH, _newDirV]]; +_args set [2, CBA_time]; +_args set [3, _moveRight];