From 6dc56388de8b4a10e8d7e392f658f3f4d79eadbb Mon Sep 17 00:00:00 2001 From: Tanasart Date: Tue, 25 Jun 2024 13:44:08 +0700 Subject: [PATCH] - New Slice Stack node. --- PixelComposer.resource_order | 1 + PixelComposer.yyp | 1 + scripts/d3d_object/d3d_object.gml | 2 +- .../font_sprite_loader/font_sprite_loader.gml | 6 +- scripts/globals/globals.gml | 2 +- scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml | 8 +- .../node_3d_mesh_stack_slice.gml | 329 ++++++++++++++++++ .../node_3d_mesh_stack_slice.yy | 13 + .../node_3d_mesh_stack_slice/node_counter.yy | 12 + scripts/node_registry/node_registry.gml | 1 + scripts/obj_reader/obj_reader.gml | 23 +- scripts/panel_inspector/panel_inspector.gml | 17 +- .../surface_functions/surface_functions.gml | 18 +- scripts/var_comparison/var_comparison.gml | 7 +- 14 files changed, 413 insertions(+), 27 deletions(-) create mode 100644 scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.gml create mode 100644 scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy create mode 100644 scripts/node_3d_mesh_stack_slice/node_counter.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 7d893e642..052f01f4f 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -647,6 +647,7 @@ {"name":"node_3d_mesh_plane","order":7,"path":"scripts/node_3d_mesh_plane/node_3d_mesh_plane.yy",}, {"name":"node_3d_mesh_sphere_ico","order":5,"path":"scripts/node_3d_mesh_sphere_ico/node_3d_mesh_sphere_ico.yy",}, {"name":"node_3d_mesh_sphere_uv","order":4,"path":"scripts/node_3d_mesh_sphere_uv/node_3d_mesh_sphere_uv.yy",}, + {"name":"node_3d_mesh_stack_slice","order":7,"path":"scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy",}, {"name":"node_3d_mesh_terrain","order":9,"path":"scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.yy",}, {"name":"node_3d_point_affector","order":11,"path":"scripts/node_3d_point_affector/node_3d_point_affector.yy",}, {"name":"node_3d_repeat","order":1,"path":"scripts/node_3d_repeat/node_3d_repeat.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 8468d9780..4f8f7df58 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1028,6 +1028,7 @@ {"id":{"name":"node_3d_mesh_plane","path":"scripts/node_3d_mesh_plane/node_3d_mesh_plane.yy",},}, {"id":{"name":"node_3d_mesh_sphere_ico","path":"scripts/node_3d_mesh_sphere_ico/node_3d_mesh_sphere_ico.yy",},}, {"id":{"name":"node_3d_mesh_sphere_uv","path":"scripts/node_3d_mesh_sphere_uv/node_3d_mesh_sphere_uv.yy",},}, + {"id":{"name":"node_3d_mesh_stack_slice","path":"scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy",},}, {"id":{"name":"node_3d_mesh_terrain","path":"scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.yy",},}, {"id":{"name":"node_3d_particle","path":"scripts/node_3d_particle/node_3d_particle.yy",},}, {"id":{"name":"node_3d_point_affector","path":"scripts/node_3d_point_affector/node_3d_point_affector.yy",},}, diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index 89136aabd..96424c5b2 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -39,7 +39,7 @@ function __3dObject() constructor { var check = false; for( var i = 0, n = array_length(_keys); i < n; i++ ) { var key = _keys[i]; - if(self[$ key] != params[$ key]) + if(!isEqual(self[$ key], params[$ key])) check = true; self[$ key] = params[$ key]; } diff --git a/scripts/font_sprite_loader/font_sprite_loader.gml b/scripts/font_sprite_loader/font_sprite_loader.gml index ca4b2aacd..6a23d9d64 100644 --- a/scripts/font_sprite_loader/font_sprite_loader.gml +++ b/scripts/font_sprite_loader/font_sprite_loader.gml @@ -6,10 +6,12 @@ FONT_SPRITES = ds_map_create(); if(ds_map_exists(FONT_SPRITES, path)) return; var f = _font_add(path, 32); + if(!font_exists(f)) return; + draw_set_text(f, fa_left, fa_top, c_white); var name = "ABCabc123"; - var ww = string_width(name); - var hh = string_height(name); + var ww = max(1, string_width(name)); + var hh = max(1, string_height(name)); var s = surface_create(ww, hh); surface_set_target(s); diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index b462d4895..c87df8c3c 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -38,7 +38,7 @@ LATEST_VERSION = 11700; VERSION = 11750; SAVE_VERSION = 11700; - VERSION_STRING = "1.17.5.002"; + VERSION_STRING = "1.17.5.003"; BUILD_NUMBER = 11750; globalvar HOTKEYS, HOTKEY_CONTEXT; diff --git a/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml b/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml index 4d0061039..33f2f7060 100644 --- a/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml +++ b/scripts/node_3d_mesh_obj/node_3d_mesh_obj.gml @@ -35,10 +35,13 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) inputs[| in_mesh + 2] = nodeValue("Import Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) .rejectArray(); + inputs[| in_mesh + 3] = nodeValue("Invert Y", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true) + .rejectArray(); + input_display_list = [ __d3d_input_list_mesh, __d3d_input_list_transform, - ["Object", false], in_mesh + 0, in_mesh + 2, + ["Object", false], in_mesh + 0, in_mesh + 2, in_mesh + 3, ["Material", false], in_mesh + 1, ] @@ -107,8 +110,9 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) current_path = _path; var _scale = inputs[| in_mesh + 2].getValue(); + var _yneg = inputs[| in_mesh + 3].getValue(); - readObj_init(_scale); + readObj_init(_scale, _yneg); obj_read_time = get_timer(); obj_read_file = file_text_open_read(current_path); diff --git a/scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.gml b/scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.gml new file mode 100644 index 000000000..269702455 --- /dev/null +++ b/scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.gml @@ -0,0 +1,329 @@ +function Node_3D_Mesh_Stack_Slice(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { + name = "Slice Stack"; + + inputs[| 0] = nodeValue("Mesh", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Mesh, noone) + .setVisible(true, true); + + inputs[| 1] = nodeValue("Output Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 16, 16 ]) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1); + + inputs[| 3] = nodeValue("Slices", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4); + + outputs[| 0] = nodeValue("Outputs", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, []) + .setArrayDepth(1); + + mesh_data = new Inspector_Label("", f_code); + + input_display_list = [ + ["Model", false], 0, mesh_data, + ["Slices", false], 1, 3, + ]; + + insp1UpdateTooltip = "Export"; + insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; + + params = { + mesh : noone, + dim : noone, + sca : noone, + slic : noone, + } + + splicing = false; + splice_progress = 0; + splice_prog_tot = 0; + splice_pixel = 0; + + faces_minx = 99999; faces_maxx = -99999; + faces_miny = 99999; faces_maxy = -99999; + faces_minz = 99999; faces_maxz = -99999; + + faces_data = []; + faces_amo = 1; + + point_size = 14; + + dimensions = [ 1, 1 ]; + slicesAmo = 1; + surfaces = []; + + insp1UpdateTooltip = "Splice"; + insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; + + static onInspector1Update = function(_fromValue = false) { + meshInit(); + spliceInit(true); + } + + static meshInit = function() { + var _mesh = getInputData(0); + if(_mesh == params.mesh) return; + + faces_minx = 99999; faces_maxx = -99999; + faces_miny = 99999; faces_maxy = -99999; + faces_minz = 99999; faces_maxz = -99999; + + var _vbs = _mesh.VB; + var _fac = []; + var _ind = 0; + + for (var i = 0, n = array_length(_vbs); i < n; i++) { + var _vb = _vbs[i]; + + var _buffer = buffer_create_from_vertex_buffer(_vb, buffer_fixed, 1); + var _buffer_s = buffer_get_size(_buffer); + + var _matInd = array_safe_get_fast(_mesh.material_index, i, i); + var _material = array_safe_get_fast(_mesh.materials, _matInd, noone); + var _matSurf = _material == noone? noone : _material.surface; + var _useSurf = surface_exists(_matSurf); + if(_useSurf) { + var _surfBuff = buffer_from_surface(_matSurf, false); + var _surfW = surface_get_width(_matSurf); + var _surfH = surface_get_height(_matSurf); + } + + switch(_mesh.VF) { + case global.VF_POS_NORM_TEX_COL : + var _format_s = global.VF_POS_NORM_TEX_COL_size; + var _vertex_s = floor(_buffer_s / _format_s); + buffer_to_start(_buffer); + + var _pnt = []; + var _pid = 0; + var _uu = 0; + var _vv = 0; + + repeat(_vertex_s) { + var _px = buffer_read(_buffer, buffer_f32); + var _py = buffer_read(_buffer, buffer_f32); + var _pz = buffer_read(_buffer, buffer_f32); + + var _nx = buffer_read(_buffer, buffer_f32); + var _ny = buffer_read(_buffer, buffer_f32); + var _nz = buffer_read(_buffer, buffer_f32); + + var _u = buffer_read(_buffer, buffer_f32); + var _v = buffer_read(_buffer, buffer_f32); + + var _r = buffer_read(_buffer, buffer_s8); + var _g = buffer_read(_buffer, buffer_s8); + var _b = buffer_read(_buffer, buffer_s8); + var _a = buffer_read(_buffer, buffer_s8); + + _pnt[_pid++] = _px; + _pnt[_pid++] = _py; + _pnt[_pid++] = _pz; + + _uu += _u / 3; + _vv += _v / 3; + + faces_minx = min(faces_minx, _px); + faces_maxx = max(faces_maxx, _px); + faces_miny = min(faces_miny, _py); + faces_maxy = max(faces_maxy, _py); + faces_minz = min(faces_minz, _pz); + faces_maxz = max(faces_maxz, _pz); + + if(_pid == 9) { + _pnt[9] = _useSurf? buffer_read_at(_surfBuff, (round(_vv * _surfH) * _surfW + round(_uu * _surfW)) * 4, buffer_u32) : c_white; + _pnt[10] = max(_pnt[0], _pnt[3], _pnt[6]); + + _pnt[11] = (_pnt[0] + _pnt[3] + _pnt[6]) / 3; + _pnt[12] = (_pnt[1] + _pnt[4] + _pnt[7]) / 3; + _pnt[13] = (_pnt[2] + _pnt[5] + _pnt[8]) / 3; + + _fac[_ind++] = _pnt; + _pnt = []; + _pid = 0; + + _uu = 0; + _vv = 0; + } + } + break; + } + + if(_useSurf) buffer_delete(_surfBuff); + } + + array_sort(_fac, function(a1, a2) { return sign(a2[10] - a1[10]); }); + + faces_amo = _ind; + for (var i = 0, n = _ind; i < n; i++) { + for(var j = 0; j < point_size; j++) + faces_data[i * point_size + j] = _fac[i][j]; + } + + params.mesh = _mesh; + } + + static spliceInit = function(force = false) { + if(splicing) return; + + var _mesh = getInputData(0); + dimensions = getInputData(1); + slicesAmo = getInputData(3); + + if(_mesh == noone) return; + if(!is_instanceof(_mesh, __3dObject)) return; + + var _surfs = outputs[| 0].getValue(); + _surfs = array_verify(_surfs, slicesAmo); + + for(var i = 0; i < slicesAmo; i++) { + _surfs[i] = surface_verify(_surfs[i], dimensions[0], dimensions[1]); + surface_clear(_surfs[i]); + } + + surfaces = _surfs; + outputs[| 0].setValue(_surfs); + + splicing = force || dimensions != params.dim || slicesAmo != params.slic; + splice_progress = 0; + splice_prog_tot = slicesAmo; + + params.dim = dimensions; + params.slic = slicesAmo; + } + + static splice = function() { + if(!splicing) return; + + var _faces = faces_amo; + var _ranx = faces_maxx - faces_minx; + var _rany = faces_maxy - faces_miny; + var _ranz = faces_maxz - faces_minz; + + mesh_data.text = $"Faces: {_faces}\nSize: [{_ranx}, {_rany}, {_ranz}]"; + + var _stpx = _ranx / dimensions[0]; + var _stpy = _rany / dimensions[1]; + var _stpz = _ranz / slicesAmo; + + var _strx = faces_minx + _stpx / 2; + var _stry = faces_miny + _stpy / 2; + var _strz = faces_minz + _stpz / 2; + + var _f1x, _f1y, _f1z, _f2x, _f2y, _f2z, _f3x, _f3y, _f3z; + var w = dimensions[0]; + var _pxAmo = dimensions[0] * dimensions[1]; + + var _z = splice_progress; + var _surf = surfaces[_z]; + var _pz = _strz + _z * _stpz; + + var _left = _pxAmo - splice_pixel; + var _time = get_timer(); + + surface_set_target(_surf); + + repeat(_left) { + _x = splice_pixel % w; + _y = floor(splice_pixel / w); + splice_pixel++; + + var _px = _strx + _x * _stpx; + var _py = _stry + _y * _stpy; + + var _inSide = false; + var _fc = c_white; + var _dist = 99999; + + var _f = 0, _fi = 0; + repeat(_faces) { + _f = _fi; + _fi += point_size; + + if(faces_data[_f + 10] < _px - 0.1) break; + + _f1x = faces_data[_f + 0]; _f2x = faces_data[_f + 3]; _f3x = faces_data[_f + 6]; + _f1y = faces_data[_f + 1]; _f2y = faces_data[_f + 4]; _f3y = faces_data[_f + 7]; + _f1z = faces_data[_f + 2]; _f2z = faces_data[_f + 5]; _f3z = faces_data[_f + 8]; + + var edge1x = _f2x - _f1x; + var edge1y = _f2y - _f1y; + var edge1z = _f2z - _f1z; + + var edge2x = _f3x - _f1x; + var edge2y = _f3y - _f1y; + var edge2z = _f3z - _f1z; + + var pvecx = _py * edge2z - _pz * edge2y; + var pvecy = _pz * edge2x - _px * edge2z; + var pvecz = _px * edge2y - _py * edge2x; + + var det = edge1x * pvecx + edge1y * pvecy + edge1z * pvecz; + + if (abs(det) < 0.0001) continue; + + var inv_det = 1.0 / det; + + var tvecx = _px - _f1x; + var tvecy = _py - _f1y; + var tvecz = _pz - _f1z; + + var u = (tvecx * pvecx + tvecy * pvecy + tvecz * pvecz) * inv_det; + if (u < 0.0 || u > 1.0) continue; + + var qvecx = tvecy * edge1z - tvecz * edge1y; + var qvecy = tvecz * edge1x - tvecx * edge1z; + var qvecz = tvecx * edge1y - tvecy * edge1x; + + var v = (_px * qvecx + _py * qvecy + _pz * qvecz) * inv_det; + if (v < 0.0 || u + v > 1.0) continue; + + var t = (edge2x * qvecx + edge2y * qvecy + edge2z * qvecz) * inv_det; + if(t <= 0) continue; + + _inSide = !_inSide; + + var _d = sqr(_px - faces_data[_f + 11]) + sqr(_py - faces_data[_f + 12]) + sqr(_pz - faces_data[_f + 13]); + if(_d < _dist) { + _dist = _d; + _fc = faces_data[_f + 9]; + } + } + + if(!_inSide) continue; + draw_point_color(_x, _y, _fc); + + if(get_timer() - _time > 1_000_000 / 60) + break; + } + surface_reset_target(); + + if(splice_pixel >= _pxAmo) { + splice_pixel = 0; + splice_progress++; + + if(splice_progress >= splice_prog_tot) { + splicing = false; + triggerRender(); + } + } + } + + static step = function() { + if(splicing) splice(); + } + + static update = function() { + + } + + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + if(splicing) { + var cx = xx + w * _s / 2; + var cy = yy + h * _s / 2; + var rr = min(w - 32, h - 32) * _s / 2; + + draw_set_color(COLORS._main_icon); + draw_arc(cx, cy, rr, current_time / 5, current_time / 5 + 90, 4 * _s, 90); + return; + } + } + +} \ No newline at end of file diff --git a/scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy b/scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy new file mode 100644 index 000000000..5ad5d9e97 --- /dev/null +++ b/scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"", + "%Name":"node_3d_mesh_stack_slice", + "isCompatibility":false, + "isDnD":false, + "name":"node_3d_mesh_stack_slice", + "parent":{ + "name":"d3d_modifier", + "path":"folders/nodes/data/3D/d3d_modifier.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/node_3d_mesh_stack_slice/node_counter.yy b/scripts/node_3d_mesh_stack_slice/node_counter.yy new file mode 100644 index 000000000..10832a0b0 --- /dev/null +++ b/scripts/node_3d_mesh_stack_slice/node_counter.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "variable", + "path": "folders/nodes/data/variable.yy", + }, + "resourceVersion": "1.0", + "name": "node_counter", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 82775283b..a035cc2ce 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -686,6 +686,7 @@ function __initNodes() { addNodeObject(d3d, "Transform", s_node_3d_transform, "Node_3D_Transform", [1, Node_3D_Transform],, "Transform 3D object.").setVersion(11570); addNodeObject(d3d, "Transform Scene", s_node_3d_transform_scene, "Node_3D_Transform_Scene", [1, Node_3D_Transform_Scene],, "Transform 3D scene, accepts array of transformations for each objects.").setVersion(11570); addNodeObject(d3d, "UV Remap", s_node_uv_remap, "Node_3D_UV_Remap", [1, Node_3D_UV_Remap],, "Remap UV map using plane.").setVersion(11570); + addNodeObject(d3d, "Slice Stack", s_node_3d_stack_slice, "Node_3D_Mesh_Stack_Slice", [1, Node_3D_Mesh_Stack_Slice],, "").setVersion(11750); ///**/ addNodeObject(d3d, "3D Instancer", s_node_3d_set_material, "Node_3D_Instancer", [1, Node_3D_Instancer]).setVersion(11560); ///**/ addNodeObject(d3d, "3D Particle", s_node_3d_set_material, "Node_3D_Particle", [1, Node_3D_Particle]).setVersion(11560); diff --git a/scripts/obj_reader/obj_reader.gml b/scripts/obj_reader/obj_reader.gml index b64e87667..39506426a 100644 --- a/scripts/obj_reader/obj_reader.gml +++ b/scripts/obj_reader/obj_reader.gml @@ -1,4 +1,4 @@ -function readObj_init(_scale = 1) { +function readObj_init(_scale = 1, _yneg = false) { obj_reading = true; obj_read_progress = 0; obj_read_prog_sub = 0; @@ -6,6 +6,7 @@ function readObj_init(_scale = 1) { obj_raw = noone; obj_reading_scale = _scale; + obj_reading_yneg = _yneg; _VB = []; _VBT = []; @@ -39,11 +40,19 @@ function readObj_file() { switch(sep[0]) { case "v" : - ds_list_add(v, [ - toNumber(sep[1]) * obj_reading_scale, - toNumber(sep[2]) * obj_reading_scale, - toNumber(sep[3]) * obj_reading_scale - ]); + if(obj_reading_yneg) { + ds_list_add(v, [ + toNumber(sep[1]) * obj_reading_scale, + toNumber(sep[3]) * obj_reading_scale, + -toNumber(sep[2]) * obj_reading_scale, + ]); + } else { + ds_list_add(v, [ + toNumber(sep[1]) * obj_reading_scale, + toNumber(sep[2]) * obj_reading_scale, + toNumber(sep[3]) * obj_reading_scale, + ]); + } break; case "vt" : @@ -270,7 +279,7 @@ function readObj_buff() { } vertex_end(VB); - vertex_freeze(VB); + // vertex_freeze(VB); VBS[i] = VB; V[i] = ds_list_to_array(_v); diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index eb118eb70..4cb1363c6 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -29,9 +29,9 @@ function Inspector_Custom_Renderer(drawFn, registerFn = noone) : widget() constr static toString = function() { return $"Custon renderer"; } } #endregion -function Inspector_Sprite(spr) constructor { self.spr = spr; } - -function Inspector_Spacer(height, line = false) constructor { self.h = height; self.line = line; } +function Inspector_Sprite(spr) constructor { self.spr = spr; } +function Inspector_Spacer(height, line = false) constructor { self.h = height; self.line = line; } +function Inspector_Label( text, font = f_p3) constructor { self.text = text; self.font = font; } function Panel_Inspector() : PanelContent() constructor { #region ---- main ---- @@ -593,6 +593,17 @@ function Panel_Inspector() : PanelContent() constructor { hh += _sh + ui(8); continue; + } else if(is_instanceof(jun_disp, Inspector_Label)) { // TEXT + var _txt = jun_disp.text; + + draw_set_text(jun_disp.font, fa_left, fa_top, COLORS._main_text_sub); + var _sh = string_height_ext(_txt, -1, con_w - ui(16)) + ui(16); + draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, 0, yy, con_w, _sh, COLORS._main_icon_light); + draw_text_ext(ui(8), yy + ui(8), _txt, -1, con_w - ui(16)); + + hh += _sh + ui(8); + continue; + } else if(is_array(jun_disp)) { // LABEL var pad = i && _colsp == false? ui(4) : 0 _colsp = false; diff --git a/scripts/surface_functions/surface_functions.gml b/scripts/surface_functions/surface_functions.gml index c20eed9a9..aa534c5be 100644 --- a/scripts/surface_functions/surface_functions.gml +++ b/scripts/surface_functions/surface_functions.gml @@ -10,7 +10,7 @@ } else if(is_instanceof(surface, SurfaceAtlas)) surface = surface.getSurface(); } - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; __channel_pre(surface); draw_surface(surface, _x, _y); @@ -27,7 +27,7 @@ } else if(is_instanceof(surface, SurfaceAtlas)) surface = surface.getSurface(); } - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; __channel_pre(surface); draw_surface_stretched(surface, _x, _y, _w, _h); @@ -45,7 +45,7 @@ surface = surface.getSurface(); } - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; __channel_pre(surface); draw_surface_ext(surface, _x, _y, _xs, _ys, _rot, _col, _alpha); @@ -62,7 +62,7 @@ } else if(is_instanceof(surface, SurfaceAtlas)) surface = surface.getSurface(); } - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; __channel_pre(surface); draw_surface_tiled(surface, _x, _y); @@ -79,7 +79,7 @@ } else if(is_instanceof(surface, SurfaceAtlas)) surface = surface.getSurface(); } - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; var back = surface_get_target(); var bdim = surface_get_dimension(back); @@ -105,7 +105,7 @@ } else if(is_instanceof(surface, SurfaceAtlas)) surface = surface.getSurface(); } - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; __channel_pre(surface); draw_surface_part_ext(surface, _l, _t, _w, _h, _x, _y, _xs, _ys, _col, _alpha); @@ -225,7 +225,7 @@ INLINE if(is_instanceof(surface, SurfaceAtlas)) surface = surface.surface.get(); - if(!surface_exists(surface)) return 0; + if(is_array(surface) || !surface_exists(surface)) return 0; var px = surface_getpixel_ext(surface, _x, _y); if(is_numeric(px)) return int64(px); @@ -565,7 +565,7 @@ function surface_encode(surface, stringify = true) { #region if(is_instanceof(surface, SurfaceAtlas)) surface = surface.surface.get(); - if(!surface_exists(surface)) return ""; + if(is_array(surface) || !surface_exists(surface)) return ""; var buff = buffer_create(surface_get_width_safe(surface) * surface_get_height_safe(surface) * 4, buffer_fixed, 1); @@ -631,7 +631,7 @@ else if(is_instanceof(surface, SurfaceAtlasFast)) surface = surface.surface; else if(is_instanceof(surface, dynaSurf)) surface = array_safe_get(surface.surfaces, 0); - if(!surface_exists(surface)) return; + if(is_array(surface) || !surface_exists(surface)) return; var f = surface_get_format(surface); diff --git a/scripts/var_comparison/var_comparison.gml b/scripts/var_comparison/var_comparison.gml index 4c3ea1578..b633b56aa 100644 --- a/scripts/var_comparison/var_comparison.gml +++ b/scripts/var_comparison/var_comparison.gml @@ -3,8 +3,11 @@ function isEqual(val1, val2, struct_expand = false, _depth = 0) { #region if(_depth > 8) return false; - if(is_array(val1) && is_array(val2)) return array_member_equal(val1, val2, _depth); - if(struct_expand && is_struct(val1) && is_struct(val2)) return struct_equal(val1, val2, _depth); + if(is_array(val1) && is_array(val2)) + return array_member_equal(val1, val2, _depth); + + if(struct_expand && is_struct(val1) && is_struct(val2)) + return struct_equal(val1, val2, _depth); return val1 == val2; } #endregion