- New Slice Stack node.

This commit is contained in:
Tanasart 2024-06-25 13:44:08 +07:00
parent fdf245c1a9
commit 6dc56388de
14 changed files with 413 additions and 27 deletions

View file

@ -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_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_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_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_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_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",}, {"name":"node_3d_repeat","order":1,"path":"scripts/node_3d_repeat/node_3d_repeat.yy",},

View file

@ -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_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_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_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_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_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",},}, {"id":{"name":"node_3d_point_affector","path":"scripts/node_3d_point_affector/node_3d_point_affector.yy",},},

View file

@ -39,7 +39,7 @@ function __3dObject() constructor {
var check = false; var check = false;
for( var i = 0, n = array_length(_keys); i < n; i++ ) { for( var i = 0, n = array_length(_keys); i < n; i++ ) {
var key = _keys[i]; var key = _keys[i];
if(self[$ key] != params[$ key]) if(!isEqual(self[$ key], params[$ key]))
check = true; check = true;
self[$ key] = params[$ key]; self[$ key] = params[$ key];
} }

View file

@ -6,10 +6,12 @@ FONT_SPRITES = ds_map_create();
if(ds_map_exists(FONT_SPRITES, path)) return; if(ds_map_exists(FONT_SPRITES, path)) return;
var f = _font_add(path, 32); var f = _font_add(path, 32);
if(!font_exists(f)) return;
draw_set_text(f, fa_left, fa_top, c_white); draw_set_text(f, fa_left, fa_top, c_white);
var name = "ABCabc123"; var name = "ABCabc123";
var ww = string_width(name); var ww = max(1, string_width(name));
var hh = string_height(name); var hh = max(1, string_height(name));
var s = surface_create(ww, hh); var s = surface_create(ww, hh);
surface_set_target(s); surface_set_target(s);

View file

@ -38,7 +38,7 @@
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11750; VERSION = 11750;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.5.002"; VERSION_STRING = "1.17.5.003";
BUILD_NUMBER = 11750; BUILD_NUMBER = 11750;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;

View file

@ -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) inputs[| in_mesh + 2] = nodeValue("Import Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.rejectArray(); .rejectArray();
inputs[| in_mesh + 3] = nodeValue("Invert Y", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true)
.rejectArray();
input_display_list = [ input_display_list = [
__d3d_input_list_mesh, __d3d_input_list_mesh,
__d3d_input_list_transform, __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, ["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; current_path = _path;
var _scale = inputs[| in_mesh + 2].getValue(); 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_time = get_timer();
obj_read_file = file_text_open_read(current_path); obj_read_file = file_text_open_read(current_path);

View file

@ -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;
}
}
}

View file

@ -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",
}

View file

@ -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",
}

View file

@ -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", 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, "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, "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 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); ///**/ addNodeObject(d3d, "3D Particle", s_node_3d_set_material, "Node_3D_Particle", [1, Node_3D_Particle]).setVersion(11560);

View file

@ -1,4 +1,4 @@
function readObj_init(_scale = 1) { function readObj_init(_scale = 1, _yneg = false) {
obj_reading = true; obj_reading = true;
obj_read_progress = 0; obj_read_progress = 0;
obj_read_prog_sub = 0; obj_read_prog_sub = 0;
@ -6,6 +6,7 @@ function readObj_init(_scale = 1) {
obj_raw = noone; obj_raw = noone;
obj_reading_scale = _scale; obj_reading_scale = _scale;
obj_reading_yneg = _yneg;
_VB = []; _VB = [];
_VBT = []; _VBT = [];
@ -39,11 +40,19 @@ function readObj_file() {
switch(sep[0]) { switch(sep[0]) {
case "v" : case "v" :
ds_list_add(v, [ if(obj_reading_yneg) {
toNumber(sep[1]) * obj_reading_scale, ds_list_add(v, [
toNumber(sep[2]) * obj_reading_scale, toNumber(sep[1]) * obj_reading_scale,
toNumber(sep[3]) * 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; break;
case "vt" : case "vt" :
@ -270,7 +279,7 @@ function readObj_buff() {
} }
vertex_end(VB); vertex_end(VB);
vertex_freeze(VB); // vertex_freeze(VB);
VBS[i] = VB; VBS[i] = VB;
V[i] = ds_list_to_array(_v); V[i] = ds_list_to_array(_v);

View file

@ -29,9 +29,9 @@ function Inspector_Custom_Renderer(drawFn, registerFn = noone) : widget() constr
static toString = function() { return $"Custon renderer"; } static toString = function() { return $"Custon renderer"; }
} #endregion } #endregion
function Inspector_Sprite(spr) constructor { self.spr = spr; } function Inspector_Sprite(spr) constructor { self.spr = spr; }
function Inspector_Spacer(height, line = false) constructor { self.h = height; self.line = line; }
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 { function Panel_Inspector() : PanelContent() constructor {
#region ---- main ---- #region ---- main ----
@ -593,6 +593,17 @@ function Panel_Inspector() : PanelContent() constructor {
hh += _sh + ui(8); hh += _sh + ui(8);
continue; 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 } else if(is_array(jun_disp)) { // LABEL
var pad = i && _colsp == false? ui(4) : 0 var pad = i && _colsp == false? ui(4) : 0
_colsp = false; _colsp = false;

View file

@ -10,7 +10,7 @@
} else if(is_instanceof(surface, SurfaceAtlas)) } else if(is_instanceof(surface, SurfaceAtlas))
surface = surface.getSurface(); surface = surface.getSurface();
} }
if(!surface_exists(surface)) return; if(is_array(surface) || !surface_exists(surface)) return;
__channel_pre(surface); __channel_pre(surface);
draw_surface(surface, _x, _y); draw_surface(surface, _x, _y);
@ -27,7 +27,7 @@
} else if(is_instanceof(surface, SurfaceAtlas)) } else if(is_instanceof(surface, SurfaceAtlas))
surface = surface.getSurface(); surface = surface.getSurface();
} }
if(!surface_exists(surface)) return; if(is_array(surface) || !surface_exists(surface)) return;
__channel_pre(surface); __channel_pre(surface);
draw_surface_stretched(surface, _x, _y, _w, _h); draw_surface_stretched(surface, _x, _y, _w, _h);
@ -45,7 +45,7 @@
surface = surface.getSurface(); surface = surface.getSurface();
} }
if(!surface_exists(surface)) return; if(is_array(surface) || !surface_exists(surface)) return;
__channel_pre(surface); __channel_pre(surface);
draw_surface_ext(surface, _x, _y, _xs, _ys, _rot, _col, _alpha); draw_surface_ext(surface, _x, _y, _xs, _ys, _rot, _col, _alpha);
@ -62,7 +62,7 @@
} else if(is_instanceof(surface, SurfaceAtlas)) } else if(is_instanceof(surface, SurfaceAtlas))
surface = surface.getSurface(); surface = surface.getSurface();
} }
if(!surface_exists(surface)) return; if(is_array(surface) || !surface_exists(surface)) return;
__channel_pre(surface); __channel_pre(surface);
draw_surface_tiled(surface, _x, _y); draw_surface_tiled(surface, _x, _y);
@ -79,7 +79,7 @@
} else if(is_instanceof(surface, SurfaceAtlas)) } else if(is_instanceof(surface, SurfaceAtlas))
surface = surface.getSurface(); surface = surface.getSurface();
} }
if(!surface_exists(surface)) return; if(is_array(surface) || !surface_exists(surface)) return;
var back = surface_get_target(); var back = surface_get_target();
var bdim = surface_get_dimension(back); var bdim = surface_get_dimension(back);
@ -105,7 +105,7 @@
} else if(is_instanceof(surface, SurfaceAtlas)) } else if(is_instanceof(surface, SurfaceAtlas))
surface = surface.getSurface(); surface = surface.getSurface();
} }
if(!surface_exists(surface)) return; if(is_array(surface) || !surface_exists(surface)) return;
__channel_pre(surface); __channel_pre(surface);
draw_surface_part_ext(surface, _l, _t, _w, _h, _x, _y, _xs, _ys, _col, _alpha); draw_surface_part_ext(surface, _l, _t, _w, _h, _x, _y, _xs, _ys, _col, _alpha);
@ -225,7 +225,7 @@
INLINE INLINE
if(is_instanceof(surface, SurfaceAtlas)) surface = surface.surface.get(); 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); var px = surface_getpixel_ext(surface, _x, _y);
if(is_numeric(px)) return int64(px); if(is_numeric(px)) return int64(px);
@ -565,7 +565,7 @@
function surface_encode(surface, stringify = true) { #region function surface_encode(surface, stringify = true) { #region
if(is_instanceof(surface, SurfaceAtlas)) surface = surface.surface.get(); 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); 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, SurfaceAtlasFast)) surface = surface.surface;
else if(is_instanceof(surface, dynaSurf)) surface = array_safe_get(surface.surfaces, 0); 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); var f = surface_get_format(surface);

View file

@ -3,8 +3,11 @@ function isEqual(val1, val2, struct_expand = false, _depth = 0) { #region
if(_depth > 8) return false; if(_depth > 8) return false;
if(is_array(val1) && is_array(val2)) return array_member_equal(val1, val2, _depth); if(is_array(val1) && is_array(val2))
if(struct_expand && is_struct(val1) && is_struct(val2)) return struct_equal(val1, val2, _depth); 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; return val1 == val2;
} #endregion } #endregion