Array over-cache

This commit is contained in:
Tanasart 2023-11-30 16:55:37 +07:00
parent 12f185f3cd
commit ce9006cd23
3 changed files with 17 additions and 19 deletions

View file

@ -45,8 +45,8 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var _n = _l[| _index];
var _in = output? _n.getValue() : getInputData(_index);
//print($"Getting value {name} [{_index}, {_arr}]: {_n.isArray()} = {_in}");
if(!_n.isArray()) return _in;
//if(_index == 3) print($"Getting value {name} [{_index}, {_arr}]: {_n.isArray(_in)} = {_in}");
if(!_n.isArray(_in)) return _in;
var _aIndex = _arr;
if(!is_array(_in)) return 0;

View file

@ -21,10 +21,6 @@ function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 3] = nodeValue("Anchor", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0.5, 0.5 ])
.setDisplay(VALUE_DISPLAY.vector, { #region
side_button : new buttonAnchor(function(ind) {
//var _dim = getDimension();
//var _pos = getSingleValue(2);
//var _anc = getSingleValue(3);
switch(ind) {
case 0 : inputs[| 3].setValue([ 0.0, 0.0 ]); break;
case 1 : inputs[| 3].setValue([ 0.5, 0.0 ]); break;
@ -146,6 +142,7 @@ function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _b = inputs[| 3].editWidget.side_button;
var _a = anc[0] * 2 + anc[1] * 20;
switch(_a) {
case 0 : _b.index = 0; break;
case 1 : _b.index = 1; break;

View file

@ -1512,7 +1512,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(!is_array(def_val))
return val;
if(isDynamicArray(display_type))
if(isDynamicArray())
return val;
if(isArray(val))
@ -1714,35 +1714,36 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion
static isArray = function(val = undefined) { #region
if(val == undefined) {
var _cac = val == undefined;
if(_cac) {
if(cache_array[0]) return cache_array[1];
val = getValue();
cache_array[0] = true;
}
cache_array[0] = true;
if(!is_array(val)) { //Value is array
cache_array[1] = false;
return cache_array[1];
if(!is_array(val)) { //Value is scalar
if(_cac) cache_array[1] = false;
return false;
}
if(array_depth == 0 && !typeArray(display_type)) { //Value is not an array by default, and no array depth enforced
cache_array[1] = true;
return cache_array[1];
if(_cac) cache_array[1] = true;
return false;
}
var ar = val;
repeat(array_depth + typeArray(display_type)) { //Recursively get the first member of subarray to check if value has depth of "array_depth" or not
if(!is_array(ar) || !array_length(ar)) { //empty array
cache_array[1] = false;
return cache_array[1];
if(_cac) cache_array[1] = false;
return false;
}
ar = ar[0];
}
cache_array[1] = is_array(ar);
return cache_array[1];
if(_cac) cache_array[1] = is_array(ar);
return is_array(ar);
} #endregion
static arrayLength = function(val = undefined) { #region