Skip to content

Commit a2c06c5

Browse files
authored
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 #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
1 parent 3e3a0cb commit a2c06c5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

addons/nametags/functions/fnc_calculateFadeValue.sqf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
params ["_target", "_player"];
44
private _vehicle = vehicle _target;
55
private _distance = _player distance _vehicle;
6-
private _pos = _vehicle modelToWorld [0,0,1.4];
76

87
private _darknessPenalty = 0;
98
private _rangeModifier = 0;
@@ -38,7 +37,10 @@ if (GVAR(enableFOVBoost)) then {
3837

3938
private _fadeValue = (linearConversion [0, (_maxDistance * _rangeModifier), _distance, 1, 0, true]) - _darknessPenalty;
4039
if (GVAR(enableOcclusion)) then {
41-
_fadeValue = _fadeValue - ([objNull, "FIRE"] checkVisibility [eyePos _player, _pos]);
40+
_fadeValue = _fadeValue - ([objNull, "FIRE"] checkVisibility [
41+
_player modelToWorldVisualWorld (_player selectionPosition "pilot"),
42+
_vehicle modelToWorldVisual [0,0,1.4]
43+
]);
4244
};
4345

4446
// this function allows Mission Builders to implement there own coefs

addons/nametags/functions/fnc_onDraw.sqf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ if (GVAR(useLIS)) then {
1616
// unit, per the comment from Pierre MGI at https://community.bistudio.com/wiki/cursorObject
1717
// we'd like to find the cursorObject regardless, so we piggyback on the LIS check to find the most probable one
1818

19+
// This is the best we can do without a positionCameraToWorldVisual command.
20+
// positionCameraToWorld translates position from camera space to world space in SIMULATION time scope,
21+
// while a theoretical positionCameraToWorldVisual command would translate positions from camera space to world
22+
// space in RENDER time scope.
23+
private _camPos = _player modelToWorldVisualWorld (_player selectionPosition "pilot");
1924
private _lis = lineIntersectsSurfaces [
20-
AGLToASL positionCameraToWorld [0, 0, 0],
21-
AGLToASL positionCameraToWorld [0, 0, GVAR(renderDistance) + 1],
25+
_camPos,
26+
_camPos vectorAdd ((getCameraViewDirection _player) vectorMultiply (GVAR(renderDistance) + 1)),
2227
_player,
2328
objNull,
2429
true,

0 commit comments

Comments
 (0)