From a2c06c58fb445580aadc358c24cb2eb1ea91fa97 Mon Sep 17 00:00:00 2001 From: Bismarck Date: Sat, 5 Jun 2021 14:28:31 -0500 Subject: [PATCH] Fixed LIS checks in fast moving vehicles behaving unexpectedly (#195) * Changed LIS check away from sim time scope `positionCameraToWorld` to imperfect render time scope method; closes https://github.com/diwako/diwako_dui/issues/194 * Got rid of unnecessary creation of `_endPos` var * Changed `_pos` and `eyePos` checks from simulation time scope to visual time scope, moved `_pos` directly into `checkVisibility` statement as it's not needed in the function otherwise --- addons/nametags/functions/fnc_calculateFadeValue.sqf | 6 ++++-- addons/nametags/functions/fnc_onDraw.sqf | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/nametags/functions/fnc_calculateFadeValue.sqf b/addons/nametags/functions/fnc_calculateFadeValue.sqf index bde39a6..9332582 100644 --- a/addons/nametags/functions/fnc_calculateFadeValue.sqf +++ b/addons/nametags/functions/fnc_calculateFadeValue.sqf @@ -3,7 +3,6 @@ params ["_target", "_player"]; private _vehicle = vehicle _target; private _distance = _player distance _vehicle; -private _pos = _vehicle modelToWorld [0,0,1.4]; private _darknessPenalty = 0; private _rangeModifier = 0; @@ -38,7 +37,10 @@ if (GVAR(enableFOVBoost)) then { private _fadeValue = (linearConversion [0, (_maxDistance * _rangeModifier), _distance, 1, 0, true]) - _darknessPenalty; if (GVAR(enableOcclusion)) then { - _fadeValue = _fadeValue - ([objNull, "FIRE"] checkVisibility [eyePos _player, _pos]); + _fadeValue = _fadeValue - ([objNull, "FIRE"] checkVisibility [ + _player modelToWorldVisualWorld (_player selectionPosition "pilot"), + _vehicle modelToWorldVisual [0,0,1.4] + ]); }; // this function allows Mission Builders to implement there own coefs diff --git a/addons/nametags/functions/fnc_onDraw.sqf b/addons/nametags/functions/fnc_onDraw.sqf index 4257091..76116cd 100644 --- a/addons/nametags/functions/fnc_onDraw.sqf +++ b/addons/nametags/functions/fnc_onDraw.sqf @@ -16,9 +16,14 @@ if (GVAR(useLIS)) then { // unit, per the comment from Pierre MGI at https://community.bistudio.com/wiki/cursorObject // we'd like to find the cursorObject regardless, so we piggyback on the LIS check to find the most probable one + // This is the best we can do without a positionCameraToWorldVisual command. + // positionCameraToWorld translates position from camera space to world space in SIMULATION time scope, + // while a theoretical positionCameraToWorldVisual command would translate positions from camera space to world + // space in RENDER time scope. + private _camPos = _player modelToWorldVisualWorld (_player selectionPosition "pilot"); private _lis = lineIntersectsSurfaces [ - AGLToASL positionCameraToWorld [0, 0, 0], - AGLToASL positionCameraToWorld [0, 0, GVAR(renderDistance) + 1], + _camPos, + _camPos vectorAdd ((getCameraViewDirection _player) vectorMultiply (GVAR(renderDistance) + 1)), _player, objNull, true,