Skip to content

Commit

Permalink
Added magnification level caching
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Aug 2, 2023
1 parent d494a89 commit 669eddd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions addons/optics/fnc_animateScriptedOptic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ if (cameraView == "GUNNER") then {
// Add magnification to zeroing control.
private _zoom = 0.25 call CBA_fnc_getFov select 1;

// To avoid flickering of the magnification text, anything above and including 0.995 is rounded to 1
if (_zoom >= 0.995) then {
_zoom = 1 max _zoom;
// To avoid flickering of the magnification text, cache magnification and only modify magnification if change is big enough
if (abs (GVAR(magnificationCache) - _zoom) <= 0.005) then {
_zoom = GVAR(magnificationCache);
} else {
if (_zoom >= 1) then {
GVAR(magnificationCache) = _zoom;
};
};

_ctrlMagnification ctrlSetText format [
Expand Down Expand Up @@ -135,10 +139,6 @@ _ctrlBodyNight ctrlSetAngle [_bank, 0.5, 0.5];
// zooming reticle
if (isNull (_display displayCtrl IDC_ENABLE_ZOOM)) exitWith {};

if (_zoom >= 1) then {
GVAR(magnificationCache) = _zoom;
};

GVAR(ReticleAdjust) set [2, _zoom];
private _reticleAdjust = linearConversion GVAR(ReticleAdjust);
private _sizeReticle = _reticleAdjust * _detailScaleFactor;
Expand Down

0 comments on commit 669eddd

Please sign in to comment.