mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #989 from acemod/interactionOclusion
Action point oclusion
This commit is contained in:
commit
4e7194174d
@ -1,47 +1,8 @@
|
||||
class GVAR(cursorMenu) {
|
||||
idd = 91919;
|
||||
movingEnable = false;
|
||||
access = 0;
|
||||
movingEnable = 0;
|
||||
enableSimulation = 1;
|
||||
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(dlgCursorMenu)),_this select 0)]; uiNamespace setVariable [ARR_2(QUOTE(QGVAR(cursorMenuOpened)),true)]);
|
||||
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(cursorMenuOpened)),false)]);
|
||||
objects[] = {};
|
||||
/*class controlsBackground {
|
||||
class Background {
|
||||
idc = 91920;
|
||||
moving = 0;
|
||||
font = "TahomaB";
|
||||
text = "";
|
||||
sizeEx = 0;
|
||||
lineSpacing = 0;
|
||||
access = 0;
|
||||
type = 0;
|
||||
style = 0;
|
||||
size = 1;
|
||||
colorBackground[] = {0, 0, 0, 0.5};
|
||||
colorText[] = {0, 0, 0, 0};
|
||||
x = "safezoneX";
|
||||
y = "safezoneY";
|
||||
w = "safezoneW";
|
||||
h = "safezoneH";
|
||||
};
|
||||
};*/
|
||||
class controls {
|
||||
class Canvas {
|
||||
idc = 91921;
|
||||
moving = 0;
|
||||
font = "TahomaB";
|
||||
text = "";
|
||||
sizeEx = 0;
|
||||
lineSpacing = 0;
|
||||
access = 0;
|
||||
type = 0;
|
||||
style = 0;
|
||||
size = 1;
|
||||
colorBackground[] = {0, 0, 0, 0};
|
||||
colorText[] = {0, 0, 0, 0};
|
||||
x = "safezoneX";
|
||||
y = "safezoneY";
|
||||
w = "safezoneW";
|
||||
h = "safezoneH";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -25,6 +25,21 @@ PREP(renderSelector);
|
||||
PREP(setupTextColors);
|
||||
PREP(splitPath);
|
||||
|
||||
// Event handlers for all interact menu controls
|
||||
DFUNC(handleMouseMovement) = {
|
||||
if (GVAR(cursorKeepCentered)) then {
|
||||
GVAR(cursorPos) = GVAR(cursorPos) vectorAdd [_this select 1, _this select 2, 0] vectorDiff [0.5, 0.5, 0];
|
||||
setMousePosition [0.5, 0.5];
|
||||
} else {
|
||||
GVAR(cursorPos) = [_this select 1, _this select 2, 0];
|
||||
};
|
||||
};
|
||||
DFUNC(handleMouseButtonDown) = {
|
||||
if !(GVAR(actionOnKeyRelease)) then {
|
||||
[GVAR(openedMenuType),true] call FUNC(keyUp);
|
||||
};
|
||||
};
|
||||
|
||||
GVAR(keyDown) = false;
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
GVAR(keyDownTime) = 0;
|
||||
@ -51,6 +66,7 @@ GVAR(expandedTime) = diag_tickTime;
|
||||
GVAR(iconCtrls) = [];
|
||||
GVAR(iconCount) = 0;
|
||||
|
||||
GVAR(collectedActionPoints) = [];
|
||||
GVAR(foundActions) = [];
|
||||
GVAR(lastTimeSearchedActions) = -1000;
|
||||
|
||||
|
@ -37,40 +37,36 @@ GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
|
||||
{(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} ||
|
||||
{(_menuType == 0) && GVAR(AlwaysUseCursorInteraction)};
|
||||
|
||||
// Delete existing controls in case there's any left
|
||||
GVAR(iconCount) = 0;
|
||||
for "_i" from 0 to (count GVAR(iconCtrls))-1 do {
|
||||
ctrlDelete (GVAR(iconCtrls) select _i);
|
||||
GVAR(ParsedTextCached) set [_i, ""];
|
||||
};
|
||||
GVAR(iconCtrls) resize GVAR(iconCount);
|
||||
|
||||
if (GVAR(useCursorMenu)) then {
|
||||
createDialog QGVAR(cursorMenu);
|
||||
(findDisplay 46) createDisplay QGVAR(cursorMenu); //"RscCinemaBorder";//
|
||||
(finddisplay 91919) displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];
|
||||
(finddisplay 91919) displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}];
|
||||
// The dialog sets:
|
||||
// uiNamespace getVariable QGVAR(dlgCursorMenu);
|
||||
// uiNamespace getVariable QGVAR(cursorMenuOpened);
|
||||
ctrlEnable [91921, true];
|
||||
GVAR(cursorPos) = [0.5,0.5,0];
|
||||
((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseMoving", {
|
||||
if (GVAR(cursorKeepCentered)) then {
|
||||
GVAR(cursorPos) = GVAR(cursorPos) vectorAdd [_this select 1, _this select 2, 0] vectorDiff [0.5, 0.5, 0];
|
||||
setMousePosition [0.5, 0.5];
|
||||
} else {
|
||||
GVAR(cursorPos) = [_this select 1, _this select 2, 0];
|
||||
};
|
||||
}];
|
||||
// handles LMB in cursor mode when action on keyrelease is disabled
|
||||
((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseButtonDown", {
|
||||
if (!GVAR(actionOnKeyRelease) && GVAR(actionSelected)) then {
|
||||
[GVAR(openedMenuType),true] call FUNC(keyUp);
|
||||
};
|
||||
}];
|
||||
|
||||
_ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922];
|
||||
_ctrl ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH];
|
||||
_ctrl ctrlCommit 0;
|
||||
|
||||
// handles Mouse moving and LMB in cursor mode when action on keyrelease is disabled
|
||||
((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
|
||||
((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
|
||||
setMousePosition [0.5, 0.5];
|
||||
};
|
||||
|
||||
GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff
|
||||
((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL));
|
||||
|
||||
private ["_wavesAtOrigin", "_wavesAtVirtualPoint"];
|
||||
|
||||
_wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt);
|
||||
_wavesAtVirtualPoint = [(positionCameraToWorld [0, 0, 2])] call EFUNC(common,waveHeightAt);
|
||||
GVAR(selfMenuOffset) set [2, ((GVAR(selfMenuOffset) select 2) + _wavesAtOrigin - _wavesAtVirtualPoint)];
|
||||
|
||||
|
||||
["interactMenuOpened", [_menuType]] call EFUNC(common,localEvent);
|
||||
|
||||
true
|
||||
|
@ -19,7 +19,7 @@ _calledByClicking = _this select 1;
|
||||
if (GVAR(openedMenuType) < 0) exitWith {true};
|
||||
|
||||
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
closeDialog 0;
|
||||
(findDisplay 91919) closeDisplay 2;
|
||||
};
|
||||
|
||||
if(GVAR(actionSelected)) then {
|
||||
|
@ -17,13 +17,13 @@ GVAR(currentOptions) = [];
|
||||
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos", "_virtualPoint", "_wavesAtOrigin", "_wavesAtVirtualPoint"];
|
||||
_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;
|
||||
|
||||
@ -119,6 +119,8 @@ _fnc_renderSelfActions = {
|
||||
};
|
||||
|
||||
|
||||
GVAR(collectedActionPoints) resize 0;
|
||||
|
||||
// Render nearby actions, unit self actions or vehicle self actions as appropiate
|
||||
if (GVAR(openedMenuType) == 0) then {
|
||||
|
||||
@ -137,3 +139,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,17 @@ _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);
|
||||
if (count _pos > 2) then {
|
||||
_sPos pushBack (((_pos call EFUNC(common,positionToASL)) vectorDiff _cameraPos) vectorDotProduct _cameraDir);
|
||||
} else {
|
||||
_sPos pushBack 0;
|
||||
};
|
||||
|
||||
// Add action point for oclusion and rendering
|
||||
GVAR(collectedActionPoints) pushBack [_sPos select 2, _sPos, _activeActionTree];
|
||||
|
||||
END_COUNTER(fnc_renderMenus);
|
||||
|
||||
|
@ -23,6 +23,10 @@ PARAMS_4(_text,_icon,_sPos,_textSettings);
|
||||
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
|
||||
_displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
|
||||
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
|
||||
if (GVAR(useCursorMenu)) then {
|
||||
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
|
||||
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
|
||||
};
|
||||
};
|
||||
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
|
||||
|
||||
|
@ -20,6 +20,10 @@ private ["_displayNum", "_ctrl", "_pos"];
|
||||
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
|
||||
_displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
|
||||
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
|
||||
if (GVAR(useCursorMenu)) then {
|
||||
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
|
||||
((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
|
||||
};
|
||||
};
|
||||
|
||||
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
|
||||
|
Loading…
Reference in New Issue
Block a user