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:
* None
*
* Return Value:
* None
*
* 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:46:14 +00:00
#define DEBUG_MODE_FULL
2015-08-12 20:09:59 +00:00
#include "script_component.hpp"
2015-08-17 16:46:14 +00:00
#define VD_NORMAL_ZOOM 1.00041
#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 {
if (_zoom > VD_NORMAL_ZOOM) then {
// Dynamically set Object View Distance based on player's Zoom Level and View Distance
setObjectViewDistance ((_zoom / VD_ZOOM_DIVISION_AIR * (viewDistance - GVAR(fovBasedPFHminimalViewDistance))) + GVAR(fovBasedPFHminimalViewDistance));
} else {
setObjectViewDistance (GVAR(fovBasedPFHminimalViewDistance) + viewDistance / 10);
};
TRACE_2("FoV Based",getObjectViewDistance select 0,_zoom);
};
// Land
if (_zoom > VD_NORMAL_ZOOM) then {
2015-08-12 20:09:59 +00:00
// Dynamically set Object View Distance based on player's Zoom Level and View Distance
2015-08-17 16:46:14 +00:00
setObjectViewDistance ((_zoom / VD_ZOOM_DIVISION * (viewDistance - GVAR(fovBasedPFHminimalViewDistance))) + GVAR(fovBasedPFHminimalViewDistance));
2015-08-12 20:09:59 +00:00
} else {
setObjectViewDistance GVAR(fovBasedPFHminimalViewDistance);
};
TRACE_2("FoV Based",getObjectViewDistance select 0,_zoom);