diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index f33b3c47fe..498321b857 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -6,6 +6,7 @@ PREP(addActionEventHandler); PREP(addActionMenuEventHandler); PREP(addCameraEventHandler); PREP(addCustomEventHandler); +PREP(addLineToDebugDraw); PREP(addMapMarkerCreatedEventHandler); PREP(addScrollWheelEventHandler); PREP(adminKick); @@ -24,6 +25,7 @@ PREP(closeDialogIfTargetMoves); PREP(codeToLetter); PREP(codeToString); PREP(convertKeyCode); +PREP(createOrthonormalReference); PREP(currentChannel); PREP(disableUserInput); PREP(displayText); diff --git a/addons/common/functions/fnc_addLineToDebugDraw.sqf b/addons/common/functions/fnc_addLineToDebugDraw.sqf new file mode 100644 index 0000000000..cfe45359c9 --- /dev/null +++ b/addons/common/functions/fnc_addLineToDebugDraw.sqf @@ -0,0 +1,48 @@ +/* + * Author: CAA-Picard + * + * Add line to draw on debug + * + * Argument: + * 0: Start point ASL (Array) + * 1: End point ASL (Array) + * 2: Color (Array) + * + * Return value: + * + */ +#include "script_component.hpp" + +if (isNil QGVAR(debugLines)) then { + GVAR(debugLines) = []; + GVAR(debugLinesIndex) = 0; +}; + +if (count GVAR(debugLines) < 100) then { + GVAR(debugLines) pushBack _this; + GVAR(debugLinesIndex) = 0; +} else { + GVAR(debugLines) set [GVAR(debugLinesIndex), _this]; + GVAR(debugLinesIndex) = (GVAR(debugLinesIndex) + 1) mod 100; +}; + +if (isNil QGVAR(debugDrawHandler)) then { + GVAR(debugDrawHandler) = addMissionEventHandler ["Draw3D", { + if (count GVAR(debugLines) == 0) exitWith { + removeMissionEventHandler GVAR(debugDrawHandler); + GVAR(debugDrawHandler) = nil; + }; + + { + _p0 = _x select 0; + if (!surfaceIsWater _p0) then { + _p0 = ASLtoATL _p0; + }; + _p1 = _x select 1; + if (!surfaceIsWater _p1) then { + _p1 = ASLtoATL _p1; + }; + drawLine3D [_p0, _p1, _x select 2]; + } forEach GVAR(debugLines); + }]; +}; \ No newline at end of file diff --git a/addons/common/functions/fnc_createOrthonormalReference.sqf b/addons/common/functions/fnc_createOrthonormalReference.sqf new file mode 100644 index 0000000000..a92464a7f3 --- /dev/null +++ b/addons/common/functions/fnc_createOrthonormalReference.sqf @@ -0,0 +1,21 @@ +/* + * Author: CAA-Picard + * + * Returns a orthonormal system of reference aligned with the supplied vector + * + * Argument: + * Vector to align the coordinate system with (Array) + * + * Return value: + * 0: v1 (Array) + * 1: v2 (Array) + * 2: v3 (Array) + */ +#include "script_component.hpp" + +private ["_v1","_v2","_v3"]; +_v1 = vectorNormalized _this; +_v2 = vectorNormalized (_v1 vectorCrossProduct [0,0,1]); +_v3 = _v2 vectorCrossProduct _v1; + +[_v1,_v2,_v3]