mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
break out seeker angle check. more laser code cleanup.
This commit is contained in:
parent
9287d6fe44
commit
5251de8447
@ -6,7 +6,6 @@ PREP(shootRay);
|
||||
PREP(shootCone);
|
||||
PREP(checkLos);
|
||||
|
||||
PREP(findLaserDesignator);
|
||||
PREP(findStrongestRay);
|
||||
|
||||
PREP(translateToModelSpace);
|
||||
|
@ -1,74 +0,0 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_seeker", "_headingPitch", "_found", "_vectorTo", "_polarTo", "_dir", "_vertOk", "_horzOk", "_fov",
|
||||
"_closestDistance", "_pos1", "_pos2", "_disCheck", "_currentTarget", "_potentialTargets", "_offset", "_vector"];
|
||||
|
||||
_seeker = _this select 0;
|
||||
_laserCode = _this select 1;
|
||||
_fov = if (count _this > 2) then {_this select 2} else {75};
|
||||
_vector = if (count _this > 3) then {_this select 3} else {vectorDir _seeker};
|
||||
_offset = if (count _this > 4) then {_this select 4} else {[0,0,0]};
|
||||
|
||||
_headingPitch = _vector call CBA_fnc_vect2polar;
|
||||
_currentTarget = nil;
|
||||
_found = false;
|
||||
|
||||
_getPosASL = {visiblePositionASL (_this select 0)};
|
||||
|
||||
LOG("Searching lasers");
|
||||
if(!(isNil "ACE_LASERS")) then {
|
||||
_potentialTargets = [];
|
||||
TRACE_1("", ACE_LASERS);
|
||||
|
||||
{
|
||||
if(!(isNull _x)) then {
|
||||
_sensorPos = ATLtoASL(_seeker modelToWorldVisual _offset);
|
||||
_vectorTo = [_sensorPos, ([_x] call _getPosASL)] call BIS_fnc_vectorFromXToY;
|
||||
_polarTo = _vectorTo call CBA_fnc_vect2polar;
|
||||
_dir = _polarTo select 1;
|
||||
_dir = _dir - (_headingPitch select 1);
|
||||
|
||||
TRACE_4("Calc", _sensorPos, _vectorTo, _polarTo, _dir);
|
||||
|
||||
if (_dir < 0) then {_dir = _dir + 360};
|
||||
if (_dir > 360) then {_dir = _dir - 360};
|
||||
_vertOk = false;
|
||||
_horzOk = false;
|
||||
if(_dir < _fov || {_dir > (360-_fov)}) then {
|
||||
_horzOk = true;
|
||||
};
|
||||
if(abs((abs(_polarTo select 2))-(abs(_headingPitch select 2))) < _fov) then {
|
||||
_vertOk = true;
|
||||
};
|
||||
|
||||
TRACE_2("Results", _vertOk, _horzOk);
|
||||
|
||||
if(_vertOk && {_horzOk}) then {
|
||||
// Does the laser currently have our current code, if we have one?
|
||||
_targetCode = _x getVariable ["ACE_LASER_CODE", ACE_DEFAULT_LASER_CODE];
|
||||
TRACE_1("Target in sight, checking code", _targetCode, _laserCode);
|
||||
if(_targetCode == _laserCode) then {
|
||||
_potentialTargets set[(count _potentialTargets), _x];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
} forEach ACE_LASERS;
|
||||
|
||||
TRACE_1("", _potentialTargets);
|
||||
|
||||
_closestDistance = 100000;
|
||||
{
|
||||
_pos1 = (getPosASL _seeker);
|
||||
_pos2 = ([_x] call _getPosASL);
|
||||
_disCheck = _pos1 distance _pos2;
|
||||
// shouldn't this bail out when a valid target is found instead of iterating over all potential targets ?
|
||||
if(_disCheck < _closestDistance && {[_pos1, _pos2, _x, _seeker] call FUNC(checkLos)}) then {
|
||||
_found = true;
|
||||
_currentTarget = _x;
|
||||
_closestDistance = _disCheck;
|
||||
};
|
||||
} forEach _potentialTargets;
|
||||
};
|
||||
[_found, _currentTarget]
|
@ -1,5 +1,5 @@
|
||||
#include "script_component.hpp"
|
||||
#define DEBUG_MODE_FULL
|
||||
//#define DEBUG_MODE_FULL
|
||||
private ["_divergence","_pos","_vec","_longestReturn","_shortestReturn","_resultPositions","_p1","_p2","_p","_v","_cp","_vecRotateMap","_result",
|
||||
"_resultPos","_distance","_count","_pos2","_radOffset","_offset","_offsetPos","_offsetVector"];
|
||||
_divergence = 0.3;
|
||||
|
@ -3,6 +3,8 @@
|
||||
PREP(rotateVectLineGetMap);
|
||||
PREP(rotateVectLine);
|
||||
|
||||
PREP(checkSeekerAngle);
|
||||
|
||||
PREP(fired);
|
||||
|
||||
PREP(guidancePFH);
|
||||
|
50
addons/missileguidance/functions/fnc_checkSeekerAngle.sqf
Normal file
50
addons/missileguidance/functions/fnc_checkSeekerAngle.sqf
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
* Returns whether the target position is within the maximum angle FOV of the provided seeker
|
||||
* objects current direction.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Seeker [Object]
|
||||
* 1: Target [Position]
|
||||
* 2: Max Angle [Degrees]
|
||||
*
|
||||
* Return value:
|
||||
* Boolean
|
||||
*/
|
||||
|
||||
#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
private["_seeker", "_targetPos", "_seekerMaxAngle", "_vectorTo", "_sensorPos", "_vertOk", "_horzOk", "_dir", "_headingPitch"];
|
||||
|
||||
_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;
|
||||
|
||||
_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 {
|
||||
false
|
||||
};
|
||||
|
||||
true
|
@ -2,23 +2,25 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
|
||||
private["_targets", "_foundTargetPos", "_launchParams", "_seekerParams", "_targetLaunchParams"];
|
||||
|
||||
_seekerTargetPos = _this select 0;
|
||||
|
||||
_launchParams = _this select 1;
|
||||
_seekerParams = _launchParams select 3;
|
||||
|
||||
// TODO: this needs to be shootCone/findStrongestRay after testing
|
||||
//_targets = [_projectile, ACE_DEFAULT_LASER_CODE, (_seekerParams select 0)] call ace_laser_fnc_findLaserDesignator;
|
||||
//_foundTargetPos = getPosASL (_targets select 1);
|
||||
|
||||
_laserResult = [(getPosASL _projectile), [ACE_DEFAULT_WAVELENGTH,ACE_DEFAULT_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
|
||||
_laserResult = [(getPosASL _projectile), [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
|
||||
_foundTargetPos = _laserResult select 0;
|
||||
TRACE_1("Search", _laserResult);
|
||||
|
||||
// @TODO: Check angle to target from seeker head
|
||||
|
||||
if(!isNil "_foundTargetPos") then {
|
||||
_angleFov = _seekerParams select 0;
|
||||
_canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle);
|
||||
|
||||
// If we got here, it was an invalid target, just return a spot 5m in front of the missile
|
||||
if(!_canSeeTarget) then {
|
||||
_foundTargetPos = _sensorPos vectorAdd ((velocity _projectile) vectorMultiply 5);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
TRACE_1("Seeker return target pos", _foundTargetPos);
|
||||
_foundTargetPos;
|
Loading…
Reference in New Issue
Block a user