mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-13 05:53:53 +01:00
[Array Processor] Fix array balancing modify output value.
This commit is contained in:
parent
bcfdd88c63
commit
5767d8c988
@ -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 {
|
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 =============
|
/////============== GET =============
|
||||||
|
|
||||||
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value
|
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value
|
||||||
getValueRecursive(self.__curr_get_val, _time);
|
getValueRecursive(self.__curr_get_val, _time);
|
||||||
var val = __curr_get_val[0];
|
var val = __curr_get_val[0];
|
||||||
|
|
||||||
val = array_verify(val, data_array_length);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __getAnimValue = function(_time = CURRENT_FRAME) {
|
static __getAnimValue = function(_time = CURRENT_FRAME) {
|
||||||
if(!is_anim) {
|
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);
|
return array_empty(animator.values)? 0 : animator.processType(animator.values[0].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sep_axis) {
|
if(sep_axis) {
|
||||||
__temp_time = _time;
|
__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);
|
return animator.getValue(_time);
|
||||||
|
@ -298,6 +298,17 @@ function array_spread(arr, _arr = [], _minDepth = 0) {
|
|||||||
return _arr;
|
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) {
|
function array_verify(arr, length) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
LATEST_VERSION = 1_16_00;
|
LATEST_VERSION = 1_16_00;
|
||||||
VERSION = 1_17_11_0;
|
VERSION = 1_17_11_0;
|
||||||
SAVE_VERSION = 1_17_10_0;
|
SAVE_VERSION = 1_17_10_0;
|
||||||
VERSION_STRING = "1.17.11";
|
VERSION_STRING = "1.17.12.001";
|
||||||
BUILD_NUMBER = 1_17_11_0;
|
BUILD_NUMBER = 1_17_11_0;
|
||||||
|
|
||||||
HOTKEYS = ds_map_create();
|
HOTKEYS = ds_map_create();
|
||||||
|
@ -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++ ) {
|
for( var i = input_fix_len; i < array_length(inputs); i++ ) {
|
||||||
var val = getInputData(i);
|
var val = getInputData(i);
|
||||||
|
// if(is_array(val)) val = array_clone(val);
|
||||||
|
|
||||||
if(is_array(val) && spd) array_append(res, val);
|
if(is_array(val) && spd) array_append(res, val);
|
||||||
else array_push(res, val);
|
else array_push(res, val);
|
||||||
|
@ -359,7 +359,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||||||
for(var i = 0; i < _len; i++)
|
for(var i = 0; i < _len; i++)
|
||||||
all_inputs[i] = array_verify(all_inputs[i], process_amount);
|
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++) {
|
for(var i = 0; i < _len; i++) {
|
||||||
var _in = inputs_data[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]);
|
all_inputs[i][l] = inputs[i].arrayBalance(_in[_index]);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1313,20 +1313,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||||||
}
|
}
|
||||||
|
|
||||||
static arrayBalance = function(val) {
|
static arrayBalance = function(val) {
|
||||||
if(!is_array(def_val))
|
if(!is_array(def_val)) return val;
|
||||||
return val;
|
if(isDynamicArray()) return val;
|
||||||
|
if(isArray(val)) return val;
|
||||||
if(isDynamicArray())
|
if(!is_array(val)) return array_create(def_length, val);
|
||||||
return val;
|
|
||||||
|
|
||||||
if(isArray(val))
|
if(array_length(val) < def_length) {
|
||||||
return val;
|
val = array_clone(val, 1);
|
||||||
|
|
||||||
if(!is_array(val))
|
|
||||||
return array_create(def_length, val);
|
|
||||||
|
|
||||||
if(array_length(val) < def_length)
|
|
||||||
array_resize(val, def_length);
|
array_resize(val, def_length);
|
||||||
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -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 = {}) { 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 {
|
function NodeValue_Area(_name, _node, _value, _data = {}) : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, "") constructor {
|
||||||
|
|
||||||
setDisplay(VALUE_DISPLAY.area, _data);
|
setDisplay(VALUE_DISPLAY.area, _data);
|
||||||
|
def_length = AREA_ARRAY_LENGTH;
|
||||||
|
|
||||||
/////============== GET =============
|
/////============== GET =============
|
||||||
|
|
||||||
|
@ -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 {
|
function NodeValue_Dimension(_node, value) : NodeValue("Dimension", _node, CONNECT_TYPE.input, VALUE_TYPE.integer, value, "") constructor {
|
||||||
setDisplay(VALUE_DISPLAY.vector);
|
setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
def_length = 2;
|
||||||
|
|
||||||
/////============== GET =============
|
/////============== GET =============
|
||||||
|
|
||||||
|
@ -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 {
|
function NodeValue_Padding(_name, _node, _value, _tooltip = "") : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, _tooltip) constructor {
|
||||||
setDisplay(VALUE_DISPLAY.padding);
|
setDisplay(VALUE_DISPLAY.padding);
|
||||||
|
def_length = 4;
|
||||||
|
|
||||||
/////============== GET =============
|
/////============== GET =============
|
||||||
|
|
||||||
|
@ -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 {
|
function NodeValue_Vec2(_name, _node, _value, _data = {}) : NodeValue(_name, _node, CONNECT_TYPE.input, VALUE_TYPE.float, _value, "") constructor {
|
||||||
setDisplay(VALUE_DISPLAY.vector, _data);
|
setDisplay(VALUE_DISPLAY.vector, _data);
|
||||||
|
def_length = 2;
|
||||||
|
|
||||||
/////============== GET =============
|
/////============== GET =============
|
||||||
|
|
||||||
|
@ -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 {
|
function NodeValue_Vec2_Range(_name, _node, _value, _data = {}) : NodeValue_Array(_name, _node, _value, "", 4) constructor {
|
||||||
setDisplay(VALUE_DISPLAY.vector_range, _data);
|
setDisplay(VALUE_DISPLAY.vector_range, _data);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user