fix render order bug

This commit is contained in:
Tanasart 2023-12-22 10:15:04 +07:00
parent 36bfafb4d7
commit e4c55a13b9
33 changed files with 151 additions and 87 deletions

View file

@ -127,7 +127,7 @@
{"name":"feedback","order":7,"path":"folders/nodes/data/iterate/feedback.yy",},
{"name":"for each","order":9,"path":"folders/nodes/data/iterate/for each.yy",},
{"name":"for filter","order":10,"path":"folders/nodes/data/iterate/for filter.yy",},
{"name":"for sort inline","order":11,"path":"folders/nodes/data/iterate/for sort inline.yy",},
{"name":"for sort","order":11,"path":"folders/nodes/data/iterate/for sort.yy",},
{"name":"lua","order":12,"path":"folders/nodes/data/lua.yy",},
{"name":"misc","order":10,"path":"folders/nodes/data/misc.yy",},
{"name":"MK effects","order":24,"path":"folders/nodes/data/MK effects.yy",},

View file

@ -154,7 +154,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"feedback","folderPath":"folders/nodes/data/iterate/feedback.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"for each","folderPath":"folders/nodes/data/iterate/for each.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"for filter","folderPath":"folders/nodes/data/iterate/for filter.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"for sort inline","folderPath":"folders/nodes/data/iterate/for sort inline.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"for sort","folderPath":"folders/nodes/data/iterate/for sort.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"for","folderPath":"folders/nodes/data/iterate/for.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"lua","folderPath":"folders/nodes/data/lua.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"misc","folderPath":"folders/nodes/data/misc.yy",},
@ -404,8 +404,6 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"execute_shell_simple_ext_x64.dll","CopyToMask":-1,"filePath":"datafiles/report",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"options.ini","CopyToMask":-1,"filePath":"datafiles/report",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"PXC crash reporter.exe","CopyToMask":-1,"filePath":"datafiles/report",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"arrowRight.png","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Bevel.png","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Broken heart.png","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Broken heart.pxc","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"card_back.png","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 918 B

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,018 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,013 B

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -272,7 +272,8 @@ event_inherited();
var start = category == NODE_CATEGORY? -2 : 0;
for(var i = start; i < ds_list_size(category); i++) {
var name = "";
var name = "";
var color = noone;
if(i == -2) name = "All";
else if(i == -1) name = "New";
@ -286,14 +287,18 @@ event_inherited();
setPage(NODE_PAGE_DEFAULT);
continue;
}
color = context.color;
draw_set_color(COLORS._main_text_accent);
}
}
var _hov = false;
BLEND_OVERRIDE
if(sHOVER && catagory_pane.hover && point_in_rectangle(_m[0], _m[1], 0, _y + hh, category_width - ui(32), _y + hh + hg - 1)) {
BLEND_OVERRIDE
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _y + hh, category_width - ui(32), hg, CDEF.main_white, 1);
BLEND_NORMAL
_hov = true;
if(i != ADD_NODE_PAGE && mouse_click(mb_left, sFOCUS)) {
@ -303,7 +308,6 @@ event_inherited();
content_pane.scroll_y_to = 0;
}
}
BLEND_NORMAL
var cc = COLORS._main_text_inner;
@ -319,7 +323,7 @@ event_inherited();
}
if(i == ADD_NODE_PAGE) draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text_accent);
else draw_set_text(f_p0, fa_left, fa_center, cc);
else draw_set_text(f_p0, fa_left, fa_center, cc);
var _is_extra = name == "Extra";
name = __txt(name);

View file

@ -3,14 +3,17 @@ function Node_VFX_Group_Inline(_x, _y, _group = noone) : Node_Collection_Inline(
color = COLORS.node_blend_vfx;
icon = THEME.vfx;
is_root = false;
topoList = ds_list_create();
inputs[| 0] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true )
.rejectArray();
topoList = ds_list_create();
update_on_frame = true;
managedRenderOrder = true;
prev_nodes = [];
if(!LOADING && !APPENDING && !CLONING) { #region
var input = nodeBuild("Node_VFX_Spawner", x, y);
var output = nodeBuild("Node_VFX_Renderer", x + 256, y);
@ -21,10 +24,18 @@ function Node_VFX_Group_Inline(_x, _y, _group = noone) : Node_Collection_Inline(
addNode(output);
} #endregion
static getNextNodes = function() { #region
return __nodeLeafList(nodes);
static clearTopoSorted = function() { INLINE topoSorted = false; prev_nodes = []; }
static getPreviousNodes = function() { #region
onGetPreviousNodes(prev_nodes);
return prev_nodes;
} #endregion
static onRemoveNode = function(node) { node.in_VFX = noone; }
static onAddNode = function(node) { node.in_VFX = self; }
static getNextNodes = function() { return __nodeLeafList(nodes); }
static reset = function() { #region
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var node = nodes[| i];

View file

@ -83,23 +83,7 @@ function Node_VFX_Spawner(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y
}
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
var spr = getInputData(0);
if(spr == 0) {
if(!is_surface(def_surface))
return;
spr = def_surface;
}
if(is_array(spr))
spr = spr[safe_mod(round(current_time / 100), array_length(spr))];
var cx = xx + w * _s / 2;
var cy = yy + h * _s / 2;
var ss = min((w - 8) / surface_get_width_safe(spr), (h - 8) / surface_get_height_safe(spr)) * _s;
draw_surface_align(spr, cx, cy, ss, fa_center, fa_center);
} #endregion
static getGraphPreviewSurface = function() { return getInputData(0); }
getPreviewingNode = VFX_PREVIEW_NODE;
}

View file

@ -14,22 +14,35 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
input_node_type = noone;
output_node_type = noone;
is_root = true;
static topoSortable = function() { #region
return false;
} #endregion
static removeNode = function(node) { #region
array_remove(attributes.members, node.node_id);
ds_list_remove(nodes, node);
array_remove(node.context_data, self);
onRemoveNode(node);
} #endregion
static onRemoveNode = function(node) {}
static addNode = function(node) { #region
if(array_exists(attributes.members, node.node_id)) return;
array_push_unique(attributes.members, node.node_id);
array_push(attributes.members, node.node_id);
ds_list_add(nodes, node);
if(!ds_list_exist(nodes, node))
ds_list_add(nodes, node);
array_push_unique(node.context_data, self);
onAddNode(node);
} #endregion
static onAddNode = function(node) {}
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(_ind, _vertex, _node) { #region
@ -58,9 +71,7 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
continue;
}
var _node = PROJECT.nodeMap[? attributes.members[i]];
array_push_unique(_node.context_data, self);
ds_list_add(nodes, _node);
addNode(PROJECT.nodeMap[? attributes.members[i]]);
}
} #endregion
@ -138,22 +149,20 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
group_adding = false;
if(PANEL_GRAPH.node_dragging && key_mod_press(SHIFT)) {
var side = undefined;
var _list = PANEL_GRAPH.nodes_selecting;
if(group_hovering) {
group_adding = true;
for( var i = 0, n = array_length(_list); i < n; i++ )
array_push_unique(attributes.members, _list[i].node_id);
addNode(_list[i]);
} else {
for( var i = 0, n = array_length(_list); i < n; i++ )
array_remove(attributes.members, _list[i].node_id);
removeNode(_list[i]);
}
if(!group_dragging) {
for( var i = 0, n = array_length(_list); i < n; i++ )
array_remove(attributes.members, _list[i].node_id);
removeNode(_list[i]);
refreshMember();
refreshGroupBG();
}
@ -191,7 +200,8 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
draw_set_color(_color);
group_hover_al = lerp_float(group_hover_al, group_hovering, 4);
draw_set_alpha(_sel? 0.1 : 0.025 + 0.050 * group_hover_al);
group_hovering = 0;
draw_set_alpha(_sel? 0.1 : 0.025 + 0.025 * group_hover_al);
draw_primitive_begin(pr_trianglelist);
var a = group_vertex[0];
@ -208,12 +218,14 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
var v2x = _x + c[0] * _s;
var v2y = _y + c[1] * _s;
draw_vertex(v0x, v0y);
draw_vertex(v1x, v1y);
draw_vertex(v2x, v2y);
draw_vertex(round(v0x), round(v0y));
draw_vertex(round(v1x), round(v1y));
draw_vertex(round(v2x), round(v2y));
if(!_hov && point_in_triangle(_mx, _my, v0x, v0y, v1x, v1y, v2x, v2y))
if(!_hov && point_in_triangle(_mx, _my, v0x, v0y, v1x, v1y, v2x, v2y)) {
group_hovering = 1 + key_mod_press(SHIFT) * 2;
_hov = true;
}
b = group_vertex[i];
}
@ -232,7 +244,6 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
draw_set_alpha(1);
group_hovering = _hov;
return _hov;
} #endregion

View file

@ -210,6 +210,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
temp_surface = [];
force_requeue = false;
in_VFX = false;
is_group_io = false;
#endregion
@ -683,7 +685,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
LOG_BLOCK_END();
} #endregion
static clearTopoSorted = function() { INLINE topoSorted = false; }
static forwardPassiveDynamic = function() { #region
rendered = false;
for( var i = 0, n = ds_list_size(outputs); i < n; i++ ) {
var _outp = outputs[| i];
@ -692,6 +698,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(!_to.node.active || _to.value_from != _outp) continue;
_to.node.passiveDynamic = true;
_to.node.rendered = false;
}
}
} #endregion
@ -701,10 +708,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
if(_clearCache) clearInputCache();
} #endregion
static isLeaf = function() { #region
static isLeaf = function(list = noone) { #region
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
var _inp = inputs[| i];
if(!_inp.isLeaf()) return false;
if(!_inp.isLeaf(list)) return false;
}
return true;
@ -722,6 +729,32 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
return true;
} #endregion
static getPreviousNodes = function() { #region
var prev = [];
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
var _in = inputs[| i];
if(_in.value_from != noone) {
if(in_VFX && !_in.value_from.node.in_VFX) {
array_push(in_VFX.prev_nodes, _in.value_from.node);
array_push(prev, in_VFX);
continue;
}
array_push_unique(prev, _in.value_from.node);
}
if(_in.value_from_loop != noone)
array_push_unique(prev, _in.value_from_loop);
}
onGetPreviousNodes(prev);
return prev;
} #endregion
static onGetPreviousNodes = function(arr) {}
static getNextNodes = function() { #region
var nodes = [];
var nodeNames = [];
@ -732,8 +765,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
for(var i = 0; i < ds_list_size(outputs); i++) {
var _ot = outputs[| i];
if(!_ot.forward) continue;
if(_ot.type == VALUE_TYPE.node) continue;
if(!_ot.forward) continue;
for( var j = 0, n = array_length(_ot.value_to_loop); j < n; j++ ) {
var _to = _ot.value_to_loop[j];

View file

@ -4,6 +4,7 @@ function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) con
icon = THEME.feedback;
icon_24 = THEME.feedback_24;
is_root = false;
selectable = false;
update_on_frame = true;

View file

@ -2,6 +2,7 @@ function Node_Iterate_Each_Inline(_x, _y, _group = noone) : Node_Collection_Inli
name = "Loop Array";
color = COLORS.node_blend_loop;
is_root = false;
input_node = noone;
output_node = noone;

View file

@ -2,6 +2,7 @@ function Node_Iterate_Filter_Inline(_x, _y, _group = noone) : Node_Collection_In
name = "Filter Array";
color = COLORS.node_blend_loop;
is_root = false;
input_node = noone;
output_node = noone;

View file

@ -4,6 +4,8 @@ function Node_Iterate_Inline(_x, _y, _group = noone) : Node_Collection_Inline(_x
icon = THEME.loop;
icon_24 = THEME.loop_24;
is_root = false;
inputs[| 0] = nodeValue("Repeat", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 )
.uncache();

View file

@ -2,6 +2,7 @@ function Node_Iterate_Sort_Inline(_x, _y, _group = noone) : Node_Collection_Inli
name = "Sort Array";
color = COLORS.node_blend_loop;
is_root = false;
topoList = ds_list_create();
input_node = noone;
@ -143,10 +144,7 @@ function Node_Iterate_Sort_Inline(_x, _y, _group = noone) : Node_Collection_Inli
arrOut = array_clone(arrIn);
print($"===== Sort begin =====");
quickSort(arrOut, 0, array_length(arrOut) - 1);
print($"Sorted {arrIn} > {arrOut}")
output_node.outputs[| 0].setValue(arrOut);
} #endregion

View file

@ -5,7 +5,7 @@
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "for sort inline",
"path": "folders/nodes/data/iterate/for sort inline.yy",
"name": "for sort",
"path": "folders/nodes/data/iterate/for sort.yy",
},
}

View file

@ -8,6 +8,10 @@ function Node_Iterator_Each_Inline_Input(_x, _y, _group = noone) : Node(_x, _y,
outputs[| 0] = nodeValue("Value in", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0 );
static onGetPreviousNodes = function(arr) {
array_push(arr, loop);
}
static update = function() { #region
if(!is_instanceof(loop, Node_Iterate_Each_Inline)) return;

View file

@ -8,6 +8,10 @@ function Node_Iterator_Filter_Inline_Input(_x, _y, _group = noone) : Node(_x, _y
outputs[| 0] = nodeValue("Value in", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0 );
static onGetPreviousNodes = function(arr) {
array_push(arr, loop);
}
static update = function() { #region
if(!is_instanceof(loop, Node_Iterate_Filter_Inline)) return;

View file

@ -9,4 +9,9 @@ function Node_Iterator_Sort_Inline_Input(_x, _y, _group = noone) : Node(_x, _y,
outputs[| 0] = nodeValue("Value 1", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0 );
outputs[| 1] = nodeValue("Value 2", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0 );
static onGetPreviousNodes = function(arr) {
array_push(arr, loop);
}
}

View file

@ -5,7 +5,7 @@
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "for sort inline",
"path": "folders/nodes/data/iterate/for sort inline.yy",
"name": "for sort",
"path": "folders/nodes/data/iterate/for sort.yy",
},
}

View file

@ -5,7 +5,7 @@
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "for sort inline",
"path": "folders/nodes/data/iterate/for sort inline.yy",
"name": "for sort",
"path": "folders/nodes/data/iterate/for sort.yy",
},
}

View file

@ -634,8 +634,7 @@ function __initNodes() {
ds_list_add(generator, "Simulation");
addNodeObject(generator, "Particle", s_node_particle, "Node_Particle", [1, Node_Particle],, "Generate particle effect.");
addNodeObject(generator, "VFX", s_node_vfx, "Node_VFX_Group", [1, Node_VFX_Group],, "Create VFX group, which generate particles that can be manipulated using different force nodes.");
addNodeObject(generator, "Inline VFX", s_node_vfx, "Node_VFX_Group_Inline", [1, Node_VFX_Group_Inline],, "Create VFX group, which generate particles that can be manipulated using different force nodes.");
addNodeObject(generator, "VFX", s_node_vfx, "Node_VFX_Group_Inline", [1, Node_VFX_Group_Inline],, "Create VFX group, which generate particles that can be manipulated using different force nodes.");
addNodeObject(generator, "RigidSim", s_node_rigidSim, "Node_Rigid_Group_Inline", [1, Node_Rigid_Group_Inline],, "Create group for rigidbody simulation.").setVersion(1110);
addNodeObject(generator, "SmokeSim", s_node_smokeSim_group, "Node_Fluid_Group_Inline", [1, Node_Fluid_Group_Inline],, "Create group for fluid simulation.").setVersion(1120);
addNodeObject(generator, "StrandSim", s_node_strandSim, "Node_Strand_Group_Inline", [1, Node_Strand_Group_Inline], ["Hair"], "Create group for hair simulation.").setVersion(1140);
@ -745,7 +744,7 @@ function __initNodes() {
addNodeObject(values, "Filter Array", s_node_filter_array, "Node_Iterate_Filter_Inline", [1, Node_Iterate_Filter_Inline],, "Filter array using condition.").setVersion(1140);
addNodeObject(values, "Sort Array", s_node_sort_array, "Node_Iterate_Sort_Inline", [1, Node_Iterate_Sort_Inline],, "Sort array using node graph.").setVersion(1143);
addNodeObject(values, "Parse CSV", s_node_csv_parse, "Node_Array_CSV_Parse", [1, Node_Array_CSV_Parse]).setVersion(1145);
ds_list_add(values, "Paths");
addNodeObject(values, "Path", s_node_path, "Node_Path", [1, Node_Path]);
addNodeObject(values, "Path Anchor", s_node_path_anchor, "Node_Path_Anchor", [1, Node_Path_Anchor]).setVersion(1140);
@ -1019,6 +1018,7 @@ function __initNodes() {
addNodeObject(hid, "StrandSim", s_node_strandSim, "Node_Strand_Group", [1, Node_Strand_Group], ["Hair"], "Create group for hair simulation.").setVersion(1140).hideRecent();
addNodeObject(hid, "Feedback", s_node_feedback, "Node_Feedback_Inline", [1, Node_Feedback_Inline]).hideRecent();
addNodeObject(hid, "Loop", s_node_loop, "Node_Iterate_Inline", [1, Node_Iterate_Inline]).hideRecent();
addNodeObject(hid, "VFX", s_node_vfx, "Node_VFX_Group", [1, Node_VFX_Group]).hideRecent();
addNodeObject(hid, "Loop Array", s_node_loop_array, "Node_Iterate_Each", [1, Node_Iterate_Each]).hideRecent();
addNodeObject(hid, "Loop Input", s_node_loop_array, "Node_Iterator_Each_Inline_Input", [1, Node_Iterator_Each_Inline_Input]).hideRecent();

View file

@ -1951,7 +1951,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return 1;
} #endregion
static isLeaf = function() { INLINE return value_from == noone; }
static isLeaf = function(list = noone) { INLINE return (value_from == noone) || (list != noone && !ds_list_exist(list, value_from.node)); }
static isRendered = function() { #region
if(type == VALUE_TYPE.node) return true;

View file

@ -21,14 +21,12 @@ function __nodeLeafList(_list) { #region
for( var i = 0, n = ds_list_size(_list); i < n; i++ ) {
var _node = _list[| i];
if(!_node.active) continue;
if(!_node.isRenderActive()) continue;
if(!_node.isLeaf()) continue;
if(!_node.active) { LOG_LINE_IF(global.FLAG.render == 1, $"Reject {_node.internalName} [inactive]"); continue; }
if(!_node.isLeaf(_list)) { LOG_LINE_IF(global.FLAG.render == 1, $"Reject {_node.internalName} [not leaf]"); continue; }
if(!_node.isRenderable()) { LOG_LINE_IF(global.FLAG.render == 1, $"Reject {_node.internalName} [not renderable]"); continue; }
if(_node.isRenderable()) {
array_push(nodes, _node);
array_push(nodeNames, _node.internalName);
}
array_push(nodes, _node);
array_push(nodeNames, _node.internalName);
}
LOG_LINE_IF(global.FLAG.render == 1, $"Push node {nodeNames} to queue");
@ -58,7 +56,7 @@ function NodeTopoSort() { #region
repeat(amo) {
var _node = PROJECT.nodeMap[? _key];
_node.topoSorted = false;
_node.clearTopoSorted();
_key = ds_map_find_next(PROJECT.nodeMap, _key);
}
@ -70,11 +68,17 @@ function NodeTopoSort() { #region
function __sortGraph(_list, _nodeList) { #region
var _root = [];
var _leftOver = [];
for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ ) {
var _node = _nodeList[| i];
var _isRoot = true;
if(is_instanceof(_node, Node_Collection_Inline) && !_node.is_root) {
array_push(_leftOver, _node);
continue;
}
for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) {
var _to = _node.outputs[| j].getJunctionTo();
@ -91,26 +95,25 @@ function __sortGraph(_list, _nodeList) { #region
if(_isRoot) array_push(_root, _node);
}
var _st = ds_stack_create();
var _st = ds_queue_create();
for( var i = 0, n = array_length(_root); i < n; i++ )
ds_stack_push(_st, _root[i]);
ds_queue_enqueue(_st, _root[i]);
while(!ds_stack_empty(_st)) {
var _node = ds_stack_pop(_st);
while(!ds_queue_empty(_st)) {
var _node = ds_queue_dequeue(_st);
if(_node.topoSorted) continue;
var _childs = [];
var _prev = _node.getPreviousNodes();
for( var i = 0, n = ds_list_size(_node.inputs); i < n; i++ ) {
var _in = _node.inputs[| i];
var _fr = _in.value_from;
for( var i = 0, n = array_length(_prev); i < n; i++ ) {
var _in = _prev[i];
if(_fr == noone) continue;
if(!ds_list_exist(_nodeList, _fr.node)) continue;
if(_fr.node.topoSorted) continue;
if(!ds_list_exist(_nodeList, _in)) continue;
if(_in.topoSorted) continue;
array_push(_childs, _fr.node);
array_push(_childs, _in);
}
if(array_empty(_childs)) {
@ -120,11 +123,16 @@ function __sortGraph(_list, _nodeList) { #region
if(is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder)
__sortGraph(_list, _node.nodes);
} else {
ds_stack_push(_st, _node);
for( var i = 0, n = array_length(_childs); i < n; i++ )
ds_stack_push(_st, _childs[i]);
ds_queue_enqueue(_st, _childs[i]);
ds_queue_enqueue(_st, _node);
}
}
for( var i = 0, n = array_length(_leftOver); i < n; i++ ) {
if(!_leftOver[i].topoSorted)
ds_list_insert(_list, 0, _leftOver[i]);
}
} #endregion
function NodeListSort(_list, _nodeList) { #region
@ -138,9 +146,9 @@ function NodeListSort(_list, _nodeList) { #region
function __nodeIsRenderLeaf(_node) { #region
if(is_undefined(_node)) { LOG_IF(global.FLAG.render == 1, $"Skip undefiend [{_node}]"); return false; }
if(!is_instanceof(_node, Node)) { LOG_IF(global.FLAG.render == 1, $"Skip non-node [{_node}]"); return false; }
if(_node.is_group_io) { LOG_IF(global.FLAG.render == 1, $"Skip group IO [{_node.internalName}]"); return false; }
if(!_node.active) { LOG_IF(global.FLAG.render == 1, $"Skip inactive [{_node.internalName}]"); return false; }
if(!_node.isRenderActive()) { LOG_IF(global.FLAG.render == 1, $"Skip render inactive [{_node.internalName}]"); return false; }
if(!_node.attributes.update_graph) { LOG_IF(global.FLAG.render == 1, $"Skip non-auto update [{_node.internalName}]"); return false; }
@ -172,7 +180,7 @@ function Render(partial = false, runAction = false) { #region
if(reset_all) {
var _key = ds_map_find_first(PROJECT.nodeMap);
var amo = ds_map_size(PROJECT.nodeMap);
repeat(amo) {
var _node = PROJECT.nodeMap[? _key];
_node.setRenderStatus(false);