2023-03-07 14:29:47 +01:00
|
|
|
function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2024-07-17 09:02:36 +02:00
|
|
|
name = "Path Combine";
|
|
|
|
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
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Combined Path", self, VALUE_TYPE.pathnode, self));
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
curr_path = [];
|
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static createNewInput = function() {
|
2024-08-08 06:57:51 +02:00
|
|
|
var index = array_length(inputs);
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(index, nodeValue_PathNode("Path", self, noone ))
|
2023-03-07 14:29:47 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
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
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getLineCount = function() {
|
2023-03-07 14:29:47 +01:00
|
|
|
var l = 0;
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ )
|
|
|
|
l += curr_path[i].getLineCount();
|
|
|
|
|
2023-03-07 14:29:47 +01:00
|
|
|
return l;
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getSegmentCount = function(ind = 0) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
var lc = curr_path[i].getLineCount()
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
if(ind < lc) return curr_path[i].getSegmentCount(ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getLength = function(ind = 0) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
var lc = curr_path[i].getLineCount();
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
if(ind < lc) return curr_path[i].getLength(ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getAccuLength = function(ind = 0) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
var lc = curr_path[i].getLineCount();
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
if(ind < lc) return curr_path[i].getAccuLength(ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getPointRatio = function(_rat, ind = 0) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
var lc = curr_path[i].getLineCount();
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
if(ind < lc) return curr_path[i].getPointRatio(_rat, ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
2025-01-15 07:55:00 +01:00
|
|
|
return new __vec2P();
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getPointDistance = function(_dist, ind = 0) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
var lc = curr_path[i].getLineCount();
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
if(ind < lc) return curr_path[i].getPointDistance(_dist, ind);
|
2023-03-19 09:17:39 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
2025-01-15 07:55:00 +01:00
|
|
|
return new __vec2P();
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static getBoundary = function(ind = 0) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
var lc = curr_path[i].getLineCount();
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
if(ind < lc) return curr_path[i].getBoundary(ind);
|
2023-03-07 14:29:47 +01:00
|
|
|
ind -= lc;
|
|
|
|
}
|
|
|
|
|
2023-08-02 19:11:57 +02:00
|
|
|
return 0;
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2025-01-16 04:39:54 +01:00
|
|
|
for( var i = 0, n = array_length(curr_path); i < n; i++ ) {
|
|
|
|
if(!struct_has(curr_path[i], "drawOverlay")) continue;
|
2023-11-28 06:50:54 +01:00
|
|
|
|
2025-01-16 04:39:54 +01:00
|
|
|
curr_path[i].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2023-11-28 06:50:54 +01:00
|
|
|
}
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-11-28 06:50:54 +01:00
|
|
|
|
2024-07-17 09:02:36 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) {
|
2024-01-23 07:51:28 +01:00
|
|
|
ds_map_clear(cached_pos);
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(self);
|
2025-01-16 04:39:54 +01:00
|
|
|
|
|
|
|
curr_path = [];
|
|
|
|
|
|
|
|
for( var i = input_fix_len; i < array_length(inputs); i += data_length ) {
|
|
|
|
var _path = getInputData(i);
|
|
|
|
var _ispath = _path != noone && struct_has(_path, "getPointRatio");
|
|
|
|
|
|
|
|
if(_ispath) array_push(curr_path, _path);
|
|
|
|
}
|
2024-07-17 09:02:36 +02:00
|
|
|
}
|
2023-03-07 14:29:47 +01:00
|
|
|
}
|