2023-03-07 14:29:47 +01:00
|
|
|
function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Path Array";
|
2024-05-02 12:13:35 +02:00
|
|
|
setDimension(96, 48);;
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2024-01-23 07:51:28 +01:00
|
|
|
cached_pos = ds_map_create();
|
2023-03-07 14:29:47 +01:00
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Path array", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self);
|
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static createNewInput = function() { #region
|
2023-03-07 14:29:47 +01:00
|
|
|
var index = ds_list_size(inputs);
|
|
|
|
|
|
|
|
inputs[| index] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone )
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
|
|
|
return inputs[| index];
|
2024-05-23 10:59:39 +02:00
|
|
|
} setDynamicInput(1, true, VALUE_TYPE.pathnode);
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static getLineCount = function() { #region
|
2023-03-07 14:29:47 +01:00
|
|
|
var l = 0;
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-03-07 14:29:47 +01:00
|
|
|
l += struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
|
|
|
}
|
|
|
|
return l;
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static getSegmentCount = function(ind = 0) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-03-19 09:17:39 +01:00
|
|
|
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
if(ind < lc) return _path.getSegmentCount(ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static getLength = function(ind = 0) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-03-19 09:17:39 +01:00
|
|
|
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
if(ind < lc) return _path.getLength(ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static getAccuLength = function(ind = 0) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-03-19 09:17:39 +01:00
|
|
|
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
|
|
|
|
2023-03-29 15:02:03 +02:00
|
|
|
if(ind < lc) return _path.getAccuLength(ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-11-28 06:50:54 +01:00
|
|
|
static getPointRatio = function(_rat, ind = 0) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-08-02 19:11:57 +02:00
|
|
|
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-11-28 06:50:54 +01:00
|
|
|
if(ind < lc) return _path.getPointRatio(_rat, ind).clone();
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
2023-08-31 16:58:13 +02:00
|
|
|
return new __vec2();
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2023-11-28 06:50:54 +01:00
|
|
|
static getPointDistance = function(_dist, ind = 0) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-03-07 14:29:47 +01:00
|
|
|
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
|
|
|
|
2023-11-28 06:50:54 +01:00
|
|
|
if(ind < lc) return _path.getPointDistance(_dist, ind).clone();
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
2023-08-31 16:58:13 +02:00
|
|
|
return new __vec2();
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static getBoundary = function(ind = 0) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(i);
|
2023-08-02 19:11:57 +02:00
|
|
|
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
if(ind < lc) return _path.getBoundary(ind);
|
2023-03-07 14:29:47 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
return 0;
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2024-03-14 14:35:19 +01:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
2024-05-23 10:59:39 +02:00
|
|
|
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
2023-11-28 06:50:54 +01:00
|
|
|
var _path = getInputData(i);
|
|
|
|
if(!struct_has(_path, "drawOverlay")) continue;
|
|
|
|
|
2024-03-26 11:48:41 +01:00
|
|
|
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2023-11-28 06:50:54 +01:00
|
|
|
}
|
|
|
|
} #endregion
|
|
|
|
|
2023-10-11 02:20:03 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) { #region
|
2024-01-23 07:51:28 +01:00
|
|
|
ds_map_clear(cached_pos);
|
2023-03-07 14:29:47 +01:00
|
|
|
outputs[| 0].setValue(self);
|
2023-10-11 02:20:03 +02:00
|
|
|
} #endregion
|
2023-03-07 14:29:47 +01:00
|
|
|
}
|