2022-01-13 05:24:03 +01:00
|
|
|
enum ARRAY_PROCESS {
|
|
|
|
loop,
|
|
|
|
hold
|
|
|
|
}
|
|
|
|
|
2022-12-13 09:20:36 +01:00
|
|
|
function Node_Processor(_x, _y, _group = -1) : Node(_x, _y, _group) constructor {
|
2022-12-27 13:30:02 +01:00
|
|
|
array_process = ARRAY_PROCESS.loop;
|
|
|
|
current_data = [];
|
|
|
|
inputs_data = [];
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
process_amount = 0;
|
2022-12-27 13:30:02 +01:00
|
|
|
dimension_index = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
icon = THEME.node_processor;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
static process_data = function(_outSurf, _data, _output_index, _array_index) { return _outSurf; }
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
static getSingleValue = function(_index, _arr = 0) {
|
|
|
|
var _n = inputs[| _index];
|
|
|
|
var _in = _n.getValue();
|
2022-12-27 04:00:50 +01:00
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(_n.isArray())
|
|
|
|
return _in[_arr % array_length(_in)];
|
|
|
|
return _in;
|
|
|
|
}
|
|
|
|
|
|
|
|
static getDimension = function(arr = 0) {
|
|
|
|
if(dimension_index == -1) return [1, 1];
|
|
|
|
|
|
|
|
var _in = getSingleValue(dimension_index, arr);
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
if(inputs[| dimension_index].type == VALUE_TYPE.surface && is_surface(_in)) {
|
2022-12-27 13:30:02 +01:00
|
|
|
var ww = surface_get_width(_in);
|
|
|
|
var hh = surface_get_height(_in);
|
2022-12-27 04:00:50 +01:00
|
|
|
return [ww, hh];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(is_array(_in) && array_length(_in) == 2)
|
|
|
|
return _in;
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
return [1, 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static preProcess = function(outIndex) {
|
|
|
|
var _out = outputs[| outIndex].getValue();
|
2022-12-18 03:20:38 +01:00
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
if(process_amount == 0) { //render single data
|
2023-01-01 02:06:02 +01:00
|
|
|
if(outputs[| outIndex].type == VALUE_TYPE.d3object) //passing 3D vertex call
|
|
|
|
return _out;
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
if(is_array(_out)) { //free surface if needed
|
|
|
|
if(outputs[| outIndex].type == VALUE_TYPE.surface)
|
|
|
|
for(var i = 1; i < array_length(_out); i++) {
|
|
|
|
if(is_surface(_out[i])) surface_free(_out[i]);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
_out = array_safe_get(_out, 0);
|
2022-12-27 04:00:50 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(outputs[| outIndex].type == VALUE_TYPE.surface && dimension_index > -1) {
|
|
|
|
var surf = inputs_data[dimension_index];
|
|
|
|
var _sw = 1, _sh = 1;
|
|
|
|
if(inputs[| dimension_index].type == VALUE_TYPE.surface && is_surface(surf)) {
|
|
|
|
_sw = surface_get_width(surf);
|
|
|
|
_sh = surface_get_height(surf);
|
|
|
|
} else if(is_array(surf)) {
|
|
|
|
_sw = surf[0];
|
|
|
|
_sh = surf[1];
|
|
|
|
}
|
|
|
|
_out = surface_verify(_out, _sw, _sh);
|
2022-12-27 04:00:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
current_data = inputs_data;
|
2023-01-01 02:06:02 +01:00
|
|
|
return process_data(_out, inputs_data, outIndex, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(outputs[| outIndex].type == VALUE_TYPE.d3object) { //passing 3D vertex call
|
|
|
|
if(is_array(_out)) _out = _out[0];
|
|
|
|
return array_create(process_amount, _out);
|
2022-12-27 04:00:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!is_array(_out))
|
|
|
|
_out = array_create(process_amount);
|
|
|
|
else if(array_length(_out) != process_amount)
|
|
|
|
array_resize(_out, process_amount);
|
|
|
|
|
|
|
|
var _data = array_create(ds_list_size(inputs));
|
|
|
|
|
|
|
|
for(var l = 0; l < process_amount; l++) {
|
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) { //input prepare
|
|
|
|
var _in = inputs_data[i];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
if(!inputs[| i].isArray(_in)) {
|
|
|
|
_data[i] = inputs_data[i];
|
|
|
|
continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
if(array_length(_in) == 0) {
|
|
|
|
_data[i] = 0;
|
|
|
|
continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-27 04:00:50 +01:00
|
|
|
var _index = 0;
|
|
|
|
switch(array_process) {
|
|
|
|
case ARRAY_PROCESS.loop : _index = safe_mod(l, array_length(_in)); break;
|
|
|
|
case ARRAY_PROCESS.hold : _index = min(l, array_length(_in) - 1); break;
|
2022-11-22 14:25:39 +01:00
|
|
|
}
|
2022-12-27 04:00:50 +01:00
|
|
|
_data[i] = _in[_index];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-27 04:00:50 +01:00
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(outputs[| outIndex].type == VALUE_TYPE.surface && dimension_index > -1) {
|
|
|
|
var surf = _data[dimension_index];
|
|
|
|
var _sw = 1, _sh = 1;
|
|
|
|
if(inputs[| dimension_index].type == VALUE_TYPE.surface && is_surface(surf)) {
|
|
|
|
_sw = surface_get_width(surf);
|
|
|
|
_sh = surface_get_height(surf);
|
|
|
|
} else if(is_array(surf)) {
|
|
|
|
_sw = surf[0];
|
|
|
|
_sh = surf[1];
|
|
|
|
}
|
|
|
|
_out[l] = surface_verify(_out[l], _sw, _sh);
|
2022-12-27 04:00:50 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 13:30:02 +01:00
|
|
|
if(l == preview_index)
|
|
|
|
current_data = _data;
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
_out[l] = process_data(_out[l], _data, outIndex, l);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-27 04:00:50 +01:00
|
|
|
|
|
|
|
return _out;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
static update = function() {
|
|
|
|
process_amount = 0;
|
|
|
|
inputs_data = array_create(ds_list_size(inputs));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) { //pre-collect current input data
|
|
|
|
inputs_data[i] = inputs[| i].getValue();
|
|
|
|
|
|
|
|
if(!is_array(inputs_data[i])) continue;
|
|
|
|
if(array_length(inputs_data[i]) == 0) continue;
|
|
|
|
if(!inputs[| i].isArray(inputs_data[i])) continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
if(typeArray(inputs[| i].display_type)) {
|
|
|
|
process_amount = max(process_amount, array_length(inputs_data[i][0]));
|
|
|
|
} else
|
|
|
|
process_amount = max(process_amount, array_length(inputs_data[i]));
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++)
|
|
|
|
outputs[| i].setValue(preProcess(i));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|