diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 3923ddf4b3..d3ea2451b9 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -15,9 +15,6 @@ PREP(render); PREP(renderIcon); PREP(renderBaseMenu); PREP(renderMenu); -PREP(rotateVectLine); -PREP(rotateVectLineGetMap); -PREP(updateVecLineMap); GVAR(keyDown) = false; GVAR(keyDownSelfAction) = false; @@ -31,7 +28,6 @@ GVAR(actionSelected) = false; GVAR(selectedTarget) = objNull; GVAR(menuDepthPath) = []; -GVAR(vecLineMap) = []; GVAR(lastPos) = [0,0,0]; GVAR(currentOptions) = []; diff --git a/addons/interact_menu/functions/fnc_keyDownSelfAction.sqf b/addons/interact_menu/functions/fnc_keyDownSelfAction.sqf index 1dff596665..0f58a246d2 100644 --- a/addons/interact_menu/functions/fnc_keyDownSelfAction.sqf +++ b/addons/interact_menu/functions/fnc_keyDownSelfAction.sqf @@ -32,6 +32,8 @@ if(!GVAR(keyDownSelfAction)) then { setMousePosition [0.5, 0.5]; }; - GVAR(selfMenuOffset) = (positionCameraToWorld [0, 0, 2]) vectorDiff (positionCameraToWorld [0, 0, 0]); + + GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff + ((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)); }; true diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf index ee98a86f7a..b2b5f35547 100644 --- a/addons/interact_menu/functions/fnc_keyUp.sqf +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -22,5 +22,4 @@ if(GVAR(actionSelected)) then { GVAR(expanded) = false; GVAR(lastPath) = []; GVAR(menuDepthPath) = []; -GVAR(vecLineMap) = []; true diff --git a/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf b/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf index 1842587984..0f784e640b 100644 --- a/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf +++ b/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf @@ -26,5 +26,4 @@ if(GVAR(actionSelected)) then { GVAR(expanded) = false; GVAR(lastPath) = []; GVAR(menuDepthPath) = []; -GVAR(vecLineMap) = []; true diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 8dce504acc..f5723f0c5d 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -25,7 +25,6 @@ GVAR(currentOptions) = []; private ["_actionsVarName","_classActions","_objectActions","_target","_player","_action","_actionData","_active"]; _player = ACE_player; if (GVAR(keyDown)) then { - [] call FUNC(updateVecLineMap); // Render all nearby interaction menus #define MAXINTERACTOBJECTS 3 @@ -76,8 +75,6 @@ if (GVAR(keyDown)) then { } else { if (GVAR(keyDownSelfAction)) then { - [] call FUNC(updateVecLineMap); - // Render only the self action menu _target = vehicle ACE_player; @@ -100,7 +97,7 @@ if (GVAR(keyDown)) then { { _action = _x; - _pos = _cursorPos1 vectorAdd GVAR(selfMenuOffset); + _pos = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition); [_target, _action, _pos] call FUNC(renderBaseMenu); } forEach _classActions; }; @@ -176,9 +173,6 @@ if(!_foundTarget && GVAR(actionSelected)) then { GVAR(actionSelected) = false; GVAR(expanded) = false; GVAR(lastPath) = []; - if(!GVAR(keyDown)) then { - GVAR(vecLineMap) = []; - }; }; for "_i" from GVAR(iconCount) to (count GVAR(iconCtrls))-1 do { ctrlDelete (GVAR(iconCtrls) select _i); diff --git a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf index d25a8ad957..7ff430fa08 100644 --- a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf @@ -41,6 +41,9 @@ if((count _this) > 2) then { _pos = _pos vectorAdd ((visiblePositionASL _object) vectorDiff (getPosASL _object)); }; +_cameraToActionVec = (_pos call EFUNC(common,positionToASL)) vectorDiff ((positionCameraToWorld [0,0,0]) call EFUNC(common,positionToASL)); +GVAR(refSystem) = _cameraToActionVec call EFUNC(common,createOrthonormalReference); + // For non-self actions, exit if the action is too far away if (GVAR(keyDown) && {(ACE_player modelToWorld (ACE_player selectionPosition "pilot")) distance _pos >= _distance}) exitWith {false}; diff --git a/addons/interact_menu/functions/fnc_renderMenu.sqf b/addons/interact_menu/functions/fnc_renderMenu.sqf index 3ae2f98324..ad604b9fa5 100644 --- a/addons/interact_menu/functions/fnc_renderMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderMenu.sqf @@ -66,9 +66,11 @@ _angle = _centerAngle - _angleSpan / 2; _target = _object; _player = ACE_player; - _offset = [GVAR(vecLineMap), _angle] call FUNC(rotateVectLine); _mod = (0.15 max (0.15 * ((positionCameraToWorld [0, 0, 0]) distance _pos))) / GVAR(selfMenuScale); - _newPos = _pos vectorAdd (_offset vectorMultiply _mod); + + _offset = ((GVAR(refSystem) select 1) vectorMultiply (-_mod * cos _angle)) vectorAdd + ((GVAR(refSystem) select 2) vectorMultiply (-_mod * sin _angle)); + _newPos = ((_pos call EFUNC(common,positionToASL)) vectorAdd _offset) call EFUNC(common,ASLToPosition); //drawLine3D [_pos, _newPos, [1,0,0,0.5]]; diff --git a/addons/interact_menu/functions/fnc_rotateVectLine.sqf b/addons/interact_menu/functions/fnc_rotateVectLine.sqf deleted file mode 100644 index 4639a50903..0000000000 --- a/addons/interact_menu/functions/fnc_rotateVectLine.sqf +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Author: NouberNou - * Rotate a vector line (?) - * - * Argument: - * 0: Map - * 1: Theta - * - * Return value: - * 0: ?? - * - * Public: No - */ -#include "script_component.hpp" - -private ["_theta", "_p", "_map", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; -_map = _this select 0; -_theta = _this select 1; - -_p = _map select 0; -_p1 = _map select 1; -_p2 = _map select 2; - -_q1 = +(_map select 3); -_q2 = +(_map select 4); -_u = _map select 5; -_d = _map select 6; - -/* Step 4 */ -_q2 set[0, (_q1 select 0) * cos(_theta) - (_q1 select 1) * sin(_theta)]; -_q2 set[1, (_q1 select 0) * sin(_theta) + (_q1 select 1) * cos(_theta)]; -_q2 set[2, (_q1 select 2)]; - -/* Inverse of step 3 */ -_q1 set[0, (_q2 select 0) * _d + (_q2 select 2) * (_u select 0)]; -_q1 set[1, (_q2 select 1)]; -_q1 set[2, - (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; - -/* Inverse of step 2 */ -if (_d != 0) then { - _q2 set[0, (_q1 select 0)]; - _q2 set[1, (_q1 select 1) * (_u select 2) / _d + (_q1 select 2) * (_u select 1) / _d]; - _q2 set[2, - (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; -} else { - _q2 = _q1; -}; - -/* Inverse of step 1 */ -_q1 set[0, (_q2 select 0) + (_p1 select 0)]; -_q1 set[1, (_q2 select 1) + (_p1 select 1)]; -_q1 set[2, (_q2 select 2) + (_p1 select 2)]; -_q1; diff --git a/addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf b/addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf deleted file mode 100644 index e695f3fa8e..0000000000 --- a/addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Author: NouberNou - * ? - * - * Argument: - * 0: p0 - * 1: p1 - * 2: p2 - * - * Return value: - * Map - * - * Public: No - */ -#include "script_component.hpp" - -private ["_p", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; - -_p = _this select 0; -_p1 = _this select 1; -_p2 = _this select 2; - -_q1 = []; -_q2 = []; -_u = []; - -/* Step 1 */ -_q1 set[0, (_p select 0) - (_p1 select 0)]; -_q1 set[1, (_p select 1) - (_p1 select 1)]; -_q1 set[2, (_p select 2) - (_p1 select 2)]; - -_u set[0, (_p2 select 0) - (_p1 select 0)]; -_u set[1, (_p2 select 1) - (_p1 select 1)]; -_u set[2, (_p2 select 2) - (_p1 select 2)]; -_u = _u call BIS_fnc_unitVector; -_d = sqrt((_u select 1)*(_u select 1) + (_u select 2)*(_u select 2)); - -/* Step 2 */ -if (_d != 0) then { - _q2 set[0, (_q1 select 0)]; - _q2 set[1, (_q1 select 1) * (_u select 2) / _d - (_q1 select 2) * (_u select 1) / _d]; - _q2 set[2, (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; -} else { - _q2 = _q1; -}; - -/* Step 3 */ -_q1 set[0, (_q2 select 0) * _d - (_q2 select 2) * (_u select 0)]; -_q1 set[1, (_q2 select 1)]; -_q1 set[2, (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; - -[_p, _p1, _p2, _q1, _q2, _u, _d] diff --git a/addons/interact_menu/functions/fnc_updateVecLineMap.sqf b/addons/interact_menu/functions/fnc_updateVecLineMap.sqf deleted file mode 100644 index c5027ffc60..0000000000 --- a/addons/interact_menu/functions/fnc_updateVecLineMap.sqf +++ /dev/null @@ -1,13 +0,0 @@ -#include "script_component.hpp"; - -if((count GVAR(vecLineMap)) == 0 || ((count GVAR(menuDepthPath)) > 0 && (getPosASL player) distance GVAR(lastPos) > 0.01)) then { - GVAR(lastPos) = getPosASL player; - _cursorVec = [_cursorPos2, _cursorPos1] call BIS_fnc_vectorFromXtoY; - _p1 = [0,0,0]; - _p2 = +_cursorVec; - _p = (_cursorVec call CBA_fnc_vect2polar); - _v = [(_p select 0), (_p select 1), (_p select 2)+90] call CBA_fnc_polar2vect; - _cp = [_cursorVec, _v] call BIS_fnc_crossProduct; - - GVAR(vecLineMap) = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap); -}; \ No newline at end of file