Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions addons/missileguidance/functions/fnc_line_onFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ private _ammoConfig = configOf _projectile;
private _p = getNumber (_ammoConfig >> QUOTE(ADDON) >> "lineGainP");
private _d = getNumber (_ammoConfig >> QUOTE(ADDON) >> "lineGainD");
if ((_p == 0) && {_d == 0}) then { WARNING_1("Ammo %1 has zero P/D",typeOf _projectile) };
private _correctionDistance = getNumber (_ammoConfig >> QUOTE(ADDON) >> "correctionDistance");

if (_correctionDistance == 0) then {
_correctionDistance = 1;
};
private _pid_x = [_p, 0, _d, 0] call CBA_pid_fnc_create;
private _pid_y = [_p, 0, _d, 0] call CBA_pid_fnc_create;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to clean these up with deleteLocation at end of pfeh?
or could cba_pid switch to hashes which should get garbage collected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I didn't realise that these wouldn't be garbage collected. It would be best for CBA to switch to hashes I think

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc acre creates thousands of these locations and there really shouldn't be any performance impact of them existing so this is a really minor thing

made a cba pr to change over to hashmaps CBATeam/CBA_A3#1811


private _navigationParams = [
_p, 0, _d,
0,
0,
_correctionDistance
_pid_x,
_pid_y
];
_navigationParams
21 changes: 3 additions & 18 deletions addons/missileguidance/functions/fnc_navigationType_line.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,19 @@ _firedEH params ["","","","","","","_projectile"];
_targetData params ["", "_targetDir", "_distance"];
_flightParams params ["_pitchRate", "_yawRate"];

_navigationParams params ["_proportionalGain", "", "_derivativeGain", "_lastErrorX", "_lastErrorY", "_correctionDistance"];
_navigationParams params ["_pid_x", "_pid_y"];
private _relativeTargetDirection = [0, (velocityModelSpace _projectile) select 1, 0] vectorAdd (_projectile vectorWorldToModelVisual (_targetDir vectorMultiply _distance));

private _angleX = ((_relativeTargetDirection select 0) atan2 (_relativeTargetDirection select 1));
private _angleY = ((_relativeTargetDirection select 2) atan2 (_relativeTargetDirection select 1));

private _pX = _proportionalGain * _angleX;
private _dX = 0;
if (_timestep > 0) then {
_dX = _derivativeGain * (_angleX - _lastErrorX) / _timestep;
};

private _pY = _proportionalGain * _angleY;
private _dY = 0;
if (_timestep > 0) then {
_dY = _derivativeGain * (_angleY - _lastErrorY) / _timestep;
};

private _accelerationX = _pX + _dX;
private _accelerationY = _pY + _dY;
private _accelerationX = [_pid_x, -_angleX] call CBA_pid_fnc_update;
private _accelerationY = [_pid_y, -_angleY] call CBA_pid_fnc_update;

private _commandedAcceleration = [
_accelerationX,
0,
_accelerationY
];

_navigationParams set [3, _angleX];
_navigationParams set [4, _angleY];

_projectile vectorModelToWorldVisual _commandedAcceleration;