Surface size limit.

This commit is contained in:
Tanasart 2023-06-17 18:59:20 +02:00
parent 9219431741
commit 8dab2d8fba
27 changed files with 157 additions and 65 deletions

View file

@ -3,5 +3,7 @@ var port = async_load[? "port"];
if(!ds_map_exists(PORT_MAP, port)) exit;
var nodeTarget = PORT_MAP[? port];
for( var i = 0; i < array_length(nodeTarget); i++ )
nodeTarget[i].asyncPackets(async_load);
for( var i = 0; i < array_length(nodeTarget); i++ ) {
if(is_struct(nodeTarget[i]) && nodeTarget[i].active)
nodeTarget[i].asyncPackets(async_load);
}

View file

@ -24,18 +24,21 @@ function __log(title, str, fname = "log/log.txt") {
}
function log_message(title, str, icon = noone, flash = false, write = true) {
if(TEST_ERROR) return;
if(write) __log("[MESSAGE] ", string(title) + ": " + string(str));
return noti_status(string(title) + ": " + string(str), icon, flash);
}
function log_warning(title, str, ref = noone) {
function log_warning(title, str, ref = noone) {
if(TEST_ERROR) return;
__log("[WARNING] ", string(title) + ": " + string(str));
return noti_warning(string(title) + ": " + string(str),, ref);
}
function log_crash(str) {
if(TEST_ERROR) return;
__log("[ERROR] ", string(str));
return noti_error(string(str));
@ -71,7 +74,7 @@ function exception_print(e) {
function setException() {
exception_unhandled_handler(function(ex) {
var path = string(DIRECTORY) + "prev_crash.pxc";
if(!SAVING) SAVE_AT(path);
if(!SAVING && !TESTING) SAVE_AT(path);
var tt = "\n-------------------------- OH NO --------------------------\n\n";
tt += "\n" + ex.longMessage;

View file

@ -92,8 +92,9 @@
#macro DELTA_TIME delta_time / 1_000_000
#macro CONF_TESTING false
globalvar TESTING;
globalvar TESTING, TEST_ERROR;
TESTING = CONF_TESTING;
TEST_ERROR = false;
#macro DEMO false
#macro ItchDemo:DEMO true

View file

@ -1,4 +1,4 @@
function json_try_parse(text, def = noone) {
function json_try_parse(text, def = {}) {
try {
return json_parse(text);
} catch(e) {

View file

@ -14,6 +14,12 @@ function LOAD() {
ds_list_clear(ERRORS);
}
function TEST_PATH(path) {
TESTING = true;
TEST_ERROR = true;
__LOAD_PATH(path, false, false);
}
function LOAD_PATH(path, readonly = false, safe_mode = false) {
if(MODIFIED && !READONLY) {
var dia = dialogCall(o_dialog_load);
@ -44,8 +50,8 @@ function __LOAD_PATH(path, readonly = false, safe_mode = false) {
nodeCleanUp();
clearPanel();
setPanel();
instance_destroy(_p_dialog);
//room_restart();
if(!TESTING)
instance_destroy(_p_dialog);
ds_list_clear(ERRORS);
var temp_path = DIRECTORY + "_temp";

View file

@ -220,7 +220,7 @@ function Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
if(do_reset_material) {
array_resize(input_display_list, input_display_len);
while(ds_list_size(inputs) > input_length)
ds_list_delete(inputs, input_length);
@ -265,14 +265,14 @@ function Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var _cam = new __3d_camera(_proj, _fov);
_outSurf = _3d_pre_setup(_outSurf, _dim, _transform, _light, _cam, pass);
for(var i = 0; i < array_length(VB); i++) {
if(i >= array_length(materialIndex)) continue;
var mIndex = materialIndex[i];
for(var j = 0; j < array_length(VB); j++) {
if(j >= array_length(materialIndex)) continue;
var mIndex = materialIndex[j];
var tex = inputs[| input_length + mIndex].getValue();
if(!is_surface(tex)) continue;
vertex_submit(VB[i], pr_trianglelist, surface_get_texture(tex));
vertex_submit(VB[j], pr_trianglelist, surface_get_texture(tex));
}
_3d_post_setup();

View file

@ -225,7 +225,6 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
layers = [];
var vis = attributes.layer_visible;
ds_list_clear(vis);
var frames = content[? "Frames"];
for( var i = 0; i < array_length(frames); i++ ) {
@ -256,7 +255,7 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
case 0x2004: //layer
var name = chunk[? "Name"];
array_push(layers, new ase_layer(name));
ds_list_add(vis, true);
array_push(vis, true);
break;
case 0x2005: //cel
var _layer = chunk[? "Layer index"];
@ -331,7 +330,7 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
layers[i].tag = tag;
var cel = layers[i].getCel(ANIMATOR.current_frame - _tag_delay);
if(!cel) continue;
if(!ds_list_get(vis, i, true)) continue;
if(!array_safe_get(vis, i, true)) continue;
var _inSurf = cel.getSurface();
if(!is_surface(_inSurf))

View file

@ -50,6 +50,9 @@ function Node_Color_RGB(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
static process_data = function(_outSurf, _data, _output_index, _array_index) {
var nor = _data[3];
if(!is_real(_data[0])) return 0;
if(!is_real(_data[1])) return 0;
if(!is_real(_data[2])) return 0;
return make_color_rgb(
nor? _data[0] * 255 : _data[0],

View file

@ -15,19 +15,22 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
bg_sel_spr = THEME.node_active;
anim_priority = ds_map_size(NODE_MAP);
static resetInternalName = function() {
var str = string_replace_all(name, " ", "_");
str = string_replace_all(str, "/", "");
str = string_replace_all(str, "-", "");
internalName = str + string(irandom_range(10000, 99999));
NODE_NAME_MAP[? internalName] = self;
}
if(!LOADING && !APPENDING) {
recordAction(ACTION_TYPE.node_added, self);
NODE_MAP[? node_id] = self;
MODIFIED = true;
run_in(1, function() {
var str = string_replace_all(name, " ", "_");
str = string_replace_all(str, "/", "");
str = string_replace_all(str, "-", "");
internalName = str + string(irandom_range(10000, 99999));
NODE_NAME_MAP[? internalName] = self;
resetInternalName();
display_name = __txt_node_name(instanceof(self), name);
});
}
@ -1355,6 +1358,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
setDisplayName(load_map.name);
internalName = struct_try_get(load_map, "iname", internalName);
if(internalName == "")
resetInternalName();
_group = struct_try_get(load_map, "group", noone);
if(_group == -1) _group = noone;

View file

@ -31,7 +31,7 @@ function Node_Feedback_Output(_x, _y, _group = noone) : Node_Group_Output(_x, _y
surface_free(cache_value);
if(_arr) {
var amo = array_length(_val_get);
var amo = is_array(_val_get)? array_length(_val_get) : 0;
cache_value = array_create(amo);
if(is_surf) {

View file

@ -123,13 +123,13 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
_to.removeFrom();
}
inputs[| 0].display_data = display_list[_val_type];
inputs[| 0].editWidget.data_list = display_list[_val_type];
inputs[| 0].display_data = array_safe_get(display_list, _val_type);
inputs[| 0].editWidget.data_list = array_safe_get(display_list, _val_type);
inputs[| 0].setValue(0);
_dtype = 0;
}
_dtype = display_list[_val_type][_dtype];
_dtype = array_safe_get(array_safe_get(display_list, _val_type, []), _dtype);
inParent.type = _val_type;
outputs[| 0].type = _val_type;
@ -293,7 +293,7 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var _dstype = inputs[| 0].getValue();
var _data = inputs[| 2].getValue();
_dstype = display_list[_data][_dstype];
_dstype = array_safe_get(array_safe_get(display_list, _data, []), _dstype);
var _datype = data_type_map[_data];

View file

@ -419,21 +419,21 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
for(var i = 0; i < array_length(_data); i++) {
var _keyframe = _data[i];
var _time = _keyframe[0];
var _time = array_safe_get(_keyframe, 0);
if(scale && _time <= 1)
_time = round(_time * (ANIMATOR.frames_total - 1));
var value = _keyframe[1];
var ease_in = _keyframe[2];
var ease_out = _keyframe[3];
var ease_in_type = _keyframe[4];
var ease_out_type = _keyframe[5];
var value = array_safe_get(_keyframe, 1);
var ease_in = array_safe_get(_keyframe, 2);
var ease_out = array_safe_get(_keyframe, 3);
var ease_in_type = array_safe_get(_keyframe, 4);
var ease_out_type = array_safe_get(_keyframe, 5);
var _val = value;
if(prop.type == VALUE_TYPE.struct)
_val = json_parse(value);
_val = json_try_parse(value);
else if(prop.type == VALUE_TYPE.path && prop.display_type == VALUE_DISPLAY.path_array) {
for(var j = 0; j < array_length(value); j++)
_val[j] = value[j];

View file

@ -158,7 +158,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _rtStr = min(_rangeMin, _rangeMax);
var _rtMax = max(_rangeMin, _rangeMax);
var _use_path = _pat != noone;
var _use_path = is_struct(_pat);
var _useTex = inputs[| 18].value_from != noone;
if(_useTex) {
_cap = false;

View file

@ -169,7 +169,7 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var _dimm = inputs[| 1].getValue();
var _exec = inputs[| 4].getValue();
if(!_exec) return;
if(!is_real(_exec) || !_exec) return;
argument_val = [];
for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length )

View file

@ -163,7 +163,7 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
var _dimm = inputs[| 1].getValue();
var _exec = inputs[| 4].getValue();
if(!_exec) return;
if(!is_real(_exec) || !_exec) return;
argument_val = [];
for( var i = input_fix_len; i < ds_list_size(inputs) - data_length; i += data_length ) {

View file

@ -797,6 +797,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
lengthTotal = 0;
var loop = inputs[| 1].getValue();
var rond = inputs[| 3].getValue();
if(!is_real(rond)) rond = false;
var ansize = ds_list_size(inputs) - input_fix_len;
if(ansize < 2) {
lengths = [];
@ -854,6 +855,8 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
static getPointDistance = function(_dist) {
var loop = inputs[| 1].getValue();
var rond = inputs[| 3].getValue();
if(!is_real(rond)) rond = false;
var ansize = array_length(lengths);
var amo = ds_list_size(inputs) - input_fix_len;
@ -895,6 +898,8 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
static getPointSegment = function(_rat) {
var loop = inputs[| 1].getValue();
var rond = inputs[| 3].getValue();
if(!is_real(rond)) rond = false;
var ansize = array_length(lengths);
var amo = ds_list_size(inputs) - input_fix_len;

View file

@ -608,6 +608,8 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
#region node function
function nodeLoad(_data, scale = false, _group = PANEL_GRAPH.getCurrentContext()) {
if(!is_struct(_data)) return;
var _x = _data.x;
var _y = _data.y;
var _type = _data.type;
@ -631,6 +633,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
var key = ds_map_find_first(NODE_MAP);
repeat(ds_map_size(NODE_MAP)) {
if(NODE_MAP[? key]) {
NODE_MAP[? key].active = false;
NODE_MAP[? key].cleanUp();
delete NODE_MAP[? key];
}

View file

@ -56,6 +56,8 @@ function Node_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var _surf = inputs[| 0].getValue();
var _life = inputs[| 1].getValue();
var _loop = inputs[| 2].getValue();
if(!is_real(_loop)) _loop = false;
var _rang = inputs[| 3].getValue();
var _colr = inputs[| 4].getValue();
var _blend = inputs[| 5].getValue();

View file

@ -121,17 +121,28 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
static getNextNodes = function() {
var nodes = [];
var _key = inputs[| 0].getValue();
var amo = ds_map_size(TUNNELS_OUT);
var nodeNames = [];
var _key = inputs[| 0].getValue();
var amo = ds_map_size(TUNNELS_OUT);
var k = ds_map_find_first(TUNNELS_OUT);
LOG_BLOCK_START();
LOG_IF(global.FLAG.render, $"→→→→→ Call get next node from: {internalName}");
LOG_BLOCK_START();
repeat(amo) {
if(TUNNELS_OUT[? k] == _key)
if(TUNNELS_OUT[? k] == _key) {
array_push(nodes, NODE_MAP[? k]);
array_push(nodeNames, NODE_MAP[? k].internalName);
}
k = ds_map_find_next(TUNNELS_OUT, k);
}
LOG_IF(global.FLAG.render, $"→→ Push {nodeNames} to stack.");
LOG_BLOCK_END();
LOG_BLOCK_END();
return nodes;
}

View file

@ -1642,9 +1642,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static applyDeserialize = function(_map, scale = false, preset = false) {
if(_map == undefined) return;
if(_map == noone) return;
if(_map == noone) return;
if(!is_struct(_map)) return;
visible = _map.visible;
visible = struct_try_get(_map, "visible", visible);
if(connect_type == JUNCTION_CONNECT.output)
return;

View file

@ -44,7 +44,9 @@ function Node_Websocket_Receiver(_x, _y, _group = noone) : Node(_x, _y, _group)
}
network_trigger = 0;
function asyncPackets(_async_load) {
static asyncPackets = function(_async_load) {
if(!active) return;
var _active = inputs[| 1].getValue();
if(!_active) return;

View file

@ -55,7 +55,9 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
connectTo(_port, _url);
}
function asyncPackets(_async_load) {
static asyncPackets = function(_async_load) {
if(!active) return;
var type = async_load[? "type"];
switch(type) {

View file

@ -40,6 +40,7 @@
}
function noti_status(str, icon = noone, flash = false, ref = noone) {
if(TEST_ERROR) return;
show_debug_message("STATUS: " + str);
if(flash && PANEL_MENU) {
@ -65,6 +66,7 @@
}
function noti_warning(str, icon = noone, ref = noone) {
if(TEST_ERROR) return;
show_debug_message("WARNING: " + str);
if(PANEL_MENU) {
@ -81,7 +83,7 @@
ds_list_add(STATUSES, noti);
ds_list_add(WARNING, noti);
if(!instance_exists(o_dialog_warning))
if(!instance_exists(o_dialog_warning) && !TESTING)
dialogCall(o_dialog_warning, mouse_mx + ui(16), mouse_my + ui(16)).warning_text = str;
if(ref) {
@ -93,6 +95,7 @@
}
function noti_error(str, icon = noone, ref = noone) {
if(TEST_ERROR) return;
show_debug_message("ERROR: " + str);
var noti = new notification(NOTI_TYPE.error, str, icon, c_ui_red);

View file

@ -217,6 +217,7 @@ function Panel_Menu() : PanelContent() constructor {
}),
menuItem(__txtx("panel_menu_tester", "Tester"), function() {
var dia = dialogPanelCall(new Panel_Test());
dia.destroy_on_click_out = false;
}),
-1,

View file

@ -1,15 +1,41 @@
function Panel_Test() : PanelContent() constructor {
w = ui(480);
h = ui(160);
h = ui(96);
title = "Tester";
test_dir = "";
test_dir = "D:\\Project\\MakhamDev\\LTS-PixelComposer\\TEST";
tb_test_dir = new textBox(TEXTBOX_INPUT.text, function(txt) { test_dir = txt; });
testing = false;
test_files = [];
test_index = 0;
test_button_surface = surface_create(1, 1);
function scanDir(dir) {
var f = file_find_first(dir + "\\*", fa_none);
while(f != "") {
var path = dir + "\\" + f;
if(filename_ext(path) == ".pxc")
array_push(test_files, path);
f = file_find_next();
}
file_find_close();
var f = file_find_first(dir + "\\*", fa_directory);
var _dir = [];
while(f != "") {
var path = dir + "\\" + f;
array_push(_dir, path);
f = file_find_next();
}
file_find_close();
for( var i = 0; i < array_length(_dir); i++ )
scanDir(_dir[i]);
}
function startTesting() {
if(testing) return;
@ -17,18 +43,14 @@ function Panel_Test() : PanelContent() constructor {
test_index = 0;
test_files = [];
var f = file_find_first(test_dir + "/*", fa_none);
var _f = "";
while(f != "") {
var path = test_dir + f;
if(filename_ext(path) == ".pxc")
array_push(test_files, path);
f = file_find_next();
}
scanDir(test_dir);
for( var i = 0; i < array_length(test_files); i++ ) {
run_in(i * 2, function(i) { LOAD_PATH(test_files[i]); test_index = i }, i);
run_in(i * 3, function(i) {
print($"TESTING: {test_files[i]}");
TEST_PATH(test_files[i]);
test_index = i
}, [i]);
}
}
@ -46,10 +68,22 @@ function Panel_Test() : PanelContent() constructor {
yy += hh + 8;
if(testing) {
var _w = (w - 16) * test_index / array_length(test_files);
draw_sprite_stretched(THEME.progress_bar, 0, 8, yy, w - 16, hh);
draw_sprite_stretched(THEME.progress_bar, 1, 8, yy, (w - 16) * test_index / array_length(test_files), hh);
draw_sprite_stretched(THEME.progress_bar, 1, 8, yy, _w, hh);
if(test_index == array_length(test_files) - 1)
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
draw_text(w / 2, yy + hh / 2, $"Testing {test_index + 1}/{array_length(test_files)}");
test_button_surface = surface_verify(test_button_surface, w - 16, hh);
surface_set_target(test_button_surface);
DRAW_CLEAR
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text_on_accent);
draw_text((w - 16) / 2, hh / 2, $"Testing {test_index + 1}/{array_length(test_files)}");
surface_reset_target();
draw_surface_part(test_button_surface, 0, 0, _w, hh, 8, yy);
if(test_index >= array_length(test_files) - 1)
testing = false;
} else {
if(buttonInstant(THEME.button, 8, yy, w - 16, hh, [ mx, my ], pFOCUS, pHOVER) == 2)

View file

@ -49,7 +49,7 @@ function __nodeInLoop(_node) {
return false;
}
function Render(partial = false, runAction = false) {
function Render(partial = false, runAction = false) {
var t = current_time;
LOG_BLOCK_START();
LOG_IF(global.FLAG.render,
@ -128,8 +128,6 @@ $"============================== RENDER START [frame {string(ANIMATOR.current_fr
if(runAction && rendering.hasInspector1Update())
rendering.inspector1Update();
} else if(rendering.isRenderActive()) {
RENDER_QUEUE.enqueue(rendering);
}
LOG_BLOCK_END();

View file

@ -42,6 +42,14 @@ function draw_surface_part_ext_safe(surface, _l, _t, _w, _h, _x, _y, _xs = 1, _y
__channel_pos(surface);
}
#macro surface_free surface_free_safe
#macro __surface_free surface_free
function surface_free_safe(surface) {
if(!is_surface(surface)) return;
__surface_free(surface);
}
function surface_save_safe(surface, path) {
if(!is_surface(surface)) return;
var f = surface_get_format(surface);
@ -150,6 +158,7 @@ function surface_create_valid(w, h, format = surface_rgba8unorm) {
}
function surface_create_from_buffer(w, h, buff, format = surface_rgba8unorm) {
if(buff < 0) return;
var s = surface_create_valid(surface_valid_size(w), surface_valid_size(h), format);
buffer_set_surface(buff, s, 0);
return s;
@ -258,7 +267,8 @@ function surface_copy_size(dest, source, format = noone) {
function surface_valid_size(s) {
if(is_infinity(s)) return 1;
return max(1, s);
if(!is_real(s)) return 1;
return clamp(s, 1, 8196);
}
function surface_array_free(arr) {