mem leaks

This commit is contained in:
Tanasart 2024-11-15 15:39:23 +07:00
parent eb6cb20f14
commit cdaa653d49
18 changed files with 120 additions and 71 deletions

View file

@ -42,7 +42,7 @@
LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_04_0;
SAVE_VERSION = 1_18_02_0;
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.007";
VERSION_STRING = MAC? "1.18.003m" : "1.18.4.008";
BUILD_NUMBER = 1_18_03_1;
HOTKEYS = ds_map_create();

View file

@ -31,7 +31,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.surface, []))
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.atlas, []))
.rejectArrayProcess();
newOutput(2, nodeValue_Output("Bind data", self, VALUE_TYPE.struct, []))

View file

@ -26,13 +26,19 @@ function Node_Array_Split(_x, _y, _group = noone) : Node(_x, _y, _group) constru
for (var i = 0; i < amo; i++) {
if(i >= array_length(outputs))
newOutput(i, nodeValue_Output($"val {i}", self, type, 0))
newOutput(i, nodeValue_Output($"val {i}", self, type, 0));
outputs[i].setValue(_inp[i]);
}
while(array_length(outputs) > amo)
array_delete(outputs, array_length(outputs) - 1, 1);
var _rem = array_length(outputs);
for(var i = amo; i < _rem; i++) {
var _to = outputs[i].getJunctionTo();
for( var j = 0, m = array_length(_to); j < m; j++ )
_to[j].removeFrom();
}
array_resize(outputs, amo);
for (var i = 0, n = amo; i < n; i++) {
outputs[i].index = i;
@ -46,10 +52,10 @@ function Node_Array_Split(_x, _y, _group = noone) : Node(_x, _y, _group) constru
static preApplyDeserialize = function() {
if(!struct_has(attributes, "output_amount")) return;
var _outAmo = attributes.output_amount;
var _amo = attributes.output_amount;
var _ind = 0;
repeat(_outAmo) {
repeat(_amo) {
newOutput(_ind, nodeValue_Output($"val {_ind}", self, VALUE_TYPE.any, 0));
_ind++;
}

View file

@ -19,7 +19,7 @@ function Node_Atlas_Set(_x, _y, _group = noone) : Node(_x, _y, _group) construct
newInput(7, nodeValue_Bool("Recalculate Position", self, true));
newOutput(0, nodeValue_Output("Atlas", self, VALUE_TYPE.surface, noone));
newOutput(0, nodeValue_Output("Atlas", self, VALUE_TYPE.atlas, noone));
input_display_list = [
0, 1, 2, 3, 7, 4, 5, 6,

View file

@ -12,6 +12,7 @@ enum COMPOSE_OUTPUT_SCALING {
function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Composite";
dimension_index = -1;
newInput(0, nodeValue_Padding("Padding", self, [ 0, 0, 0, 0 ]));
@ -774,7 +775,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var base = _data[3];
var cDep = attrDepth();
if(!is_surface(base)) return [ _outSurf, noone, [1, 1] ];
if(!is_surface(base)) return _outData;
#region dimension
var ww = 0, hh = 0;
@ -784,6 +785,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
ww = surface_get_width_safe(base);
hh = surface_get_height_safe(base);
break;
case COMPOSE_OUTPUT_SCALING.largest :
for(var i = input_fix_len; i < array_length(_data) - data_length; i += data_length) {
var _s = _data[i];
@ -791,6 +793,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
hh = max(hh, surface_get_height_safe(_s));
}
break;
case COMPOSE_OUTPUT_SCALING.constant :
ww = _dim[0];
hh = _dim[1];
@ -856,7 +859,10 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
draw_surface_safe(temp_surface[!_bg]);
surface_reset_shader();
return [ _outSurf, _atlas, [ww, hh] ];
_outData[0] = _outSurf;
_outData[1] = _atlas;
_outData[2] = [ww, hh];
return _outData;
}
static attributeSerialize = function() {

View file

@ -117,8 +117,20 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[8].mappableStep();
}
static getDimension = function(_arr = 0) {
var _dim = getSingleValue( 0, _arr);
var _sam = getSingleValue( 7, _arr);
var _mod = getSingleValue(10, _arr);
var _txd = getSingleValue(25, _arr);
var _tex = _mod == 3 || _mod == 4;
if(is_surface(_sam) && _tex && _txd)
return surface_get_dimension(_sam);
return _dim;
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[ 0];
var _dim = surface_get_dimension(_outSurf);
var _pos = _data[ 1];
var _sam = _data[ 7];
var _mode = _data[10];
@ -139,11 +151,6 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[ 7].setVisible(_tex_mode, _tex_mode);
inputs[25].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[25];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("dimension", _dim[0], _dim[1]);

View file

@ -86,8 +86,20 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[5].mappableStep();
}
static getDimension = function(_arr = 0) {
var _dim = getSingleValue( 0, _arr);
var _sam = getSingleValue( 9, _arr);
var _mod = getSingleValue( 7, _arr);
var _txd = getSingleValue(21, _arr);
var _tex = _mod == 2 || _mod == 3;
if(is_surface(_sam) && _tex && _txd)
return surface_get_dimension(_sam);
return _dim;
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0];
var _dim = surface_get_dimension(_outSurf);
var _pos = _data[1];
var _sam = _data[9];
var _mode = _data[7];
@ -102,11 +114,6 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[ 9].setVisible(_tex_mode, _tex_mode);
inputs[21].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[21];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid_hex);
shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);

View file

@ -65,15 +65,27 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _
return _hov;
}
static step = function() { #region
static step = function() {
inputs[2].mappableStep();
inputs[3].mappableStep();
inputs[4].mappableStep();
inputs[5].mappableStep();
} #endregion
}
static getDimension = function(_arr = 0) {
var _dim = getSingleValue( 0, _arr);
var _sam = getSingleValue( 7, _arr);
var _mod = getSingleValue( 8, _arr);
var _txd = getSingleValue(17, _arr);
var _tex = _mod == 2 || _mod == 3;
if(is_surface(_sam) && _tex && _txd)
return surface_get_dimension(_sam);
return _dim;
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0];
var _dim = surface_get_dimension(_outSurf);
var _pos = _data[1];
var _sam = _data[7];
var _mode = _data[8];
@ -88,10 +100,6 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _
inputs[ 7].setVisible(_tex_mode, _tex_mode);
inputs[17].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[17];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid_pentagonal);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("dimension", _dim[0], _dim[1]);

View file

@ -86,8 +86,20 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[5].mappableStep();
}
static getDimension = function(_arr = 0) {
var _dim = getSingleValue( 0, _arr);
var _sam = getSingleValue( 7, _arr);
var _mod = getSingleValue( 8, _arr);
var _txd = getSingleValue(21, _arr);
var _tex = _mod == 3 || _mod == 4;
if(is_surface(_sam) && _tex && _txd)
return surface_get_dimension(_sam);
return _dim;
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0];
var _dim = surface_get_dimension(_outSurf);
var _pos = _data[1];
var _sam = _data[7];
var _mode = _data[8];
@ -104,11 +116,6 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[ 7].setVisible(_tex_mode, _tex_mode);
inputs[21].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[21];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid_tri);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("dimension", _dim[0], _dim[1]);

View file

@ -17,7 +17,7 @@ function Node_Image_Grid(_x, _y, _group = noone) : Node(_x, _y, _group) construc
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.surface, []));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.atlas, []));
temp_surface = [ noone, noone ];

View file

@ -66,7 +66,7 @@ function Node_Image_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group) constru
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas Data", self, VALUE_TYPE.surface, []))
newOutput(1, nodeValue_Output("Atlas Data", self, VALUE_TYPE.atlas, []))
.setArrayDepth(1);
attribute_surface_depth();

View file

@ -13,7 +13,7 @@ function Node_Pack_Sprites(_x, _y, _group = noone) : Node(_x, _y, _group) constr
newOutput(0, nodeValue_Output("Packed image", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.surface, []));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.atlas, []));
input_display_list = [ 0, 4, 1, 2, 3 ];

View file

@ -88,6 +88,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var _atlas = false;
var _pAtl = noone;
var _data = [];
var _dep = attrDepth();
if(process_amount == 1) { // render single data
if(_output.type == VALUE_TYPE.d3object) //passing 3D vertex call
@ -112,6 +113,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
_sh = surface_get_height_safe(surf);
} else
return noone;
} else if(is_array(surf)) {
_sw = array_safe_get_fast(surf, 0, 1);
_sh = array_safe_get_fast(surf, 1, 1);
@ -120,10 +122,10 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
if(is_instanceof(_out, SurfaceAtlas)) {
if(manage_atlas) {
surface_free_safe(_out.getSurface())
_out = surface_verify(_out.getSurface(), _sw, _sh, attrDepth());
_out = surface_verify(_out.getSurface(), _sw, _sh, _dep);
}
} else
_out = surface_verify(_out, _sw, _sh, attrDepth());
_out = surface_verify(_out, _sw, _sh, _dep);
}
}
@ -184,11 +186,11 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
if(is_instanceof(_out[l], SurfaceAtlas)) {
if(manage_atlas) {
surface_free_safe(_out[l].surface.surface)
_out[l] = surface_verify(_out[l].getSurface(), _sw, _sh, attrDepth());
_out[l] = surface_verify(_out[l].getSurface(), _sw, _sh, _dep);
}
} else
_out[l] = surface_verify(_out[l], _sw, _sh, attrDepth());
_out[l] = surface_verify(_out[l], _sw, _sh, _dep);
}
} #endregion
@ -242,9 +244,10 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
if(dimension_index > -1) {
var _dim = getDimension();
for(var i = 0; i < _os; i++) {
if(outputs[i].type == VALUE_TYPE.surface) _out[i] = surface_verify(_out[i], _dim[0], _dim[1], _dep);
if(outputs[i].type != VALUE_TYPE.surface) continue;
_out[i] = surface_verify(_out[i], _dim[0], _dim[1], _dep);
}
}
@ -280,13 +283,16 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
if(l == 0 || l == preview_index) current_data = _inputs;
var _dim = getDimension(l);
var _outa = array_create(_os);
var _dim = getDimension(l);
for(var i = 0; i < _os; i++) {
_outa[i] = array_safe_get(_out[i], l);
if(outputs[i].type == VALUE_TYPE.surface)
_outa[i] = surface_verify(_outa[i], _dim[0], _dim[1], _dep);
if(dimension_index == -1) continue;
if(outputs[i].type != VALUE_TYPE.surface) continue;
_outa[i] = surface_verify(_outa[i], _dim[0], _dim[1], _dep);
}
if(_os == 1) {

View file

@ -49,7 +49,7 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group)
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas Data", self, VALUE_TYPE.surface, []));
newOutput(1, nodeValue_Output("Atlas Data", self, VALUE_TYPE.atlas, []));
input_display_list = [
["Surfaces", false], 0, 1, 2,

View file

@ -129,7 +129,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.surface, []))
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.atlas, []))
.setVisible(false)
.rejectArrayProcess();
@ -146,8 +146,8 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
attribute_surface_depth();
attribute_interpolation();
surface_size_map = ds_map_create();
surface_valid_map = ds_map_create();
surface_size_map = {};
surface_valid_map = {};
scatter_data = [];
scatter_map = noone;
@ -294,8 +294,6 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
var _in_w, _in_h;
var _outSurf = _outData[0];
var vSca = array_exists(useV, "Scale");
var vRot = array_exists(useV, "Rotation");
var vCol = array_exists(useV, "Color");
@ -304,16 +302,16 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
if(surfArray && array_empty(_inSurf)) return _outData;
#region cache value
ds_map_clear(surface_size_map);
ds_map_clear(surface_valid_map);
surface_size_map = {};
surface_valid_map = {};
if(!surfArray) {
surface_size_map[? _inSurf] = surface_get_dimension(_inSurf);
surface_valid_map[? _inSurf] = is_surface(_inSurf);
surface_size_map[$ _inSurf] = surface_get_dimension(_inSurf);
surface_valid_map[$ _inSurf] = is_surface(_inSurf);
} else {
for( var i = 0, n = array_length(_inSurf); i < n; i++ ) {
surface_size_map[? _inSurf[i]] = surface_get_dimension(_inSurf[i]);
surface_valid_map[? _inSurf[i]] = is_surface(_inSurf[i]);
surface_size_map[$ _inSurf[i]] = surface_get_dimension(_inSurf[i]);
surface_valid_map[$ _inSurf[i]] = is_surface(_inSurf[i]);
}
}
@ -354,7 +352,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
}
var _sed = seed;
var _sct = array_create(_amount);
var _sct = array_verify(_outData[1], _amount);
var _sct_len = 0;
var _arrLen = array_safe_length(_inSurf);
@ -372,12 +370,13 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
var _clrSin = color.evalFast(0);
var _useAtl = outputs[1].visible;
var _datLen = array_length(scatter_data);
var _p = [ 0, 0 ];
#endregion
var _outSurf = _outData[0];
surface_set_target(_outSurf);
gpu_set_tex_filter(getAttribute("interpolate"));
@ -408,7 +407,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
var _scx = _scaUniX? _scale[0] : random_range_seed(_scale[0], _scale[1], _sed++);
var _scy = _scaUniY? _scale[2] : random_range_seed(_scale[2], _scale[3], _sed++);
switch(_dist) { #region position
switch(_dist) { // position
case NODE_SCATTER_DIST.area :
if(_scat == 0) {
var _axc = _area[AREA_INDEX.center_x];
@ -513,8 +512,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
_y = random_range_seed(0, _dim[1], _sed++);
}
break;
} #endregion
}
if(_wigX) _x += random_range_seed(posWig[0], posWig[1], _sed++);
if(_wigY) _y += random_range_seed(posWig[2], posWig[3], _sed++);
@ -585,9 +583,9 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
surf = array_safe_get_fast(_inSurf, ind, 0);
}
if(surf == 0 || !surface_valid_map[? surf]) continue;
if(surf == 0 || !surface_valid_map[$ surf]) continue;
var dim = surface_size_map[? surf];
var dim = surface_size_map[$ surf];
var sw = dim[0];
var sh = dim[1];
@ -683,6 +681,9 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
scatter_data = _sct;
return [ _outSurf, _sct ];
_outData[0] = _outSurf;
_outData[1] = _sct;
return _outData;
}
}

View file

@ -21,7 +21,7 @@ function Node_Seperate_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) cons
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas", self, VALUE_TYPE.surface, []));
newOutput(1, nodeValue_Output("Atlas", self, VALUE_TYPE.atlas, []));
input_display_list = [
["Shape", false], 0, 5, 1, 4,

View file

@ -17,7 +17,7 @@ function Node_Stack(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.surface, []));
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.atlas, []));
temp_surface = [ noone, noone ];

View file

@ -7,6 +7,7 @@ enum OUTPUT_SCALING {
function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Transform";
dimension_index = -1;
newInput(0, nodeValue_Surface("Surface in", self));