mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Tweak how targets are acquired. Fix velocity calculation
This commit is contained in:
parent
e91b8bc2df
commit
becc9d24ff
@ -16,10 +16,19 @@
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#define CHECK_DISTANCE 25
|
||||
params ["_origin", "_direction", "_designateInput", "_seekerTargetPos", ["_ignoreObject", objNull]];
|
||||
|
||||
scopeName "main";
|
||||
private _nearObjects = [];
|
||||
|
||||
if (cursorObject isKindOf "AllVehicles") then {
|
||||
private _intersectionsToCursorTarget = lineIntersectsSurfaces [_origin, aimPos cursorObject, _ignoreObject, cursorObject, true, 1];
|
||||
if (_intersectionsToCursorTarget isEqualTo []) then {
|
||||
_nearObjects pushBack cursorObject;
|
||||
};
|
||||
};
|
||||
|
||||
private _intersections = lineIntersectsSurfaces [_origin, _origin vectorAdd (_direction vectorMultiply 5000), _ignoreObject, objNull, true, 1, "FIRE", "VIEW", true];
|
||||
if (_intersections isNotEqualTo []) then {
|
||||
(_intersections#0) params ["_intersectPos", "", "_object"];
|
||||
@ -42,32 +51,41 @@ if (_nearObjects isNotEqualTo []) then {
|
||||
private _averagePosition = _seekerTargetPos vectorMultiply 15;
|
||||
private _averagePositionCounter = 15;
|
||||
|
||||
private _closestObject = objNull;
|
||||
private _highestMagnitude = 0;
|
||||
private _closestDistance = 1e10;
|
||||
|
||||
private _bestScore = 0;
|
||||
private _bestObject = objNull;
|
||||
|
||||
{
|
||||
if ((getPosASLVisual _x) vectorDistanceSqr _seekerTargetPos < _closestDistance) then {
|
||||
_closestDistance = (getPosASLVisual _x) vectorDistanceSqr _seekerTargetPos;
|
||||
_closestObject = _x;
|
||||
private _tiMagnitude = (vectorMagnitude getVehicleTIPars _x) / 1.74; // 1.74 = sqrt(3) = max magnitude of [1, 1, 1]
|
||||
private _distance = (getPosASLVisual _x) vectorDistanceSqr _seekerTargetPos;
|
||||
|
||||
if (_distance <= CHECK_DISTANCE * CHECK_DISTANCE) then {
|
||||
private _score = 8 * _tiMagnitude + (_distance / (CHECK_DISTANCE * CHECK_DISTANCE));
|
||||
if (_score > _bestScore) then {
|
||||
_bestScore = _score;
|
||||
_bestObject = _x;
|
||||
};
|
||||
};
|
||||
} forEach _nearObjects;
|
||||
|
||||
private _boundingBox = 0 boundingBoxReal _closestObject;
|
||||
private _boundingBox = 0 boundingBoxReal _bestObject;
|
||||
|
||||
// Project target bounding box onto screen and do a real bad edge detection check
|
||||
_boundingBox params ["_min", "_max"];
|
||||
_min params ["_x0", "_y0", "_z0"];
|
||||
_max params ["_x1", "_y1", "_z1"];
|
||||
|
||||
private _utl = _closestObject modelToWorldVisualWorld [_x0, _y0, _z0];
|
||||
private _utr = _closestObject modelToWorldVisualWorld [_x1, _y0, _z0];
|
||||
private _ubr = _closestObject modelToWorldVisualWorld [_x1, _y1, _z0];
|
||||
private _ubl = _closestObject modelToWorldVisualWorld [_x0, _y1, _z0];
|
||||
private _utl = _bestObject modelToWorldVisualWorld [_x0, _y0, _z0];
|
||||
private _utr = _bestObject modelToWorldVisualWorld [_x1, _y0, _z0];
|
||||
private _ubr = _bestObject modelToWorldVisualWorld [_x1, _y1, _z0];
|
||||
private _ubl = _bestObject modelToWorldVisualWorld [_x0, _y1, _z0];
|
||||
|
||||
private _dtl = _closestObject modelToWorldVisualWorld [_x0, _y0, _z1];
|
||||
private _dtr = _closestObject modelToWorldVisualWorld [_x1, _y0, _z1];
|
||||
private _dbr = _closestObject modelToWorldVisualWorld [_x1, _y1, _z1];
|
||||
private _dbl = _closestObject modelToWorldVisualWorld [_x0, _y1, _z1];
|
||||
private _dtl = _bestObject modelToWorldVisualWorld [_x0, _y0, _z1];
|
||||
private _dtr = _bestObject modelToWorldVisualWorld [_x1, _y0, _z1];
|
||||
private _dbr = _bestObject modelToWorldVisualWorld [_x1, _y1, _z1];
|
||||
private _dbl = _bestObject modelToWorldVisualWorld [_x0, _y1, _z1];
|
||||
|
||||
{
|
||||
private _intersections = lineIntersectsSurfaces [_origin, _x, _ignoreObject, objNull, false, 16];
|
||||
|
@ -42,8 +42,7 @@ if ((_seekerTargetPos isNotEqualTo [0, 0, 0]) || { (_designateInput == 1) }) the
|
||||
_cameraNamespace setVariable [QGVAR(seekerTargetPos), _seekerTargetPos];
|
||||
_cameraNamespace setVariable [QGVAR(seekerTargetInfo), _seekerTargetInfo];
|
||||
|
||||
private _velocity = [0, 0, 0];
|
||||
_seekerStateParams params [["_lastPositions", []], ["_lastAveragePosition", [0, 0, 0]]];
|
||||
_seekerStateParams params [["_lastPositions", []], ["_lastAveragePosition", [0, 0, 0]], ["_velocity", [0, 0, 0]], ["_lastTimeCalculated", 0]];
|
||||
if (5 < count _lastPositions) then {
|
||||
private _averagePosition = [0, 0, 0];
|
||||
{
|
||||
@ -53,10 +52,12 @@ if (5 < count _lastPositions) then {
|
||||
_averagePosition = _averagePosition vectorMultiply (1 / count _lastPositions);
|
||||
|
||||
if (_lastAveragePosition isNotEqualTo [0, 0, 0]) then {
|
||||
if (_timestep == 0) then {
|
||||
private _dt = CBA_missionTime - _lastTimeCalculated;
|
||||
if (_dt == 0) then {
|
||||
_velocity = [0, 0, 0];
|
||||
} else {
|
||||
_velocity = (_averagePosition vectorDiff _lastAveragePosition) vectorMultiply (1 / _timestep);
|
||||
_velocity = (_averagePosition vectorDiff _lastAveragePosition) vectorMultiply (1 / _dt);
|
||||
_seekerStateParams set [3, CBA_missionTime];
|
||||
}
|
||||
};
|
||||
_seekerStateParams set [1, _averagePosition];
|
||||
@ -69,6 +70,7 @@ _targetData set [3, _velocity];
|
||||
|
||||
_lastPositions pushBack _seekerTargetPos;
|
||||
_seekerStateParams set [0, _lastPositions];
|
||||
_seekerStateParams set [2, _velocity];
|
||||
|
||||
_seekerTargetPos
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user