Skip to content

Commit

Permalink
Fixed LIS checks in fast moving vehicles behaving unexpectedly (#195)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
derbismarck authored Jun 5, 2021
1 parent 3e3a0cb commit a2c06c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions addons/nametags/functions/fnc_calculateFadeValue.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions addons/nametags/functions/fnc_onDraw.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a2c06c5

Please sign in to comment.