2023-09-12 18:58:10 +00:00
#include "..\script_component.hpp"
2015-08-12 20:09:59 +00:00
/*
* Author: Jonpas
* Sets Object View Distance dynamically based on current Field of View, between Object View Distance (minimal value) and View Distance (maximum value) set before this PFH starts.
*
* Arguments:
2015-08-22 20:26:04 +00:00
* 0: PFH Arguments <ARRAY>
* 1: PFH Handle <NUMBER>
2015-08-12 20:09:59 +00:00
*
* Return Value:
2015-08-22 20:26:04 +00:00
* PFH Handle <NUMBER>
2015-08-12 20:09:59 +00:00
*
* Example:
2015-08-17 16:22:03 +00:00
* [] call ace_viewdistance_fnc_setFovBasedOvdPFH
2015-08-12 20:09:59 +00:00
*
* Public: No
*/
2015-08-17 16:50:02 +00:00
2015-08-17 16:22:03 +00:00
params ["", "_idPFH"];
2015-08-12 20:09:59 +00:00
// Remove PFH and set Object View Distance back to what it was before
if (GVAR(objectViewDistanceCoeff) < 6) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
GVAR(fovBasedPFHminimalViewDistance) = nil;
};
2018-07-31 22:36:22 +00:00
private _zoom = ([] call CBA_fnc_getFov) select 1;
2015-08-12 20:09:59 +00:00
2016-04-14 11:52:20 +00:00
if (_zoom > VD_ZOOM_NORMAL) then {
// Dynamically set Object View Distance based on player's Zoom Level and View Distance
if ((vehicle ACE_player) isKindOf "Air") then {
2015-12-21 16:05:48 +00:00
setObjectViewDistance ((_zoom / VD_ZOOM_DIVISION_AIR * (viewDistance - GVAR(fovBasedPFHminimalViewDistance))) + GVAR(fovBasedPFHminimalViewDistance));
2015-08-17 16:46:14 +00:00
} else {
2016-04-14 11:52:20 +00:00
setObjectViewDistance ((_zoom / VD_ZOOM_DIVISION * (viewDistance - GVAR(fovBasedPFHminimalViewDistance))) + GVAR(fovBasedPFHminimalViewDistance));
2015-08-17 16:46:14 +00:00
};
2015-08-12 20:09:59 +00:00
} else {
2016-04-14 11:52:20 +00:00
if ((vehicle ACE_player) isKindOf "Air") then {
setObjectViewDistance (GVAR(fovBasedPFHminimalViewDistance) + viewDistance / 10);
} else {
setObjectViewDistance GVAR(fovBasedPFHminimalViewDistance);
};
2015-08-12 20:09:59 +00:00
};
TRACE_2("FoV Based",getObjectViewDistance select 0,_zoom);