Skip to content

Commit

Permalink
Improve Performance from updateTrajectoryPFH in Winddeflection (#7700)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokoho48 authored Jun 13, 2020
1 parent 6a59bf2 commit 3a13dd4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions addons/winddeflection/functions/fnc_updateTrajectoryPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
_args set [0, CBA_missionTime];
private _isWind = (vectorMagnitude wind > 0);

private _deleted = false;
{
_x params ["_bullet", "_airFriction"];

private _bulletVelocity = velocity _bullet;
private _bulletSpeedSqr = vectorMagnitudeSqr _bulletVelocity;

if ((!alive _bullet) || {(_bullet isKindOf "BulletBase") && {_bulletSpeedSqr < 10000}}) then {
GVAR(trackedBullets) deleteAt (GVAR(trackedBullets) find _x);
GVAR(trackedBullets) set [_forEachIndex, objNull];
_deleted = true;
} else {
if (_isWind) then {
private _trueVelocity = _bulletVelocity vectorDiff wind;
Expand All @@ -48,7 +50,11 @@
};
_bullet setVelocity _bulletVelocity;
};
nil
} count +GVAR(trackedBullets);
} forEach GVAR(trackedBullets);

if (_deleted) then {
GVAR(trackedBullets) = GVAR(trackedBullets) - [objNull];
};

// END_COUNTER(pfeh);
}, GVAR(simulationInterval), [CBA_missionTime]] call CBA_fnc_addPerFrameHandler;

0 comments on commit 3a13dd4

Please sign in to comment.