[Array Processor] Fix array balancing modify output value.

This commit is contained in:
Tanasart 2024-09-02 08:27:14 +07:00
parent bcfdd88c63
commit 5767d8c988
11 changed files with 30 additions and 21 deletions

View File

@ -12,27 +12,25 @@ function nodeValue_Vector(_name, _node, _value, _data = {}) {
function NodeValue_Array(_name, _node, _value, _tooltip = "", _length = 2) : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, _tooltip) constructor {
data_array_length = _length;
def_length = _length;
/////============== GET =============
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value
getValueRecursive(self.__curr_get_val, _time);
var val = __curr_get_val[0];
val = array_verify(val, data_array_length);
return val;
}
static __getAnimValue = function(_time = CURRENT_FRAME) {
if(!is_anim) {
if(sep_axis) return array_create_ext(data_array_length, function(i) /*=>*/ {return animators[i].processType(animators[i].values[0].value)});
if(sep_axis) return array_create_ext(def_length, function(i) /*=>*/ {return animators[i].processType(animators[i].values[0].value)});
return array_empty(animator.values)? 0 : animator.processType(animator.values[0].value);
}
if(sep_axis) {
__temp_time = _time;
return array_create_ext(data_array_length, function(i) /*=>*/ {return animators[i].getValue(__temp_time)});
return array_create_ext(def_length, function(i) /*=>*/ {return animators[i].getValue(__temp_time)});
}
return animator.getValue(_time);

View File

@ -298,6 +298,17 @@ function array_spread(arr, _arr = [], _minDepth = 0) {
return _arr;
}
function array_verify_new(arr, length) {
INLINE
if(!is_array(arr)) return array_create(length);
if(array_length(arr) == length) return arr;
arr = array_clone(arr, 1);
array_resize(arr, length);
return arr;
}
function array_verify(arr, length) {
INLINE

View File

@ -39,7 +39,7 @@
LATEST_VERSION = 1_16_00;
VERSION = 1_17_11_0;
SAVE_VERSION = 1_17_10_0;
VERSION_STRING = "1.17.11";
VERSION_STRING = "1.17.12.001";
BUILD_NUMBER = 1_17_11_0;
HOTKEYS = ds_map_create();

View File

@ -146,6 +146,7 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
for( var i = input_fix_len; i < array_length(inputs); i++ ) {
var val = getInputData(i);
// if(is_array(val)) val = array_clone(val);
if(is_array(val) && spd) array_append(res, val);
else array_push(res, val);

View File

@ -359,7 +359,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
for(var i = 0; i < _len; i++)
all_inputs[i] = array_verify(all_inputs[i], process_amount);
for(var l = 0; l < process_amount; l++) #region input preparation
for(var l = 0; l < process_amount; l++) // input preparation
for(var i = 0; i < _len; i++) {
var _in = inputs_data[i];
@ -382,7 +382,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
}
all_inputs[i][l] = inputs[i].arrayBalance(_in[_index]);
} #endregion
}
}

View File

@ -1313,20 +1313,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
}
static arrayBalance = function(val) {
if(!is_array(def_val))
return val;
if(isDynamicArray())
return val;
if(!is_array(def_val)) return val;
if(isDynamicArray()) return val;
if(isArray(val)) return val;
if(!is_array(val)) return array_create(def_length, val);
if(isArray(val))
return val;
if(!is_array(val))
return array_create(def_length, val);
if(array_length(val) < def_length)
if(array_length(val) < def_length) {
val = array_clone(val, 1);
array_resize(val, def_length);
}
return val;
}

View File

@ -24,7 +24,9 @@ enum AREA_INDEX {
function nodeValue_Area(_name, _node, _value, _data = {}) { return new NodeValue_Area(_name, _node, _value, _data); }
function NodeValue_Area(_name, _node, _value, _data = {}) : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, "") constructor {
setDisplay(VALUE_DISPLAY.area, _data);
def_length = AREA_ARRAY_LENGTH;
/////============== GET =============

View File

@ -2,6 +2,7 @@ function nodeValue_Dimension(_node, value = DEF_SURF) { return new NodeValue_Dim
function NodeValue_Dimension(_node, value) : NodeValue("Dimension", _node, CONNECT_TYPE.input, VALUE_TYPE.integer, value, "") constructor {
setDisplay(VALUE_DISPLAY.vector);
def_length = 2;
/////============== GET =============

View File

@ -2,6 +2,7 @@ function nodeValue_Padding(_name, _node, _value, _tooltip = "") { return new Nod
function NodeValue_Padding(_name, _node, _value, _tooltip = "") : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, _tooltip) constructor {
setDisplay(VALUE_DISPLAY.padding);
def_length = 4;
/////============== GET =============

View File

@ -2,6 +2,7 @@ function nodeValue_Vec2(_name, _node, _value, _data = {}) { return new NodeValue
function NodeValue_Vec2(_name, _node, _value, _data = {}) : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, "") constructor {
setDisplay(VALUE_DISPLAY.vector, _data);
def_length = 2;
/////============== GET =============

View File

@ -2,5 +2,4 @@ function nodeValue_Vec2_Range(_name, _node, _value, _data = {}) { return new Nod
function NodeValue_Vec2_Range(_name, _node, _value, _data = {}) : NodeValue_Array(_name, _node, _value, "", 4) constructor {
setDisplay(VALUE_DISPLAY.vector_range, _data);
}