Skip to content

Commit

Permalink
Cone based occlusion feature
Browse files Browse the repository at this point in the history
  • Loading branch information
diwako committed Feb 2, 2019
1 parent f065383 commit e1087ca
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mod/functions/fn_displayUnitOnCompass.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ if (isNil "_player") then {
private _circleRange = diwako_dui_compassRange;
private _distance = _player distance2d _unit;
private _fade = linearConversion [_circleRange * 0.90, _circleRange, _distance, diwako_dui_compass_opacity, 0, true];
private _relDir = ((_player getRelDir _unit) - (_viewDir - _playerDir) ) mod 360;

if (diwako_dui_enable_occlusion && {_fade > 0}) then {
private _vis = [vehicle _unit, "VIEW"] checkVisibility [eyePos _player, AGLToASL (_unit modelToWorld (_unit selectionPosition "Spine2"))];
private _lastSeen = _unit getVariable "diwako_dui_lastSeen";

if (_vis == 0) then {
private _cone = if (_relDir > 180) then { abs (_relDir - 360)} else { abs _relDir};
if (_vis == 0 || {diwako_dui_enable_occlusion_actual_cone < _cone}) then {
// unit not visible anymore
if (isNil "_lastSeen") then {
_lastSeen = time;
Expand Down Expand Up @@ -68,7 +69,6 @@ if (isNull _ctrl) then {

ctrlPosition _ctrlGrp params ["_left", "_top", "_width", "_height"];
private _center = [_left + _width/2, _top + _height/2];
private _relDir = ((_player getRelDir _unit) - (_viewDir - _playerDir) ) mod 360;
private _dist = _distance / linearConversion [15,50,_circleRange,40,145,false];
private _iconScale = diwako_dui_compass_icon_scale;
private _newWidth = (44 * pixelW) /_divisor * _iconScale;
Expand Down
13 changes: 13 additions & 0 deletions mod/functions/fn_preinit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ private _curCat = localize "STR_dui_cat_compass";
,false
] call CBA_Settings_fnc_init;

[
"diwako_dui_enable_occlusion_cone"
,"SLIDER"
,[localize "STR_dui_occlusion_cone", localize "STR_dui_occlusion_cone_desc"]
,[CBA_SETTINGS_CAT, _curCat]
,[0, 360, 360, 1]
,false
,{
params ["_value"];
diwako_dui_enable_occlusion_actual_cone = _value / 2;
}
] call CBA_Settings_fnc_init;

[
"diwako_dui_compass_icon_scale"
,"SLIDER"
Expand Down
16 changes: 16 additions & 0 deletions mod/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,5 +526,21 @@
<!-- <Japanese></Japanese> -->
<Polish>Gdy jesteś sam w grupie, będzie to tylko ukrywać znacznik gracza na kompasie</Polish>
</Key>
<Key ID="STR_dui_occlusion_cone">
<English>Occlusion Cone</English>
<!-- <Czech></Czech> -->
<!-- <French></French> -->
<German>Okklusionskegel</German>
<!-- <Japanese></Japanese> -->
<!-- <Polish></Polish> -->
</Key>
<Key ID="STR_dui_occlusion_cone_desc">
<English>Sets the cone (in degrees) in which a unit is considered seen infront of the player. E.g. 90 means you can see the unit 45 degrees to your left and right</English>
<!-- <Czech></Czech> -->
<!-- <French></French> -->
<German>Stellt den Kegel (in Grad) ein, in dem eine Einheit als vor dem Spieler gesehen gilt. Als Beispiel mit 90 grad sieht man Einheiten 45° nach links und rechts</German>
<!-- <Japanese></Japanese> -->
<!-- <Polish></Polish> -->
</Key>
</Package>
</Project>

0 comments on commit e1087ca

Please sign in to comment.