add node guard clause

This commit is contained in:
Tanasart 2024-12-25 11:51:24 +07:00
parent 5c0eb2c486
commit af86d2b97e
24 changed files with 36 additions and 34 deletions

View file

@ -9,7 +9,7 @@ function __NodeValue_Object_Generic(_name, _node, _type, _value, _tooltip = "")
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -4,17 +4,18 @@ function Node_Feedback_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y,
is_group_io = true;
setDimension(96, 32 + 24 * 2);
feedbackOut = noone;
outputs[0].getValueDefault = method(outputs[0], outputs[0].getValueRecursive); //Get value from outside loop
outputs[0].getValueRecursive = function(arr, _time) {
var _node_output = noone;
for( var i = 0; i < array_length(outputs[1].value_to); i++ ) {
var vt = outputs[1].value_to[i];
if(vt.value_from == outputs[1])
_node_output = vt;
}
if(!is(feedbackOut, NodeValue)) return;
if(CURRENT_FRAME > 0 && _node_output != noone && _node_output.node.cache_value != noone) { //use cache from output
arr[@ 0] = _node_output.node.cache_value;
var _vto = feedbackOut.getJunctionTo();
var _jout = array_safe_get(_vto, 0, noone);
if(_jout == noone) return;
if(CURRENT_FRAME > 0 && _jout.node.cache_value != noone) { //use cache from output
arr[@ 0] = _jout.node.cache_value;
arr[@ 1] = inParent;
return;
}
@ -23,4 +24,5 @@ function Node_Feedback_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y,
}
newOutput(1, nodeValue_Output("Feedback loop", self, VALUE_TYPE.node, 0).nonForward());
feedbackOut = outputs[1];
}

View file

@ -1206,7 +1206,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
getValueRecursive(self.__curr_get_val, _time);
var val = __curr_get_val[0];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
var dis = nod.display_type;

View file

@ -70,7 +70,7 @@ function __NodeValue_Area(_name, _node, _value, _data = {}) : NodeValue(_name, _
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return valueProcess(val, nod, applyUnit, arrIndex);
}

View file

@ -4,12 +4,12 @@ function __NodeValue_Bool(_name, _node, _value, _tooltip = "") : NodeValue(_name
/////============== GET =============
function toBool(a) { return is_array(a)? array_map(a, function(v) /*=>*/ {return toBool(v)}) : bool(a) };
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];
var nod = __curr_get_val[1];
return is_array(val)? array_map(val, function(v) /*=>*/ {return bool(v)}) : bool(val);
return toBool(val);
}
static __getAnimValue = function(_time = CURRENT_FRAME) {

View file

@ -7,7 +7,7 @@ function __NodeValue_Color(_name, _node, _value, _tooltip = "") : NodeValue(_nam
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -7,7 +7,7 @@ function __NodeValue_Curve(_name, _node, _value) : NodeValue(_name, _node, CONNE
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -11,7 +11,7 @@ function __NodeValue_D3Material(_name, _node, _value, _tooltip = "") : NodeValue
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
var dis = nod.display_type;

View file

@ -15,7 +15,7 @@ function __NodeValue_Dimension(_node, value) : NodeValue("Dimension", _node, CON
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
if(typ != VALUE_TYPE.surface) {

View file

@ -8,7 +8,7 @@ function __NodeValue_Enum_Button(_name, _node, _value, _data) : NodeValue(_name,
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -8,7 +8,7 @@ function __NodeValue_Enum_Scroll(_name, _node, _value, _data) : NodeValue(_name,
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -12,7 +12,7 @@ function __NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_nam
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
var dis = nod.display_type;

View file

@ -7,7 +7,7 @@ function __NodeValue_Gradient(_name, _node, _value, _tooltip = "") : NodeValue(_
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
if(is_instanceof(val, gradientObject)) return val;
if(nod.type != VALUE_TYPE.color) return val;

View file

@ -13,7 +13,7 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name,
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
var dis = nod.display_type;

View file

@ -18,7 +18,7 @@ function __NodeValue_Padding(_name, _node, _value, _tooltip = "") : NodeValue(_n
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var _d = array_get_depth(val);
__nod = nod;

View file

@ -9,7 +9,7 @@ function __NodeValue_Palette(_name, _node, _value, _tooltip = "") : NodeValue(_n
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
if(!is_array(val)) val = [ val ];
return val;

View file

@ -8,7 +8,7 @@ function __NodeValue_Quaternion(_name, _node, _value, _tooltip = "") : __NodeVal
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
var dis = nod.display_type;

View file

@ -8,7 +8,7 @@ function __NodeValue_Rotation(_name, _node, _value, _tooltip = "") : NodeValue(_
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
if(typ == VALUE_TYPE.text) val = toNumber(val);

View file

@ -9,7 +9,7 @@ function __NodeValue_Rotation_Random(_name, _node, _value, _tooltip = "") : __No
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) {
getValueRecursive(self.__curr_get_val, _time);
var val = __curr_get_val[0];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
if(!is_array(val)) return [ 0, val, val, 0, 0 ];
if(array_length(val) == 2) return [ 0, val[0], val[1], 0, 0 ];

View file

@ -9,7 +9,7 @@ function __NodeValue_Surface(_name, _node, _value, _tooltip = "") : NodeValue(_n
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
draw_junction_index = VALUE_TYPE.surface;
if(is_instanceof(val, SurfaceAtlas) || (array_valid(val) && is_instanceof(val[0], SurfaceAtlas)))

View file

@ -7,7 +7,7 @@ function __NodeValue_Text(_name, _node, _value, _tooltip = "") : NodeValue(_name
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -7,7 +7,7 @@ function __NodeValue_Trigger(_name, _node, _value, _tooltip = "") : NodeValue(_n
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
return val;
}

View file

@ -19,7 +19,7 @@ function __NodeValue_Vec2(_name, _node, _value, _data = {}) : NodeValue(_name, _
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];
var nod = __curr_get_val[1];
var nod = __curr_get_val[1]; if(!is(nod, Node)) return val;
var typ = nod.type;
if(typ != VALUE_TYPE.surface) {

View file

@ -136,7 +136,7 @@ function Panel_Test() : PanelContent() constructor {
cc = merge_color(COLORS._main_value_negative, c_white, 0.5);
tx = ui(16);
if(hv && _f.tooltip != -1) TOOLTIP = _f.tooltip;
if(hv) TOOLTIP = _f[$ "tooltip"] ?? "";
break;
case 0 :
@ -397,5 +397,5 @@ function Panel_Test() : PanelContent() constructor {
}
}
setTestDir("D:/Project/MakhamDev/LTS-PixelComposer/TEST/Tester");
setTestDir("D:/Project/MakhamDev/LTS-PixelComposer/TEST/Others");
}