optimization

This commit is contained in:
Tanasart 2024-01-26 20:38:50 +07:00
parent 6fddeedd5f
commit d5722deaf2
22 changed files with 309 additions and 247 deletions

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

@ -715,13 +715,13 @@ event_inherited();
for(var j = 0; j < ds_list_size(_content); j++) {
var _node = _content[| j];
if(is_string(_node)) continue;
if(ds_map_exists(search_map, _node)) continue;
if(struct_try_get(_node, "deprecated")) continue;
if(is_string(_node)) continue;
if(ds_map_exists(search_map, _node)) continue;
if(is_instanceof(_node, NodeObject)) {
if(_node.is_patreon_extra && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue;
if(_node.deprecated) continue;
}
var match = string_partial_match(string_lower(_node.getName()), search_lower);

View file

@ -11,7 +11,7 @@ function __initCollection() {
zip_unzip("data/Collections.zip", root);
COLLECTIONS = new DirectoryObject("Collections", DIRECTORY + "Collections");
COLLECTIONS.open = true;
refreshCollections();
}
function refreshCollections() {

View file

@ -25,10 +25,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
LATEST_VERSION = 11600;
VERSION = 11640;
SAVE_VERSION = 11640;
VERSION_STRING = "1.16.4.0";
BUILD_NUMBER = 11640;
VERSION = 11650;
SAVE_VERSION = 11650;
VERSION_STRING = "1.16.5.0";
BUILD_NUMBER = 11650;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -50,6 +50,8 @@ function LOAD_PATH(path, readonly = false, safe_mode = false) { #region
} #endregion
function __LOAD_PATH(path, readonly = false, override = false) { #region
//print($"========== Loading {path} =========="); var t = get_timer();
if(DEMO) return false;
if(!file_exists_empty(path)) {
@ -250,6 +252,8 @@ function __LOAD_PATH(path, readonly = false, override = false) { #region
run_in(1, PANEL_GRAPH.toCenterNode);
//print($"========== Load completed in {(get_timer() - t) / 1000} ms ==========");
return true;
} #endregion

View file

@ -25,7 +25,7 @@ function Node_create_ASE_File_Read_path(_x, _y, path) { #region
function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "ASE File In";
update_on_frame = true;
update_on_frame = false;
w = 128;
@ -162,10 +162,10 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
attributes.layer_visible = [];
content = ds_map_create();
layers = [];
tags = [];
_tag_delay = 0;
content = ds_map_create();
layers = [];
tags = [];
_tag_delay = 0;
path_current = "";
first_update = false;
@ -279,6 +279,14 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
tags = chunk[? "Tags"];
}
update_on_frame = false;
for( var i = 0, n = array_length(layers); i < n; i++ ) {
if(!struct_has(layers[i], "cel")) continue;
var cel = layers[i].cel;
if(array_length(cel)) update_on_frame = true;
}
return true;
} #endregion
@ -289,13 +297,8 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
var path = getInputData(0);
if(path == "") return;
updatePaths(path);
update();
for( var j = 0; j < array_length(outputs[| 1].value_to); j++ ) {
var _targNode = outputs[| 1].value_to[j].node;
_targNode._name = "";
_targNode.update();
}
triggerRender();
} #endregion
static update = function(frame = CURRENT_FRAME) { #region

View file

@ -1,6 +1,5 @@
function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "ASE Layer";
update_on_frame = true;
inputs[| 0] = nodeValue("ASE data", self, JUNCTION_CONNECT.input, VALUE_TYPE.object, noone)
.setVisible(false, true)

View file

@ -4,22 +4,23 @@ enum COLLECTION_TAG {
}
function groupNodes(nodeArray, _group = noone, record = true, check_connect = true) { #region
var _ctx_nodes = [];
#region check inline
var _ctx_nodes = [];
for(var i = 0; i < array_length(nodeArray); i++) {
var node = nodeArray[i];
for(var i = 0; i < array_length(nodeArray); i++) {
var node = nodeArray[i];
var ctx = node.inline_context;
if(node.inline_context != noone) {
array_push_unique(_ctx_nodes, node.inline_context);
if(ctx == noone) continue;
array_push_unique(_ctx_nodes, ctx);
for( var k = 0, n = array_length(node.inline_context.members); k < n; k++ ) {
if(!array_exists(nodeArray, node.inline_context.members[k])) {
noti_warning("Grouping incomplete inline group is not allowed.");
return;
}
for( var k = 0, n = array_length(ctx.members); k < n; k++ ) {
if(array_exists(nodeArray, ctx.members[k])) continue;
noti_warning("Grouping incomplete inline group is not allowed.");
return;
}
}
}
}
#endregion
UNDO_HOLDING = true;
@ -31,8 +32,9 @@ function groupNodes(nodeArray, _group = noone, record = true, check_connect = tr
cx += _node.x;
cy += _node.y;
}
cx = round(cx / array_length(nodeArray) / 32) * 32;
cy = round(cy / array_length(nodeArray) / 32) * 32;
cx = value_snap(cx / array_length(nodeArray), 32);
cy = value_snap(cy / array_length(nodeArray), 32);
_group = new Node_Group(cx, cy, PANEL_GRAPH.getCurrentContext());
}
@ -49,13 +51,69 @@ function groupNodes(nodeArray, _group = noone, record = true, check_connect = tr
_content[i] = _ctx_nodes[i];
}
var _io = [];
if(check_connect)
for(var i = 0; i < array_length(nodeArray); i++)
array_append(_io, nodeArray[i].checkConnectGroup());
var _io = { inputs: {}, outputs: {}, map: {} };
if(check_connect) { #region IO creation
for(var i = 0; i < array_length(nodeArray); i++)
nodeArray[i].checkConnectGroup(_io);
var _in = _io.inputs;
var _inKey = struct_get_names(_in);
var _x, _y, m;
for( var i = 0, n = array_length(_inKey); i < n; i++ ) {
var _frm = _io.map[$ _inKey[i]];
var _tos = _in[$ _inKey[i]];
_x = 0
_y = 0;
m = array_length(_tos);
for( var j = 0; j < m; j++ ) {
var _to = _tos[j];
_x = min(_x, _to.node.x);
_y += _to.node.y;
}
_x = value_snap(_x - 64 - 128, 32);
_y = value_snap(_y / m, 32);
var _n = new Node_Group_Input(_x, _y, _group);
_n.inputs[| 2].setValue(_frm.type);
_n.onValueUpdate(0);
_n.inParent.setFrom(_frm);
for( var j = 0; j < m; j++ ) {
var _to = _tos[j];
_to.setFrom(_n.outputs[| 0]);
}
}
var _ot = _io.outputs;
var _otKey = struct_get_names(_ot);
for( var i = 0, n = array_length(_otKey); i < n; i++ ) {
var _frm = _io.map[$ _otKey[i]];
var _tos = _ot[$ _otKey[i]];
_x = value_snap(_frm.node.x + _frm.node.w + 64, 32);
_y = value_snap(_frm.node.y, 32);
m = array_length(_tos);
var _n = new Node_Group_Output(_x, _y, _group);
_n.inputs[| 0].setFrom(_frm);
for( var j = 0; j < m; j++ ) {
var _to = _tos[j];
_to.setFrom(_n.outParent);
}
}
} #endregion
UNDO_HOLDING = false;
if(record) recordAction(ACTION_TYPE.group, _group, { io: _io, content: _content });
if(record) recordAction(ACTION_TYPE.group, _group, { content: _content });
return _group;
} #endregion
@ -63,13 +121,11 @@ function groupNodes(nodeArray, _group = noone, record = true, check_connect = tr
function upgroupNode(collection, record = true) { #region
UNDO_HOLDING = true;
var _content = [];
var _io = [];
var node_list = collection.getNodeList();
while(!ds_list_empty(node_list)) {
var remNode = node_list[| 0];
if(remNode.destroy_when_upgroup)
array_push(_io, remNode);
else
if(!remNode.destroy_when_upgroup)
array_push(_content, remNode);
collection.remove(remNode);
@ -78,7 +134,7 @@ function upgroupNode(collection, record = true) { #region
nodeDelete(collection);
UNDO_HOLDING = false;
if(record) recordAction(ACTION_TYPE.ungroup, collection, { io: _io, content: _content });
if(record) recordAction(ACTION_TYPE.ungroup, collection, { content: _content });
} #endregion
function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {

View file

@ -926,7 +926,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
static onPreDraw = function(_x, _y, _s, _iny, _outy) {}
static isHighlightingInGraph = function() { #region
var high = struct_try_get(display_parameter, "highlight", 0);
var high = display_parameter.highlight;
var _selc = active_draw_index == 0 || branch_drawing;
return !high || _selc;
} #endregion
@ -1109,8 +1109,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
var hovering = noone;
var drawLineIndex = 1;
var high = struct_try_get(params, "highlight", 0);
var bg = struct_try_get(params, "bg", c_black);
var high = params.highlight; // 0
var bg = params.bg; // 0
for(var i = 0; i < ds_list_size(outputs); i++) {
var jun = outputs[| i];
@ -1400,9 +1400,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
static drawActive = function(_x, _y, _s, ind = 0) { #region
active_draw_index = ind;
var high = struct_try_get(display_parameter, "highlight", 0);
if(high) drawBranch();
if(display_parameter.highlight) drawBranch();
} #endregion
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {}
@ -1582,57 +1580,42 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
}
} #endregion
static checkConnectGroup = function(_type = "group") { #region
var _y = y;
var nodes = [];
static checkConnectGroup = function(_io) { #region
var _y = y;
var _n = noone;
for(var i = 0; i < ds_list_size(inputs); i++) {
var _in = inputs[| i];
if(_in.isLeaf()) continue;
if(_in.value_from.node.group == group) continue;
var input_node = noone;
if(_in.isLeaf()) continue;
if(_in.value_from.node.group == group) continue;
switch(_type) {
case "group" : input_node = new Node_Group_Input(x - w - 64, _y, group); break;
case "loop" : input_node = new Node_Iterator_Input(x - w - 64, _y, group); break;
case "feedback" : input_node = new Node_Feedback_Input(x - w - 64, _y, group); break;
}
if(input_node == noone) continue;
var _ind = string(_in.value_from);
_io.map[$ _ind] = _in.value_from;
array_push(nodes, input_node);
input_node.inputs[| 2].setValue(_in.type);
input_node.inParent.setFrom(_in.value_from);
input_node.onValueUpdate(0);
_in.setFrom(input_node.outputs[| 0]);
_y += 64;
if(struct_has(_io.inputs, _ind))
array_push(_io.inputs[$ _ind ], _in);
else
_io.inputs[$ _ind ] = [ _in ];
}
for(var i = 0; i < ds_list_size(outputs); i++) {
var _ou = outputs[| i];
for(var j = 0; j < array_length(_ou.value_to); j++) {
var _to = _ou.value_to[j];
if(_to.value_from != _ou) continue;
if(!_to.node.active) continue;
if(_to.value_from != _ou) continue;
if(!_to.node.active) continue;
if(_to.node.group == group) continue;
var output_node = noone;
switch(_type) {
case "group" : output_node = new Node_Group_Output(x + w + 64, y, group); break;
case "loop" : output_node = new Node_Iterator_Output(x + w + 64, y, group); break;
case "feedback" : output_node = new Node_Feedback_Output(x + w + 64, y, group); break;
}
if(output_node == noone) continue;
var _ind = string(_ou);
_io.map[$ _ind] = _ou;
array_push(nodes, output_node);
_to.setFrom(output_node.outParent);
output_node.inputs[| 0].setFrom(_ou);
if(struct_has(_io.outputs, _ind))
array_push(_io.outputs[$ _ind ], _to);
else
_io.outputs[$ _ind ] = [ _to ];
}
}
return nodes;
} #endregion
static isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; }
@ -2055,5 +2038,5 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
return surface_get_format(_s);
} #endregion
static toString = function() { return $"PixelComposerNode [{internalName}]: {node_id}"; }
static toString = function() { return $"Node [{internalName}]: {node_id}"; }
}

View file

@ -11,12 +11,6 @@ function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) con
selectable = false;
update_on_frame = true;
draw_line_feed = true;
draw_line_shift_x = 0;
draw_line_shift_y = 0;
draw_line_thick = 1;
draw_line_shift_hover = false;
attributes.junc_in = [ "", 0 ];
attributes.junc_out = [ "", 0 ];
@ -70,7 +64,7 @@ function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) con
if(!junc_in || !junc_out) return;
if(!junc_in.node.active || !junc_out.node.active) return;
if(drawJuncConnection(junc_out, junc_in, params, self))
if(drawJuncConnection(junc_out, junc_in, params))
return self;
} #endregion

View file

@ -11,12 +11,6 @@ function Node_Iterate_Inline(_x, _y, _group = noone) : Node_Collection_Inline(_x
managedRenderOrder = true;
draw_line_feed = true;
draw_line_shift_x = 0;
draw_line_shift_y = 0;
draw_line_thick = 1;
draw_line_shift_hover = false;
attributes.junc_in = [ "", 0 ];
attributes.junc_out = [ "", 0 ];
@ -92,7 +86,7 @@ function Node_Iterate_Inline(_x, _y, _group = noone) : Node_Collection_Inline(_x
if(!junc_in || !junc_out) return;
if(!junc_in.node.active || !junc_out.node.active) return;
if(drawJuncConnection(junc_out, junc_in, params, self))
if(drawJuncConnection(junc_out, junc_in, params))
return self;
} #endregion

View file

@ -633,6 +633,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
draw_line_thick = 1;
draw_line_shift_hover = false;
draw_line_blend = 1;
draw_line_feed = false;
drawLineIndex = 1;
draw_line_vb = noone;
draw_junction_index = type;
@ -1478,8 +1479,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
#endregion
if(display_type == VALUE_DISPLAY.area) { #region
var dispType = struct_try_get(nodeFrom.display_data, "area_type");
var surfGet = struct_try_get(nodeFrom.display_data, "onSurfaceSize");
var dispType = nodeFrom.display_data.area_type;
var surfGet = nodeFrom.display_data.onSurfaceSize;
if(!applyUnit) return value;
if(!is_callable(surfGet)) return value;
@ -1511,7 +1512,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(display_type == VALUE_DISPLAY.d3quarternion) { #region
if(!applyUnit) return value;
var dispType = struct_try_get(display_data, "angle_display");
var dispType = display_data.angle_display;
switch(dispType) {
case QUARTERNION_DISPLAY.quarterion :
@ -1922,21 +1923,24 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static setValueDirect = function(val = 0, index = noone, record = true, time = CURRENT_FRAME, _update = true) { #region
is_modified = true;
var updated = false;
var _val;
var _val = val;
var _inp = connect_type == JUNCTION_CONNECT.input;
if(sep_axis) {
if(index == noone) {
for( var i = 0, n = array_length(animators); i < n; i++ )
updated |= animators[i].setValue(val[i], connect_type == JUNCTION_CONNECT.input && record, time);
updated |= animators[i].setValue(val[i], _inp && record, time);
} else
updated = animators[index].setValue(val, connect_type == JUNCTION_CONNECT.input && record, time);
updated = animators[index].setValue(val, _inp && record, time);
} else {
if(index != noone) {
_val = variable_clone(animator.getValue(time));
_val = animator.getValue(time);
if(_inp) _val = variable_clone(_val);
_val[index] = val;
} else
_val = val;
updated = animator.setValue(_val, connect_type == JUNCTION_CONNECT.input && record, time);
}
updated = animator.setValue(_val, _inp && record, time);
}
if(type == VALUE_TYPE.gradient) updated = true;
@ -1947,7 +1951,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(!updated) return false;
if(value_tag == "dimension" && struct_try_get(node.attributes, "use_project_dimension"))
if(value_tag == "dimension")
node.attributes.use_project_dimension = false;
draw_junction_index = type;
@ -2311,7 +2315,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static drawConnectionMouse = function(params, _mx, _my, target) { #region
var ss = params.s;
var aa = struct_try_get(params, "aa", 1);
var aa = params.aa; // 1
var drawCorner = type == VALUE_TYPE.action;
if(target != noone)
@ -2627,15 +2631,16 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
animator.cleanUp();
delete animator;
} #endregion
static toString = function() { return (connect_type == JUNCTION_CONNECT.input? "Input" : "Output") + $" junction {index} of [{name}]: {node}"; }
}
function drawJuncConnection(from, to, params, target = to) { #region
function drawJuncConnection(from, to, params) { #region
#region parameters
var log = struct_try_get(params, "log", false);
var high = struct_try_get(params, "highlight", 0);
var bg = struct_try_get(params, "bg", c_black);
var aa = struct_try_get(params, "aa", 1);
var feed = struct_try_get(target, "draw_line_feed", false);
var log = params.log;
var high = params.highlight;
var bg = params.bg;
var aa = params.aa;
var _x = params.x;
var _y = params.y;
@ -2657,7 +2662,7 @@ function drawJuncConnection(from, to, params, target = to) { #region
var fromIndex = from.drawLineIndex;
var toIndex = to.drawLineIndex;
if(struct_has(params, "minx")) {
if(params.minx != 0 && params.maxx != 0) {
var minx = params.minx;
var miny = params.miny;
var maxx = params.maxx;
@ -2670,15 +2675,15 @@ function drawJuncConnection(from, to, params, target = to) { #region
if(jy > maxy && fry > maxy) return noone;
}
var shx = target.draw_line_shift_x * _s;
var shy = target.draw_line_shift_y * _s;
var shx = to.draw_line_shift_x * _s;
var shy = to.draw_line_shift_y * _s;
var cx = round((frx + jx) / 2 + shx);
var cy = round((fry + jy) / 2 + shy);
var hover = false;
var th = max(1, PREFERENCES.connection_line_width * _s);
target.draw_line_shift_hover = false;
var th = max(1, PREFERENCES.connection_line_width * _s);
to.draw_line_shift_hover = false;
var downDirection = to.type == VALUE_TYPE.action || from.type == VALUE_TYPE.action;
#endregion
@ -2687,7 +2692,7 @@ function drawJuncConnection(from, to, params, target = to) { #region
var hovDist = max(th * 2, 6);
if(PANEL_GRAPH.pHOVER) {
if(feed && from.node == to.node) {
if(from.node == to.node) {
hover = distance_line_feedback(mx, my, jx, jy, frx, fry, _s) < hovDist;
} else {
switch(PREFERENCES.curve_connection_line) {
@ -2699,21 +2704,21 @@ function drawJuncConnection(from, to, params, target = to) { #region
else hover = distance_to_curve(mx, my, jx, jy, frx, fry, cx, cy, _s) < hovDist;
if(PANEL_GRAPH.value_focus == noone)
target.draw_line_shift_hover = hover;
to.draw_line_shift_hover = hover;
break;
case 2 :
if(downDirection) hover = distance_to_elbow_corner(mx, my, frx, fry, jx, jy) < hovDist;
else hover = distance_to_elbow(mx, my, frx, fry, jx, jy, cx, cy, _s, fromIndex, toIndex) < hovDist;
if(PANEL_GRAPH.value_focus == noone)
target.draw_line_shift_hover = hover;
to.draw_line_shift_hover = hover;
break;
case 3 :
if(downDirection) hover = distance_to_elbow_diag_corner(mx, my, frx, fry, jx, jy) < hovDist;
else hover = distance_to_elbow_diag(mx, my, frx, fry, jx, jy, cx, cy, _s, fromIndex, toIndex) < hovDist;
if(PANEL_GRAPH.value_focus == noone)
target.draw_line_shift_hover = hover;
to.draw_line_shift_hover = hover;
break;
}
}
@ -2737,11 +2742,6 @@ function drawJuncConnection(from, to, params, target = to) { #region
if(to.type == VALUE_TYPE.node)
ty = LINE_STYLE.dashed;
if(feed) {
ty = LINE_STYLE.dashed;
th /= 2;
}
var c0, c1;
var _selc = to.node.branch_drawing && from.node.branch_drawing;
@ -2778,7 +2778,7 @@ function drawJuncConnection(from, to, params, target = to) { #region
draw_set_color(c0);
if(feed && from.node == to.node) {
if(from.node == to.node) {
draw_line_feedback(jx, jy, frx, fry, th, c1, c0, ss);
} else {
switch(PREFERENCES.curve_connection_line) {

View file

@ -21,11 +21,16 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 5] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 5;
inputs[| 6] = nodeValue("Use custom dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 7] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
.setDisplay(VALUE_DISPLAY.vector);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ 5,
["Surfaces", false], 0,
["Surfaces", false], 0, 6, 7,
["Wrap", false], 1, 2, 3, 4
]
@ -56,6 +61,13 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
}
} if(!LOADING && !APPENDING) run_in(1, function() { onValueFromUpdate(0); }) #endregion
static step = function() { #region
var _useDim = getInputData(6);
inputs[| 7].setVisible(_useDim);
dimension_index = _useDim? 7 : 0;
} #endregion
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
PROCESSOR_OVERLAY_CHECK
@ -86,10 +98,11 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
draw_line(br[0], br[1], tr[0], tr[1]);
draw_line(br[0], br[1], bl[0], bl[1]);
if(inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
if(inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
if(inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
if(inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
var _hactive = active;
if(point_in_circle(_mx, _my, tl[0], tl[1], 12)) _hactive = false;
if(point_in_circle(_mx, _my, tr[0], tr[1], 12)) _hactive = false;
if(point_in_circle(_mx, _my, bl[0], bl[1], 12)) _hactive = false;
if(point_in_circle(_mx, _my, br[0], br[1], 12)) _hactive = false;
var dx = 0;
var dy = 0;
@ -157,11 +170,11 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _up3 = inputs[| 3].setValue([ _blx, _bly ]);
if(_up4 || _up3) UNDO_HOLDING = true;
} else if(active) {
} else if(_hactive) {
draw_set_color(COLORS._main_accent);
if(distance_to_line_infinite(_mx, _my, tl[0], tl[1], tr[0], tr[1]) < 12) {
draw_line_width(tl[0], tl[1], tr[0], tr[1], 3);
if(mouse_press(mb_left, active)) {
if(mouse_press(mb_left)) {
drag_side = 0;
drag_mx = _mx;
drag_my = _my;
@ -169,7 +182,7 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
}
} else if(distance_to_line_infinite(_mx, _my, tl[0], tl[1], bl[0], bl[1]) < 12) {
draw_line_width(tl[0], tl[1], bl[0], bl[1], 3);
if(mouse_press(mb_left, active)) {
if(mouse_press(mb_left)) {
drag_side = 1;
drag_mx = _mx;
drag_my = _my;
@ -177,7 +190,7 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
}
} else if(distance_to_line_infinite(_mx, _my, br[0], br[1], tr[0], tr[1]) < 12) {
draw_line_width(br[0], br[1], tr[0], tr[1], 3);
if(mouse_press(mb_left, active)) {
if(mouse_press(mb_left)) {
drag_side = 2;
drag_mx = _mx;
drag_my = _my;
@ -185,7 +198,7 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
}
} else if(distance_to_line_infinite(_mx, _my, br[0], br[1], bl[0], bl[1]) < 12) {
draw_line_width(br[0], br[1], bl[0], bl[1], 3);
if(mouse_press(mb_left, active)) {
if(mouse_press(mb_left)) {
drag_side = 3;
drag_mx = _mx;
drag_my = _my;
@ -194,10 +207,10 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
}
}
inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
if(inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
if(inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
if(inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
if(inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
@ -206,8 +219,11 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var bl = _data[3];
var br = _data[4];
var sw = surface_get_width_safe(_data[0]);
var sh = surface_get_height_safe(_data[0]);
var _useDim = _data[6];
var _dim = _data[7];
var sw = _useDim? _dim[0] : surface_get_width_safe(_data[0]);
var sh = _useDim? _dim[1] : surface_get_height_safe(_data[0]);
var teq = round(tl[1]) == round(tr[1]);
var beq = round(bl[1]) == round(br[1]);
@ -222,13 +238,14 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
} else {
surface_set_shader(_outSurf, sh_warp_4points);
shader_set_interpolation(_data[0]);
shader_set_dim("dimension", _data[0]);
shader_set_f("dimension", surface_get_dimension(_data[0]));
shader_set_f("p0", br[0] / sw, br[1] / sh);
shader_set_f("p1", tr[0] / sw, tr[1] / sh);
shader_set_f("p2", tl[0] / sw, tl[1] / sh);
shader_set_f("p3", bl[0] / sw, bl[1] / sh);
draw_surface_safe(_data[0], 0, 0);
draw_surface_stretched(_data[0], 0, 0, sw, sh);
surface_reset_shader();
}

View file

@ -1,5 +1,50 @@
/// @desc Panel for displaying node graph
/// @param {Struct.Project}
function connectionParameter() constructor { #region
log = false;
active = true;
x = 0;
y = 0;
s = 0;
mx = 0;
my = 0;
aa = 0;
bg = 0;
minx = 0;
miny = 0;
maxx = 0;
maxy = 0;
max_layer = 0;
highlight = 0;
cur_layer = 1;
static setPos = function(_x, _y, _s, _mx, _my) {
self.x = _x;
self.y = _y;
self.s = _s;
self.mx = _mx;
self.my = _my;
}
static setBoundary = function(_minx, _miny, _maxx, _maxy) {
self.minx = _minx;
self.miny = _miny;
self.maxx = _maxx;
self.maxy = _maxy;
}
static setProp = function(_max_layer, _highlight) {
self.max_layer = _max_layer;
self.highlight = _highlight;
}
static setDraw = function(_aa, _bg = c_black) {
self.aa = _aa;
self.bg = _bg;
}
} #endregion
function Panel_Graph(project = PROJECT) : PanelContent() constructor {
title = __txt("Graph");
title_raw = "";
@ -23,7 +68,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
highlight : false,
}
connection_param = {};
connection_param = new connectionParameter();
bg_color = c_black;
#endregion
@ -246,8 +291,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
addHotkey("Graph", "Group", "G", MOD_KEY.ctrl, function() { PANEL_GRAPH.doGroup(); });
addHotkey("Graph", "Ungroup", "G", MOD_KEY.ctrl | MOD_KEY.shift, function() { PANEL_GRAPH.doUngroup(); });
addHotkey("Graph", "Loop", "L", MOD_KEY.ctrl, function() { PANEL_GRAPH.doLoop(); });
addHotkey("Graph", "Canvas", "C", MOD_KEY.ctrl | MOD_KEY.shift, function() { PANEL_GRAPH.setCurrentCanvas(); });
addHotkey("Graph", "Canvas blend", "C", MOD_KEY.ctrl | MOD_KEY.alt, function() { PANEL_GRAPH.setCurrentCanvasBlend(); });
@ -991,28 +1034,20 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
surface_set_target(connection_surface);
DRAW_CLEAR
var hov = noone;
var hov = noone;
var hoverable = !bool(node_dragging) && pHOVER;
connection_param.x = gr_x;
connection_param.y = gr_y;
connection_param.s = graph_s;
connection_param.mx = mx;
connection_param.my = my;
connection_param.aa = aa;
connection_param.bg = bg_color;
connection_param.minx = -64;
connection_param.miny = -64;
connection_param.maxx = w + 64;
connection_param.maxy = h + 64;
connection_param.active = hoverable;
connection_param.max_layer = ds_list_size(nodes_list);
connection_param.highlight = display_parameter.highlight;
var param = connection_param;
param.active = hoverable;
param.setPos(gr_x, gr_y, graph_s, mx, my);
param.setBoundary(-64, -64, w + 64, h + 64);
param.setProp(ds_list_size(nodes_list), display_parameter.highlight);
param.setDraw(aa, bg_color);
for(var i = 0; i < ds_list_size(nodes_list); i++) {
connection_param.cur_layer = i + 1;
param.cur_layer = i + 1;
var _hov = nodes_list[| i].drawConnections(connection_param);
var _hov = nodes_list[| i].drawConnections(param);
if(_hov != noone && is_struct(_hov)) hov = _hov;
}
@ -1022,7 +1057,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _cmt = connection_draw_target;
if(array_empty(value_draggings))
value_dragging.drawConnectionMouse(connection_param, _cmx, _cmy, _cmt);
value_dragging.drawConnectionMouse(param, _cmx, _cmy, _cmt);
else {
var _stIndex = array_find(value_draggings, value_dragging);
@ -1030,7 +1065,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _dmx = _cmx;
var _dmy = value_draggings[i].connect_type == JUNCTION_CONNECT.output? _cmy + (i - _stIndex) * 24 * graph_s : _cmy;
value_draggings[i].drawConnectionMouse(connection_param, _dmx, _dmy, _cmt);
value_draggings[i].drawConnectionMouse(param, _dmx, _dmy, _cmt);
}
}
}
@ -1965,29 +2000,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
upgroupNode(_node);
} #endregion
function doLoop() { #region
if(array_empty(nodes_selecting)) return;
var cx = 0;
var cy = 0;
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
cx += _node.x;
cy += _node.y;
}
cx = round(cx / array_length(nodes_selecting) / 32) * 32;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
var _group = new Node_Iterate(cx, cy, getCurrentContext());
for(var i = 0; i < array_length(nodes_selecting); i++)
_group.add(nodes_selecting[i]);
for(var i = 0; i < array_length(nodes_selecting); i++)
nodes_selecting[i].checkConnectGroup("loop");
nodes_selecting = [];
} #endregion
function doFrame() { #region
var x0 = 999999, y0 = 999999, x1 = -999999, y1 = -999999;

View file

@ -89,27 +89,19 @@ function graph_export_image(allList, nodeList, settings = {}) {
#region draw conneciton
surface_set_target(cs);
DRAW_CLEAR
var _params = {
show_dimension : true,
show_compute : true,
avoid_label : true,
preview_scale : 100,
x : gr_x,
y : gr_y,
s : scale,
mx : mx,
my : my,
aa : aa,
active : true,
max_layer : 1,
cur_layer : 1,
highlight : false,
log: true,
};
var param = new connectionParameter();
param.setPos(gr_x, gr_y, scale, mx, my);
param.setProp(1, false);
param.setDraw(aa, c_black);
param.show_dimension = true;
param.show_compute = true;
param.avoid_label = true;
param.preview_scale = 100;
for(var i = 0; i < ds_list_size(nodeList); i++)
nodeList[| i].drawConnections(_params, true);
nodeList[| i].drawConnections(param, true);
surface_reset_target();
shader_set(sh_downsample);
@ -127,7 +119,7 @@ function graph_export_image(allList, nodeList, settings = {}) {
for(var i = 0; i < ds_list_size(nodeList); i++) {
var _node = nodeList[| i];
if(instanceof(_node) == "Node_Frame") continue;
var val = _node.drawNode(gr_x, gr_y, mx, my, scale, _params);
var val = _node.drawNode(gr_x, gr_y, mx, my, scale, param);
}
#endregion

View file

@ -139,9 +139,9 @@ function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
sc_settings.setFocusHover(pFOCUS, pHOVER);
sc_settings.draw(sx, sy, mx - sx, my - sy);
var txt = __txt("Export") + "...";
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
var _bw = string_width(txt) + ui(32);
var txt = __txt("Export") + "...";
var _bw = string_width(txt) + ui(32);
var _bh = string_height(txt) + ui(12);
bx = w - padding - _bw;
by = h - padding - _bh;

View file

@ -54,8 +54,9 @@ function ResetAllNodesRender() { #region
function NodeTopoSort() { #region
var _key = ds_map_find_first(PROJECT.nodeMap);
var amo = ds_map_size(PROJECT.nodeMap);
var amo = ds_map_size(PROJECT.nodeMap);
var _t = get_timer();
repeat(amo) {
var _node = PROJECT.nodeMap[? _key];
_node.clearTopoSorted();
@ -65,15 +66,17 @@ function NodeTopoSort() { #region
ds_list_clear(PROJECT.nodeTopo);
__sortGraph(PROJECT.nodeTopo, PROJECT.nodes);
LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)} nodes sorted +++++++");
LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++");
} #endregion
function __sortGraph(_list, _nodeList) { #region
var _root = [];
var _root = [];
var _leftOver = [];
//print($"Sorting...");
for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ ) {
var _node = _nodeList[| i];
var _node = _nodeList[| i];
var _isRoot = true;
if(is_instanceof(_node, Node_Collection_Inline) && !_node.is_root) {
@ -97,13 +100,15 @@ function __sortGraph(_list, _nodeList) { #region
if(_isRoot) array_push(_root, _node);
}
var _st = ds_queue_create();
//print($" > Roots: {_root}");
var _sortQueue = ds_queue_create();
for( var i = 0, n = array_length(_root); i < n; i++ )
ds_queue_enqueue(_st, _root[i]);
ds_queue_enqueue(_sortQueue, _root[i]);
while(!ds_queue_empty(_st)) {
var _node = ds_queue_dequeue(_st);
while(!ds_queue_empty(_sortQueue)) {
var _node = ds_queue_dequeue(_sortQueue);
if(_node.topoSorted) continue;
var _childs = [];
@ -118,16 +123,19 @@ function __sortGraph(_list, _nodeList) { #region
array_push(_childs, _in);
}
//print($" > Checking {_node.name}: {array_length(_childs)}");
if(array_empty(_childs)) {
ds_list_add(_list, _node);
_node.topoSorted = true;
if(is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder)
__sortGraph(_list, _node.nodes);
} else {
for( var i = 0, n = array_length(_childs); i < n; i++ )
ds_queue_enqueue(_st, _childs[i]);
ds_queue_enqueue(_st, _node);
ds_queue_enqueue(_sortQueue, _childs[i]);
}
if(!_node.topoSorted) {
ds_list_add(_list, _node);
_node.topoSorted = true;
}
}

View file

@ -186,14 +186,14 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount",
shader_set_f("sampleDimension", surface_get_width_safe(surface), surface_get_height_safe(surface));
}
function shader_set_interpolation(surface) {
function shader_set_interpolation(surface, _dim = noone) {
INLINE
var intp = attributes.interpolate;
gpu_set_tex_filter(intp);
shader_set_i("interpolation", intp);
shader_set_f("sampleDimension", surface_get_width_safe(surface), surface_get_height_safe(surface));
shader_set_f("sampleDimension", _dim == noone? surface_get_dimension(surface) : _dim);
shader_set_i("sampleMode", attributes.oversample);
}

View file

@ -1,7 +1,7 @@
#macro struct_has variable_struct_exists
#macro struct_key variable_struct_get_names
function struct_override(original, override) {
function struct_override(original, override) { #region
var args = variable_struct_get_names(override);
for( var i = 0, n = array_length(args); i < n; i++ ) {
@ -12,9 +12,9 @@ function struct_override(original, override) {
}
return original;
}
} #endregion
function struct_append(original, append) {
function struct_append(original, append) { #region
var args = variable_struct_get_names(append);
for( var i = 0, n = array_length(args); i < n; i++ ) {
@ -22,22 +22,22 @@ function struct_append(original, append) {
}
return original;
}
} #endregion
function struct_try_get(struct, key, def = 0) {
function struct_try_get(struct, key, def = 0) { #region
INLINE
if(struct[$ key] != undefined) return struct[$ key];
key = string_replace_all(key, "_", " ");
return struct[$ key] ?? def;
}
} #endregion
function struct_try_override(original, override, key) {
function struct_try_override(original, override, key) { #region
INLINE
if(!is_struct(original) || !is_struct(override)) return;
if(!struct_has(override, key)) return;
original[$ key] = override[$ key];
}
} #endregion