mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Make closer action points oclude farther ones. Improves the clutter of the interact menu when interating with a person from the side. Close #738
This commit is contained in:
parent
fae10aa731
commit
1735047e3c
@ -66,6 +66,7 @@ GVAR(expandedTime) = diag_tickTime;
|
||||
GVAR(iconCtrls) = [];
|
||||
GVAR(iconCount) = 0;
|
||||
|
||||
GVAR(collectedActionPoints) = [];
|
||||
GVAR(foundActions) = [];
|
||||
GVAR(lastTimeSearchedActions) = -1000;
|
||||
|
||||
|
@ -17,13 +17,13 @@ GVAR(currentOptions) = [];
|
||||
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos"];
|
||||
_player = ACE_player;
|
||||
|
||||
_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL);
|
||||
_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos;
|
||||
|
||||
_fnc_renderNearbyActions = {
|
||||
// Render all nearby interaction menus
|
||||
#define MAXINTERACTOBJECTS 3
|
||||
|
||||
_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL);
|
||||
_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos;
|
||||
|
||||
GVAR(foundActions) = [];
|
||||
GVAR(lastTimeSearchedActions) = diag_tickTime;
|
||||
|
||||
@ -114,6 +114,8 @@ _fnc_renderSelfActions = {
|
||||
};
|
||||
|
||||
|
||||
GVAR(collectedActionPoints) resize 0;
|
||||
|
||||
// Render nearby actions, unit self actions or vehicle self actions as appropiate
|
||||
if (GVAR(openedMenuType) == 0) then {
|
||||
|
||||
@ -132,3 +134,31 @@ if (GVAR(openedMenuType) == 0) then {
|
||||
} else {
|
||||
ACE_player call _fnc_renderSelfActions;
|
||||
};
|
||||
|
||||
if (count GVAR(collectedActionPoints) > 1) then {
|
||||
// Do the oclusion pass
|
||||
|
||||
// Order action points according to z
|
||||
// @todo: after 1.43 is released switch BIS_fnc_sortBy with sort
|
||||
GVAR(collectedActionPoints) = [GVAR(collectedActionPoints),[],{_x select 0},"ASCEND"] call BIS_fnc_sortBy;
|
||||
//GVAR(collectedActionPoints) sort true;
|
||||
|
||||
private ["_i","_j","_delta"];
|
||||
for [{_i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do {
|
||||
for [{_j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do {
|
||||
// Check if action point _i is ocluded by _j
|
||||
_delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1));
|
||||
|
||||
// If _i is inside a cone with 20º half angle with origin on _j
|
||||
if (_delta select 2 > 0.94) exitWith {
|
||||
GVAR(collectedActionPoints) deleteAt _i;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Render the non-ocluded points
|
||||
{
|
||||
EXPLODE_3_PVT(_x,_z,_sPos,_activeActionTree);
|
||||
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
|
||||
} forEach GVAR(collectedActionPoints);
|
||||
|
@ -93,11 +93,13 @@ _fnc_print = {
|
||||
// Check if there's something left for rendering
|
||||
if (count _activeActionTree == 0) exitWith {false};
|
||||
|
||||
//EXPLODE_2_PVT(_activeActionTree,_actionData,_actionChildren);
|
||||
|
||||
BEGIN_COUNTER(fnc_renderMenus);
|
||||
|
||||
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
|
||||
// IGNORE_PRIVATE_WARNING(_cameraPos,_cameraDir);
|
||||
_sPos pushBack (((_pos call EFUNC(common,positionToASL)) vectorDiff _cameraPos) vectorDotProduct _cameraDir);
|
||||
|
||||
// Add action point for oclusion and rendering
|
||||
GVAR(collectedActionPoints) pushBack [_sPos select 2, _sPos, _activeActionTree];
|
||||
|
||||
END_COUNTER(fnc_renderMenus);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user