mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
FOV check made faster.
This commit is contained in:
parent
dc5028275a
commit
4c74ff8717
@ -11,39 +11,20 @@
|
||||
* Return value:
|
||||
* Boolean
|
||||
*/
|
||||
|
||||
#define DEBUG_MODE_FULL
|
||||
|
||||
#include "script_component.hpp"
|
||||
private["_seeker", "_targetPos", "_seekerMaxAngle", "_vectorTo", "_sensorPos", "_vertOk", "_horzOk", "_dir", "_headingPitch"];
|
||||
private["_seeker", "_targetPos", "_seekerMaxAngle", "_sensorPos", "_testPointVector", "_testDotProduct"];
|
||||
|
||||
_seeker = _this select 0;
|
||||
_targetPos = _this select 1;
|
||||
_seekerMaxAngle = _this select 2;
|
||||
|
||||
_vertOk = false;
|
||||
_horzOk = false;
|
||||
|
||||
_sensorPos = getPosASL _seeker;
|
||||
_vectorTo = _sensorPos vectorFromTo _targetPos;
|
||||
|
||||
_headingPitch = (vectorDir _seeker) call CBA_fnc_vect2polar;
|
||||
_polarTo = _vectorTo call CBA_fnc_vect2polar;
|
||||
_testPointVector = vectorNormalized (_targetPos vectorDiff _sensorPos);
|
||||
_testDotProduct = (vectorNormalized (velocity _seeker)) vectorDotProduct _testPointVector;
|
||||
|
||||
_dir = _polarTo select 1;
|
||||
_dir = _dir - (_headingPitch select 1);
|
||||
|
||||
if (_dir < 0) then {_dir = _dir + 360};
|
||||
if (_dir > 360) then {_dir = _dir - 360};
|
||||
_vertOk = false;
|
||||
_horzOk = false;
|
||||
if(_dir < _angleFov || {_dir > (360-_angleFov)}) then {
|
||||
_horzOk = true;
|
||||
};
|
||||
if(abs((abs(_polarTo select 2))-(abs(_headingPitch select 2))) < _angleFov) then {
|
||||
_vertOk = true;
|
||||
};
|
||||
|
||||
if(!_vertOk || !_horzOk ) exitWith {
|
||||
if(_testDotProduct < (cos _seekerMaxAngle) exitWith {
|
||||
false
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user