diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 9adcfab8c..c867de103 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1262,6 +1262,7 @@ {"name":"node_export","order":10,"path":"scripts/node_export/node_export.yy",}, {"name":"controlPointBox","order":21,"path":"scripts/controlPointBox/controlPointBox.yy",}, {"name":"sh_vertex_pt","order":5,"path":"shaders/sh_vertex_pt/sh_vertex_pt.yy",}, + {"name":"node_cache_base","order":18,"path":"scripts/node_cache_base/node_cache_base.yy",}, {"name":"fd_rectangle_set_velocity_dissipation_type","order":13,"path":"scripts/fd_rectangle_set_velocity_dissipation_type/fd_rectangle_set_velocity_dissipation_type.yy",}, {"name":"node_color_replacement","order":3,"path":"scripts/node_color_replacement/node_color_replacement.yy",}, {"name":"path_reader","order":5,"path":"scripts/path_reader/path_reader.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index fe4978f11..d803f3bea 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1969,6 +1969,7 @@ {"id":{"name":"node_export","path":"scripts/node_export/node_export.yy",},}, {"id":{"name":"controlPointBox","path":"scripts/controlPointBox/controlPointBox.yy",},}, {"id":{"name":"sh_vertex_pt","path":"shaders/sh_vertex_pt/sh_vertex_pt.yy",},}, + {"id":{"name":"node_cache_base","path":"scripts/node_cache_base/node_cache_base.yy",},}, {"id":{"name":"fd_rectangle_set_velocity_dissipation_type","path":"scripts/fd_rectangle_set_velocity_dissipation_type/fd_rectangle_set_velocity_dissipation_type.yy",},}, {"id":{"name":"node_color_replacement","path":"scripts/node_color_replacement/node_color_replacement.yy",},}, {"id":{"name":"path_reader","path":"scripts/path_reader/path_reader.yy",},}, diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index 15c687201..467e4b538 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/scripts/draw_sprite_ext_override/draw_sprite_ext_override.gml b/scripts/draw_sprite_ext_override/draw_sprite_ext_override.gml index f56867a52..6f6e37197 100644 --- a/scripts/draw_sprite_ext_override/draw_sprite_ext_override.gml +++ b/scripts/draw_sprite_ext_override/draw_sprite_ext_override.gml @@ -29,7 +29,7 @@ function draw_sprite_ext_add(spr, ind, _x, _y, xscale = 1, yscale = 1, rot = 0, BLEND_NORMAL } -function draw_sprite_stretched_points(spr, ind, _x0, _y0, _x1, _y1) { +function draw_sprite_stretched_points(spr, ind, _x0, _y0, _x1, _y1, color = c_white, alpha = 1) { gml_pragma("forceinline"); var _xs = round(min(_x0, _x1)); @@ -37,7 +37,7 @@ function draw_sprite_stretched_points(spr, ind, _x0, _y0, _x1, _y1) { var _w = round(max(_x0, _x1) - _xs); var _h = round(max(_y0, _y1) - _ys); - __draw_sprite_stretched(spr, ind, _xs, _ys, _w, _h); + __draw_sprite_stretched_ext(spr, ind, _xs, _ys, _w, _h, color, alpha); } function draw_sprite_bbox(spr, ind, _bbox) { diff --git a/scripts/node_cache/node_cache.gml b/scripts/node_cache/node_cache.gml index 956e508fa..ad9fadbfc 100644 --- a/scripts/node_cache/node_cache.gml +++ b/scripts/node_cache/node_cache.gml @@ -1,8 +1,6 @@ -function Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { +function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor { name = "Cache"; use_cache = CACHE_USE.auto; - clearCacheOnChange = false; - update_on_frame = true; inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); @@ -57,4 +55,17 @@ function Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { cache_loading_progress = 0; cache_loading = true; } #endregion + + static attributeDeserialize = function(attr) { #region + struct_override(attributes, attr); + cache_group_members = []; + + if(struct_has(attributes, "cache_group")) { + for( var i = 0, n = array_length(attributes.cache_group); i < n; i++ ) { + var _node = attributes.cache_group[i]; + if(ds_map_exists(PROJECT.nodeMap, _node)) + array_push(cache_group_members, PROJECT.nodeMap[? _node]); + } + } + } #endregion } \ No newline at end of file diff --git a/scripts/node_cache_array/node_cache_array.gml b/scripts/node_cache_array/node_cache_array.gml index e0a54c553..3fb9c832b 100644 --- a/scripts/node_cache_array/node_cache_array.gml +++ b/scripts/node_cache_array/node_cache_array.gml @@ -1,8 +1,6 @@ -function Node_Cache_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { +function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor { name = "Cache Array"; use_cache = CACHE_USE.manual; - clearCacheOnChange = false; - update_on_frame = true; inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); diff --git a/scripts/node_cache_base/node_cache_base.gml b/scripts/node_cache_base/node_cache_base.gml new file mode 100644 index 000000000..f10ae6ffd --- /dev/null +++ b/scripts/node_cache_base/node_cache_base.gml @@ -0,0 +1,152 @@ +function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { + name = "Cache"; + clearCacheOnChange = false; + update_on_frame = true; + + attributes.cache_group = []; + cache_group_members = []; + group_vertex = []; + vertex_hash = ""; + + insp1UpdateTooltip = "Generate cache group"; + insp1UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ]; + + static getCacheGroup = function(node) { #region + if(node != self) { + array_push(attributes.cache_group, node.node_id); + array_push(cache_group_members, node); + } + + for( var i = 0, n = ds_list_size(node.inputs); i < n; i++ ) { + var _from = node.inputs[| i].value_from; + + if(_from == noone) continue; + if(_from.node == self) continue; + if(array_exists(attributes.cache_group, _from.node.node_id)) continue; + getCacheGroup(_from.node); + } + } #endregion + + static onInspector1Update = function() { #region + attributes.cache_group = []; + cache_group_members = []; + + getCacheGroup(self); + } #endregion + + static ccw = function(a, b, c) { return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); } + + static getNodeBorder = function(_i, _vertex, _node) { #region + var _rad = 8; + var _stp = 15; + + var _nx0 = _node.x - 32 + _rad; + var _ny0 = _node.y - 32 + _rad; + var _nx1 = _node.x + _node.w + 32 - _rad; + var _ny1 = _node.y + _node.h + 32 - _rad; + + var _ind = 0; + for( var i = 0; i <= 90; i += _stp ) + _vertex[_i * 7 * 4 + _ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ]; + + for( var i = 90; i <= 180; i += _stp ) + _vertex[_i * 7 * 4 + _ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ]; + + for( var i = 180; i <= 270; i += _stp ) + _vertex[_i * 7 * 4 + _ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ]; + + for( var i = 270; i <= 360; i += _stp ) + _vertex[_i * 7 * 4 + _ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ]; + } #endregion + + static refrshGroupBG = function() { #region + group_vertex = []; + + if(array_empty(cache_group_members)) return; + var _vtrx = array_create((array_length(cache_group_members) + 1) * 4 * 7); + + for( var i = -1, n = array_length(cache_group_members); i < n; i++ ) { + var _node = i == -1? self : cache_group_members[i]; + getNodeBorder(i + 1, _vtrx, _node); + } + + __temp_minP = [ x, y ]; + __temp_minI = 0; + + for( var i = 0, n = array_length(_vtrx); i < n; i++ ) { + var _v = _vtrx[i]; + + if(_v[1] > __temp_minP[1] || (_v[1] == __temp_minP[1] && _v[0] < __temp_minP[0])) { + __temp_minP = _v; + __temp_minI = i; + } + } + + _vtrx = array_map( _vtrx, function(a, i) { return [ a[0], a[1], i == __temp_minI? -999 : point_direction(__temp_minP[0], __temp_minP[1], a[0], a[1]) + 360 ] }); + array_sort(_vtrx, function(a0, a1) { return a0[2] == a1[2]? sign(a0[0] - a1[0]) : sign(a0[2] - a1[2]); }); + + var _linS = 0; + for( var i = 1, n = array_length(_vtrx); i < n; i++ ) { + if(_vtrx[i][1] != _vtrx[0][1]) break; + _linS = i; + } + + array_delete(_vtrx, 1, _linS - 1); + + group_vertex = [ _vtrx[0], _vtrx[1] ]; + + for( var i = 2, n = array_length(_vtrx); i < n; i++ ) { + var _v = _vtrx[i]; + + while( array_length(group_vertex) >= 2 && ccw( group_vertex[array_length(group_vertex) - 2], group_vertex[array_length(group_vertex) - 1], _v ) >= 0 ) + array_pop(group_vertex); + array_push(group_vertex, _v); + } + } #endregion + + static drawNodeBG = function(_x, _y, _mx, _my, _s) { #region + var _hash = ""; + for( var i = -1, n = array_length(cache_group_members); i < n; i++ ) { + var _node = i == -1? self : cache_group_members[i]; + _hash += $"{_node.x},{_node.y},{_node.w},{_node.h}|"; + } + _hash = md5_string_utf8(_hash); + + if(vertex_hash != _hash) refrshGroupBG(); + vertex_hash = _hash; + + if(array_length(group_vertex) < 3) return; + + var _color = getColor(); + draw_set_color(_color); + draw_set_alpha(0.025); + draw_primitive_begin(pr_trianglelist); + var a = group_vertex[0]; + var b = group_vertex[1]; + var c; + + for( var i = 2, n = array_length(group_vertex); i < n; i++ ) { + c = group_vertex[i]; + + draw_vertex(_x + a[0] * _s, _y + a[1] * _s); + draw_vertex(_x + b[0] * _s, _y + b[1] * _s); + draw_vertex(_x + c[0] * _s, _y + c[1] * _s); + + b = group_vertex[i]; + } + draw_primitive_end(); + + draw_set_alpha(0.3); + draw_primitive_begin(pr_linestrip); + for( var i = 0, n = array_length(group_vertex); i < n; i++ ) { + var a = group_vertex[i]; + draw_vertex(_x + a[0] * _s, _y + a[1] * _s); + } + + a = group_vertex[0]; + draw_vertex(_x + a[0] * _s, _y + a[1] * _s); + draw_primitive_end(); + + draw_set_alpha(1); + } #endregion +} \ No newline at end of file diff --git a/scripts/node_cache_base/node_cache_base.yy b/scripts/node_cache_base/node_cache_base.yy new file mode 100644 index 000000000..0187b34e7 --- /dev/null +++ b/scripts/node_cache_base/node_cache_base.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_cache_base", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "misc", + "path": "folders/nodes/data/misc.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_cache_base/node_outline.yy b/scripts/node_cache_base/node_outline.yy new file mode 100644 index 000000000..86468bc09 --- /dev/null +++ b/scripts/node_cache_base/node_outline.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "process", + "path": "folders/nodes/data/process.yy", + }, + "resourceVersion": "1.0", + "name": "node_outline", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index f663bafd7..05432ab70 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -590,7 +590,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc } #endregion static attributeDeserialize = function(attr) { #region - attributes = attr; + struct_override(attributes, attr); if(struct_has(attr, "separator")) attributes.separator = json_parse(attr.separator); } #endregion diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 239a522f2..5b6caf523 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1143,6 +1143,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } } #endregion + static drawNodeBG = function(_x, _y, _mx, _my, _s, display_parameter = noone) {} + static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) { #region if(draw_graph_culled) return; if(!active) return; @@ -1751,9 +1753,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x createNewInput(); } #endregion - static attributeDeserialize = function(attr) { #region - struct_override(attributes, attr); - } #endregion + static attributeDeserialize = function(attr) { struct_override(attributes, attr); } static postDeserialize = function() {} static processDeserialize = function() {} diff --git a/scripts/node_frame/node_frame.gml b/scripts/node_frame/node_frame.gml index 440ef0f74..66f3a9b6c 100644 --- a/scripts/node_frame/node_frame.gml +++ b/scripts/node_frame/node_frame.gml @@ -69,7 +69,7 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } draw_scale = 1; - static drawNode = function(_x, _y, _mx, _my, _s) { + static drawNodeBG = function(_x, _y, _mx, _my, _s) { draw_scale = _s; if(size_dragging) { diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index bd75ee7bf..161621a11 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -1631,7 +1631,7 @@ function Panel_Animation() : PanelContent() constructor { #endregion if(keyframe_boxing) { #region - draw_sprite_stretched_points(THEME.ui_selection, 0, keyframe_box_sx, keyframe_box_sy, msx, msy); + draw_sprite_stretched_points(THEME.ui_selection, 0, keyframe_box_sx, keyframe_box_sy, msx, msy, COLORS._main_accent); if(mouse_release(mb_left)) keyframe_boxing = false; diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index e69ed8833..7f1dbbee2 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -755,10 +755,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { printIf(log, "Predraw time: " + string(current_time - t)); t = current_time; #region draw frame - for(var i = 0; i < ds_list_size(nodes_list); i++) { - if(instanceof(nodes_list[| i]) != "Node_Frame") continue; - nodes_list[| i].drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter); - } + for(var i = 0; i < ds_list_size(nodes_list); i++) + nodes_list[| i].drawNodeBG(gr_x, gr_y, mx, my, graph_s, display_parameter); #endregion printIf(log, "Frame draw time: " + string(current_time - t)); t = current_time; @@ -806,7 +804,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { node_focus = node_hovering; if(node_focus) { - if(instanceof(node_focus) == "Node_Frame") { + if(is_instanceof(node_focus, Node_Frame)) { var fx0 = (node_focus.x + graph_x) * graph_s; var fy0 = (node_focus.y + graph_y) * graph_s; var fx1 = fx0 + node_focus.w * graph_s; @@ -817,7 +815,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { if(!key_mod_press(CTRL)) for(var i = 0; i < ds_list_size(nodes_list); i++) { //select content var _node = nodes_list[| i]; - if(instanceof(_node) == "Node_Frame") continue; + if(is_instanceof(_node, Node_Frame)) continue; var _x = (_node.x + graph_x) * graph_s; var _y = (_node.y + graph_y) * graph_s; var _w = _node.w * graph_s; @@ -989,7 +987,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { for(var i = 0; i < ds_list_size(nodes_list); i++) { var _node = nodes_list[| i]; - if(instanceof(_node) == "Node_Frame") continue; + if(is_instanceof(_node, Node_Frame)) continue; var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter); if(val) { @@ -1106,11 +1104,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { #region draw selection frame if(nodes_select_drag) { if(point_distance(nodes_select_mx, nodes_select_my, mx, my) > 16) { - draw_sprite_stretched_points(THEME.ui_selection, 0, nodes_select_mx, nodes_select_my, mx, my); + draw_sprite_stretched_points(THEME.ui_selection, 0, nodes_select_mx, nodes_select_my, mx, my, COLORS._main_accent); for(var i = 0; i < ds_list_size(nodes_list); i++) { var _node = nodes_list[| i]; - if(instanceof(_node) == "Node_Frame") continue; + if(is_instanceof(_node, Node_Frame)) continue; var _x = (_node.x + graph_x) * graph_s; var _y = (_node.y + graph_y) * graph_s; var _w = _node.w * graph_s;