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-12 20:09:59 +00:00
#include "script_component.hpp"
2015-08-17 16:50:02 +00:00
#define VD_ZOOM_NORMAL 1.00041
2015-08-17 16:46:14 +00:00
#define VD_ZOOM_DIVISION 35
#define VD_ZOOM_DIVISION_AIR 10
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;
};
private ["_zoom"];
_zoom = (call CBA_fnc_getFov) select 1;
2015-08-17 16:46:14 +00:00
// Air
if ((vehicle ACE_player) isKindOf "Air") exitWith {
2015-08-17 16:50:02 +00:00
if (_zoom > VD_ZOOM_NORMAL) then {
2015-08-17 16:46:14 +00:00
// Dynamically set Object View Distance based on player's Zoom Level and View Distance
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 {
2015-12-21 16:05:48 +00:00
setObjectViewDistance (GVAR(fovBasedPFHminimalViewDistance) + viewDistance / 10);
2015-08-17 16:46:14 +00:00
};
TRACE_2("FoV Based",getObjectViewDistance select 0,_zoom);
};
// Land
2015-08-17 16:50:02 +00:00
if (_zoom > VD_ZOOM_NORMAL) then {
2015-08-12 20:09:59 +00:00
// Dynamically set Object View Distance based on player's Zoom Level and View Distance
2015-12-21 16:05:48 +00:00
setObjectViewDistance ((_zoom / VD_ZOOM_DIVISION * (viewDistance - GVAR(fovBasedPFHminimalViewDistance))) + GVAR(fovBasedPFHminimalViewDistance));
2015-08-12 20:09:59 +00:00
} else {
2015-12-21 16:05:48 +00:00
setObjectViewDistance GVAR(fovBasedPFHminimalViewDistance);
2015-08-12 20:09:59 +00:00
};
TRACE_2("FoV Based",getObjectViewDistance select 0,_zoom);