From 8e0d66afd397e7b42d18b9dd0c000bf3d7696972 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 19 Nov 2023 20:28:50 +0700 Subject: [PATCH] Update subgraph rendering for loop, collection --- scripts/__node_3d/__node_3d.gml | 2 +- scripts/__node_iterator/__node_iterator.gml | 1 + scripts/node_collection/node_collection.gml | 15 +++++++++++---- scripts/node_data/node_data.gml | 4 ++-- scripts/node_group_output/node_group_output.gml | 11 +++-------- scripts/node_processor/node_processor.gml | 4 ++-- .../node_render_sprite_sheet.gml | 2 +- scripts/render_data/render_data.gml | 4 +++- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/scripts/__node_3d/__node_3d.gml b/scripts/__node_3d/__node_3d.gml index f0cd1b79f..245ab09c2 100644 --- a/scripts/__node_3d/__node_3d.gml +++ b/scripts/__node_3d/__node_3d.gml @@ -65,7 +65,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr D3D_GLOBAL_PREVIEW.camera.resetCamera(); } #endregion - static postUpdate = function() { refreshPreview(); } + static postProcess = function() { refreshPreview(); } static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) { #region if(!is_surface(mesh_prev_surface)) return; diff --git a/scripts/__node_iterator/__node_iterator.gml b/scripts/__node_iterator/__node_iterator.gml index ef75e0491..0be43bf75 100644 --- a/scripts/__node_iterator/__node_iterator.gml +++ b/scripts/__node_iterator/__node_iterator.gml @@ -50,6 +50,7 @@ function Node_Iterator(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) LOG_IF(global.FLAG.render == 1, "[outputNextNode] Get next node from Loop output"); var _nodes = []; + for( var i = 0; i < ds_list_size(nodes); i++ ) { // check if every node is updated if(!nodes[| i].rendered) { LOG_IF(global.FLAG.render == 1, $"Skipped due to node {nodes[| i].internalName} not rendered."); diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index 77f4c9e36..ef030940c 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -89,7 +89,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0); draw_dummy = false; - input_dummy.onSetFrom = function(juncFrom) { + input_dummy.onSetFrom = function(juncFrom) { #region ds_list_remove(juncFrom.value_to, input_dummy); input_dummy.value_from = noone; @@ -104,7 +104,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc input.inParent.setFrom(juncFrom); if(onNewInputFromGraph != noone) onNewInputFromGraph(juncFrom); - } + } #endregion onNewInputFromGraph = noone; @@ -292,6 +292,15 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc LOG_BLOCK_END(); } #endregion + static isActiveDynamic = function(frame = CURRENT_FRAME) { #region + if(update_on_frame) return true; + + for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) + if(inputs[| i].isActiveDynamic(frame) || !inputs[| i].from.rendered) return true; + + return false; + } #endregion + static exitGroup = function() {} static add = function(_node) { #region @@ -345,8 +354,6 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static onStep = function() {} - PATCH_STATIC - static onPreDraw = function(_x, _y, _s, _iny, _outy) { #region var xx = x * _s + _x; var yy = y * _s + _y; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index de1afc06d..23d07a303 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -526,7 +526,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x doUpdate(); } #endregion - static postupdate = function(frame = CURRENT_FRAME) {} + static postUpdate = function(frame = CURRENT_FRAME) {} static doUpdate = function(frame = CURRENT_FRAME) { #region if(PROJECT.safeMode) return; @@ -559,7 +559,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } } - postupdate(frame); + postUpdate(frame); cached_manual = false; if(!use_cache && PROJECT.onion_skin.enabled) { diff --git a/scripts/node_group_output/node_group_output.gml b/scripts/node_group_output/node_group_output.gml index d8505668d..45c182721 100644 --- a/scripts/node_group_output/node_group_output.gml +++ b/scripts/node_group_output/node_group_output.gml @@ -1,9 +1,10 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Group Output"; - destroy_when_upgroup = true; color = COLORS.node_blend_collection; previewable = false; + destroy_when_upgroup = true; + attributes.input_priority = 0; if(!CLONING && !LOADING && !APPENDING && group != noone) attributes.input_priority = group.getOutputFreeOrder(); @@ -16,7 +17,7 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr .setVisible(true, true); attributes.inherit_name = !LOADING && !APPENDING; - outParent = undefined; + outParent = undefined; output_index = -1; _onSetDisplayName = function() { attributes.inherit_name = false; } @@ -140,10 +141,4 @@ 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 } \ No newline at end of file diff --git a/scripts/node_processor/node_processor.gml b/scripts/node_processor/node_processor.gml index 239cd0cd6..66ce5d91d 100644 --- a/scripts/node_processor/node_processor.gml +++ b/scripts/node_processor/node_processor.gml @@ -330,10 +330,10 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct else processOutput(); processData_postbatch(); - postUpdate(); + postProcess(); } #endregion - static postUpdate = function() {} + static postProcess = function() {} static processSerialize = function(_map) { #region _map.array_process = attributes.array_process; diff --git a/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml b/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml index 4871c36f4..0d2637a82 100644 --- a/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml +++ b/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml @@ -70,7 +70,7 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group) update_on_frame = grup == 0; } #endregion - static postupdate = function(frame = CURRENT_FRAME) { + static postProcess = function(frame = CURRENT_FRAME) { if(LAST_FRAME) array_remove(RENDERING, node_id); } diff --git a/scripts/render_data/render_data.gml b/scripts/render_data/render_data.gml index 8f996131c..74900fd2e 100644 --- a/scripts/render_data/render_data.gml +++ b/scripts/render_data/render_data.gml @@ -140,7 +140,9 @@ function __nodeIsRenderLeaf(_node) { #region if(!_node.attributes.update_graph) { LOG_IF(global.FLAG.render == 1, $"Skip non-auto update [{_node.internalName}]"); return false; } if(_node.passiveDynamic) { _node.forwardPassiveDynamic(); LOG_IF(global.FLAG.render == 1, $"Skip passive dynamic [{_node.internalName}]"); return false; } - if(_node.rendered && !_node.isActiveDynamic()) { LOG_IF(global.FLAG.render == 1, $"Skip rendered static [{_node.internalName}]"); return false; } + + if((_node.rendered || (is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder)) && !_node.isActiveDynamic()) + { LOG_IF(global.FLAG.render == 1, $"Skip rendered static [{_node.internalName}]"); return false; } return true; } #endregion