ACE3/addons/common/functions/fnc_addLineToDebugDraw.sqf

48 lines
1.2 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
/*
2015-03-24 04:18:00 +00:00
* Author: esteldunedain
* Add line to draw on debug
*
2015-09-18 06:47:14 +00:00
* Arguments:
* 0: Start point ASL <ARRAY>
* 1: End point ASL <ARRAY>
* 2: Color <ARRAY>
*
* Return Value:
* None
*
* Example:
* [[0,0,0], [1,1,0], [1,0,0,1]] call ace_common_fnc_addLineToDebugDraw;
*
2015-09-18 06:47:14 +00:00
* Public: No
*/
params ["_startASL", "_endASL", "_color"];
if (isNil QGVAR(debugLines)) then {
GVAR(debugLines) = [];
GVAR(debugLinesIndex) = 0;
};
if (count GVAR(debugLines) < 100) then {
GVAR(debugLines) pushBack [ASLtoAGL _startASL, ASLtoAGL _endASL, _color];
GVAR(debugLinesIndex) = 0;
} else {
GVAR(debugLines) set [GVAR(debugLinesIndex), [ASLtoAGL _startASL, ASLtoAGL _endASL, _color]];
GVAR(debugLinesIndex) = (GVAR(debugLinesIndex) + 1) mod 100;
};
if (isNil QGVAR(debugDrawHandler)) then {
GVAR(debugDrawHandler) = addMissionEventHandler ["Draw3D", {
if (GVAR(debugLines) isEqualTo []) exitWith {
2015-01-25 04:05:19 +00:00
removeMissionEventHandler ["Draw3D", GVAR(debugDrawHandler)];
GVAR(debugDrawHandler) = nil;
};
{
_x params ["_start", "_end", "_color"];
drawLine3D [_start, _end, _color];
} forEach GVAR(debugLines);
}];
2015-09-18 06:47:14 +00:00
};