Cache, group IO ordering fix

This commit is contained in:
MakhamDev 2023-10-28 09:07:43 +07:00
parent b7918574b9
commit 9245b35c1f
17 changed files with 74 additions and 79 deletions

View file

@ -1342,7 +1342,7 @@
{"name":"node_counter","order":1,"path":"scripts/node_counter/node_counter.yy",},
{"name":"s_node_shape_polygon","order":25,"path":"sprites/s_node_shape_polygon/s_node_shape_polygon.yy",},
{"name":"s_node_pb_fx_interesct","order":6,"path":"sprites/s_node_pb_fx_interesct/s_node_pb_fx_interesct.yy",},
{"name":"node_path_eval","order":4,"path":"scripts/node_path_eval/node_path_eval.yy",},
{"name":"node_path_sample","order":4,"path":"scripts/node_path_sample/node_path_sample.yy",},
{"name":"sh_3d_depth","order":6,"path":"shaders/sh_3d_depth/sh_3d_depth.yy",},
{"name":"__node_3d_displace","order":1,"path":"scripts/__node_3d_displace/__node_3d_displace.yy",},
{"name":"node_vector_dot","order":9,"path":"scripts/node_vector_dot/node_vector_dot.yy",},

View file

@ -2054,7 +2054,7 @@
{"id":{"name":"s_node_shape_polygon","path":"sprites/s_node_shape_polygon/s_node_shape_polygon.yy",},},
{"id":{"name":"sh_color_picker_hue","path":"shaders/sh_color_picker_hue/sh_color_picker_hue.yy",},},
{"id":{"name":"s_node_pb_fx_interesct","path":"sprites/s_node_pb_fx_interesct/s_node_pb_fx_interesct.yy",},},
{"id":{"name":"node_path_eval","path":"scripts/node_path_eval/node_path_eval.yy",},},
{"id":{"name":"node_path_sample","path":"scripts/node_path_sample/node_path_sample.yy",},},
{"id":{"name":"sh_3d_depth","path":"shaders/sh_3d_depth/sh_3d_depth.yy",},},
{"id":{"name":"__node_3d_displace","path":"scripts/__node_3d_displace/__node_3d_displace.yy",},},
{"id":{"name":"node_vector_dot","path":"scripts/node_vector_dot/node_vector_dot.yy",},},

View file

@ -219,7 +219,7 @@ function array_shape(arr, first = true, isSurface = false) {
return (first? "" : " x ") + dim;
}
function array_depth(arr) {
function array_get_depth(arr) {
gml_pragma("forceinline");
if(!is_array(arr)) return 0;
@ -237,7 +237,7 @@ function array_depth(arr) {
function array_spread(arr, _arr = [], _minDepth = 0) {
gml_pragma("forceinline");
if(array_depth(arr) == _minDepth) {
if(array_get_depth(arr) == _minDepth) {
array_push(_arr, arr);
return _arr;
}

View file

@ -35,12 +35,9 @@ function Node_VFX_Renderer_Output(_x, _y, _group = noone) : Node_Group_Output(_x
.setVisible(true, true);
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static createOutput = function(override_order = true) { #region
static createOutput = function() { #region
if(group == noone) return;
if(!is_struct(group)) return;
if(override_order)
attributes.input_priority = ds_list_size(group.outputs);
if(!is_undefined(outParent))
ds_list_remove(group.outputs, outParent);

View file

@ -11,9 +11,12 @@ function Node_Array_Length(_x, _y, _group = noone) : Node(_x, _y, _group) constr
outputs[| 0] = nodeValue("Size", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, 0);
static update = function(frame = CURRENT_FRAME) {
var _arr = getInputData(0);
static step = function() { #region
inputs[| 0].setType(inputs[| 0].isLeaf()? VALUE_TYPE.any : inputs[| 0].value_from.type);
} #endregion
static update = function(frame = CURRENT_FRAME) { #region
var _arr = getInputData(0);
if(!is_array(_arr) || array_length(_arr) == 0) {
outputs[| 0].setValue(0);
@ -21,14 +24,14 @@ function Node_Array_Length(_x, _y, _group = noone) : Node(_x, _y, _group) constr
}
outputs[| 0].setValue(array_length(_arr));
}
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
var str = string(outputs[| 0].getValue());
var bbox = drawGetBbox(xx, yy, _s);
var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
}
} #endregion
}

View file

@ -13,17 +13,16 @@ function Node_Array_Zip(_x, _y, _group = noone) : Node(_x, _y, _group) construct
setIsDynamicInput(1);
static createNewInput = function() {
static createNewInput = function() { #region
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, -1 )
.setVisible(true, true);
return inputs[| index];
}
if(!LOADING && !APPENDING) createNewInput();
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static refreshDynamicInput = function() {
static refreshDynamicInput = function() { #region
var _l = ds_list_create();
for( var i = 0; i < ds_list_size(inputs); i++ ) {
@ -40,33 +39,36 @@ function Node_Array_Zip(_x, _y, _group = noone) : Node(_x, _y, _group) construct
inputs = _l;
createNewInput();
}
} #endregion
static onValueFromUpdate = function(index) {
static onValueFromUpdate = function(index) { #region
if(LOADING || APPENDING) return;
refreshDynamicInput();
}
} #endregion
static update = function(frame = CURRENT_FRAME) {
var _arr = getInputData(0);
static step = function() { #region
if(inputs[| 0].isLeaf()) {
inputs[| 0].setType(VALUE_TYPE.any);
outputs[| 0].setType(VALUE_TYPE.any);
return;
} else {
inputs[| 0].setType(inputs[| 0].value_from.type);
outputs[| 0].setType(inputs[| 0].value_from.type);
}
if(!is_array(_arr)) return;
var _type = inputs[| 0].value_from.type;
inputs[| 0].setType(_type);
outputs[| 0].setType(_type);
for( var i = 0; i < ds_list_size(inputs) - 1; i += data_length )
inputs[| i].setType(inputs[| i].isLeaf()? VALUE_TYPE.any : inputs[| i].value_from.type);
} #endregion
static update = function(frame = CURRENT_FRAME) { #region
var _arr = getInputData(0);
if(!is_array(_arr)) return;
var len = 1;
var val = [];
for( var i = 0; i < ds_list_size(inputs) - 1; i += data_length ) {
val[i] = getInputData(i);
inputs[| i].setType(inputs[| i].isLeaf()? inputs[| i].value_from.type : VALUE_TYPE.any);
if(!is_array(val[i])) {
val[i] = [ val[i] ];
continue;
@ -82,10 +84,10 @@ function Node_Array_Zip(_x, _y, _group = noone) : Node(_x, _y, _group) construct
}
outputs[| 0].setValue(_out);
}
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_array_zip, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
} #endregion
}

View file

@ -18,9 +18,9 @@ function Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static onInspector2Update = function() { clearCache(); }
static onInspector2Update = function() { clearCache(true); }
static step = function() {
static step = function() { #region
if(cache_loading) {
cached_output[cache_loading_progress] = __surface_array_deserialize(cache_content[cache_loading_progress]);
cache_result[cache_loading_progress] = true;
@ -31,29 +31,29 @@ function Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
update();
}
}
}
} #endregion
static update = function() {
static update = function() { #region
if(recoverCache()) return;
if(!inputs[| 0].value_from) return;
var _surf = getInputData(0);
cacheCurrentFrame(_surf);
}
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
if(cache_loading)
draw_sprite_ui(THEME.loading, 0, xx + w * _s / 2, yy + h * _s / 2, _s, _s, current_time / 2, COLORS._main_icon, 1);
}
} #endregion
static doSerialize = function(_map) {
static doSerialize = function(_map) { #region
_map.cache = surface_array_serialize(cached_output);
}
} #endregion
static postDeserialize = function() {
static postDeserialize = function() { #region
if(!struct_has(load_map, "cache")) return;
cache_content = json_try_parse(load_map.cache);
cache_loading_progress = 0;
cache_loading = true;
}
} #endregion
}

View file

@ -396,15 +396,16 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
var _or = 0;
var _ors = [];
for( var i = custom_input_index; i < ds_list_size(list); i++ ) {
var _in = list[| i];
array_push(_ors, _in.from.attributes.input_priority);
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var _n = nodes[| i];
if(!struct_has(_n.attributes, "input_priority")) continue;
array_push(_ors, _n.attributes.input_priority);
}
array_sort(_ors, true);
for( var i = 0, n = array_length(_ors); i < n; i++ )
if(_or == _ors[i]) _or++;
return _or;
} #endregion

View file

@ -1356,12 +1356,14 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
return true;
} #endregion
static clearCache = function() { #region
static clearCache = function(_force = false) { #region
clearInputCache();
if(!clearCacheOnChange) return;
if(!use_cache) return;
if(!isRenderActive()) return;
if(!_force) {
if(!use_cache) return;
if(!clearCacheOnChange) return;
if(!isRenderActive()) return;
}
if(array_length(cached_output) != TOTAL_FRAMES)
array_resize(cached_output, TOTAL_FRAMES);

View file

@ -12,12 +12,9 @@ function Node_DynaSurf_In(_x, _y, _group = noone) : Node(_x, _y, _group) constru
outputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.output, VALUE_TYPE.PCXnode, noone);
static createInput = function(override_order = true) { #region
static createInput = function() { #region
if(group == noone || !is_struct(group)) return noone;
if(override_order)
attributes.input_priority = ds_list_size(group.inputs);
if(!is_undefined(inParent))
ds_list_remove(group.inputs, inParent);

View file

@ -35,12 +35,9 @@ function Node_Fluid_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
static onInspector2Update = function() { clearCache(); }
static createOutput = function(override_order = true) { #region
static createOutput = function() { #region
if(group == noone) return;
if(!is_struct(group)) return;
if(override_order)
attributes.input_priority = ds_list_size(group.outputs);
if(!is_undefined(outParent))
ds_list_remove(group.outputs, outParent);

View file

@ -254,12 +254,9 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
}
} #endregion
static createInput = function(override_order = true) { #region
static createInput = function() { #region
if(group == noone || !is_struct(group)) return noone;
if(override_order)
attributes.input_priority = ds_list_size(group.inputs);
if(!is_undefined(inParent))
ds_list_remove(group.inputs, inParent);

View file

@ -65,13 +65,10 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr
return nodes;
} #endregion
static createOutput = function(override_order = true) { #region
static createOutput = function() { #region
if(group == noone) return;
if(!is_struct(group)) return;
if(override_order)
attributes.input_priority = ds_list_size(group.outputs);
if(!is_undefined(outParent))
ds_list_remove(group.outputs, outParent);
@ -142,4 +139,10 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr
static onLoadGroup = function() { #region
if(group == noone) nodeDelete(self);
} #endregion
//static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
// var bbox = drawGetBbox(xx, yy, _s);
// draw_set_text(f_h5, fa_center, fa_center, c_white);
// draw_text(bbox.xc, bbox.yc, attributes.input_priority);
//} #endregion
}

View file

@ -22,8 +22,9 @@ function Node_Path_Sample(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
var _rat = _data[1];
var _mod = _data[2];
if(_path == noone) return [ 0, 0 ];
if(!struct_has(_path, "getPointRatio")) return [ 0, 0 ];
if(_path == noone) return [ 0, 0 ];
if(!struct_has(_path, "getPointRatio")) return [ 0, 0 ];
if(!is_real(_rat)) return [ 0, 0 ];
var inv = false;
switch(_mod) {

View file

@ -1,7 +1,7 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_path_eval",
"name": "node_path_sample",
"isCompatibility": false,
"isDnD": false,
"parent": {

View file

@ -37,12 +37,9 @@ function Node_Rigid_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
.setVisible(true, true);
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static createOutput = function(override_order = true) { #region
static createOutput = function() { #region
if(group == noone) return;
if(!is_struct(group)) return;
if(override_order)
attributes.input_priority = ds_list_size(group.outputs);
if(!is_undefined(outParent))
ds_list_remove(group.outputs, outParent);

View file

@ -1618,8 +1618,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static isArray = function(val = undefined) { #region
if(val == undefined) {
if(cache_array[0])
return cache_array[1];
if(cache_array[0]) return cache_array[1];
val = getValue();
}
@ -1650,8 +1649,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion
static arrayLength = function(val = undefined) { #region
if(val == undefined)
val = getValue();
if(val == undefined) val = getValue();
if(!isArray(val))
return -1;