From 7ad45363c79d06a1de2da2d44d7dd2522515ce5c Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Sat, 2 Sep 2023 10:43:33 +0200 Subject: [PATCH] - [Warp, Area Warp] Fix default anchor position not the same as surface dimension. --- scripts/node_3d_camera/node_3d_camera.gml | 6 +- scripts/node_text/node_text.gml | 31 ++++------ scripts/node_wrap/node_wrap.gml | 72 ++++++++--------------- scripts/node_wrap_area/node_wrap_area.gml | 15 +++++ 4 files changed, 52 insertions(+), 72 deletions(-) diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml index ede9d022a..ec0aa2806 100644 --- a/scripts/node_3d_camera/node_3d_camera.gml +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -2,9 +2,9 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) name = "3D Camera"; batch_output = true; - object = new __3dCamera_object(); - camera = new __3dCamera(); - lookat = new __3dGizmoSphere(0.5, c_ltgray, 1); + object = new __3dCamera_object(); + camera = new __3dCamera(); + lookat = new __3dGizmoSphere(0.5, c_ltgray, 1); lookLine = noone; lookRad = new __3dGizmoCircleZ(0.5, c_yellow, 0.5); diff --git a/scripts/node_text/node_text.gml b/scripts/node_text/node_text.gml index 36e8a4f34..d6d13ba9e 100644 --- a/scripts/node_text/node_text.gml +++ b/scripts/node_text/node_text.gml @@ -36,7 +36,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons input_display_list = [ ["Output", true], 9, 6, 10, ["Text", false], 0, 7, 8, 5, - ["Font properties", false], 1, 2, 3, 4 + ["Font properties", false], 1, 2, 3, ]; outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -46,30 +46,22 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons _font_current = ""; _size_current = 0; _aa_current = false; - _rang_current = [0, 0]; - static generateFont = function(_path, _size, _aa, _range) { + static generateFont = function(_path, _size, _aa) { if(PROJECT.animator.is_playing) return; - - if(_path == _font_current && - _size == _size_current && - _aa == _aa_current && - _rang_current[0] == _range[0] && - _rang_current[1] == _range[1]) return; + if(_path == _font_current && _size == _size_current && _aa == _aa_current) return; _font_current = _path; _size_current = _size; _aa_current = _aa; - _rang_current[0] = _range[0]; - _rang_current[1] = _range[1]; - if(file_exists(_path)) { - if(font != f_p0 && font_exists(font)) - font_delete(font); + if(!file_exists(_path)) return; + + if(font != f_p0 && font_exists(font)) + font_delete(font); - font_add_enable_aa(_aa); - font = font_add(_path, _size, false, false, _range[0], _range[1]); - } + font_add_enable_aa(_aa); + font = font_add(_path, _size, false, false, 0, 0); } static processData = function(_outSurf, _data, _output_index, _array_index) { @@ -77,7 +69,6 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var _font = _data[1]; var _size = _data[2]; var _aa = _data[3]; - var _range = _data[4]; var _col = _data[5]; var _dim_type = _data[9]; @@ -88,7 +79,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var ww, hh; - generateFont(_font, _size, _aa, _range); + generateFont(_font, _size, _aa); draw_set_font(font); if(_dim_type == 0) { @@ -105,7 +96,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons surface_set_target(_outSurf); DRAW_CLEAR - BLEND_OVERRIDE; + BLEND_ALPHA if(_dim[0] != 0 && _dim[1] != 0) { var _hali = _data[7]; diff --git a/scripts/node_wrap/node_wrap.gml b/scripts/node_wrap/node_wrap.gml index 0c5e7151a..05a636c9d 100644 --- a/scripts/node_wrap/node_wrap.gml +++ b/scripts/node_wrap/node_wrap.gml @@ -37,7 +37,26 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons drag_my = 0; drag_s = [[0, 0], [0, 0]]; - static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { + attributes[? "initalset"] = false; + + static onValueFromUpdate = function(index) { #region + if(index == 0 && attributes[? "initalset"] == false) { + var _surf = inputs[| 0].getValue(); + if(!is_surface(_surf)) return; + + var _sw = surface_get_width(_surf); + var _sh = surface_get_height(_surf); + + inputs[| 1].setValue([ 0, 0 ]); + inputs[| 2].setValue([ _sw, 0 ]); + inputs[| 3].setValue([ 0, _sh ]); + inputs[| 4].setValue([ _sw, _sh ]); + + attributes[? "initalset"] = true; + } + } #endregion + + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region if(array_length(current_data) < ds_list_size(inputs)) return; var _surf = outputs[| 0].getValue(); @@ -171,9 +190,9 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons 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); - } + } #endregion - static processData = function(_outSurf, _data, _output_index, _array_index) { + static processData = function(_outSurf, _data, _output_index, _array_index) { #region var tl = _data[1]; var tr = _data[2]; var bl = _data[3]; @@ -204,51 +223,6 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons surface_reset_shader(); } - //surface_set_shader(_outSurf); - //shader_set_interpolation(_data[0]); - // draw_set_color(c_white); - - // var tex = surface_get_texture(_data[0]); - // draw_primitive_begin_texture(pr_trianglestrip, tex); - - // var res = 4; - // var _i0, _i1, _j0, _j1; - // var tl_x = tl[0]; - // var tl_y = tl[1]; - // var tr_x = tr[0]; - // var tr_y = tr[1]; - // var bl_x = bl[0]; - // var bl_y = bl[1]; - // var br_x = br[0]; - // var br_y = br[1]; - - // for( var i = 0; i < res; i++ ) { - // for( var j = 0; j < res; j++ ) { - // _i0 = i / res; - // _i1 = (i + 1) / res; - // _j0 = j / res; - // _j1 = (j + 1) / res; - - // var _tlx = lerp(lerp(tl_x, tr_x, _i0), lerp(bl_x, br_x, _i0), _j0); - // var _tly = lerp(lerp(tl_y, tr_y, _i0), lerp(bl_y, br_y, _i0), _j0); - // var _trx = lerp(lerp(tl_x, tr_x, _i1), lerp(bl_x, br_x, _i1), _j0); - // var _try = lerp(lerp(tl_y, tr_y, _i1), lerp(bl_y, br_y, _i1), _j0); - - // var _blx = lerp(lerp(tl_x, tr_x, _i0), lerp(bl_x, br_x, _i0), _j1); - // var _bly = lerp(lerp(tl_y, tr_y, _i0), lerp(bl_y, br_y, _i0), _j1); - // var _brx = lerp(lerp(tl_x, tr_x, _i1), lerp(bl_x, br_x, _i1), _j1); - // var _bry = lerp(lerp(tl_y, tr_y, _i1), lerp(bl_y, br_y, _i1), _j1); - - // draw_vertex_texture(_tlx, _tly, _i0, _j0); - // draw_vertex_texture(_trx, _try, _i1, _j0); - - // draw_vertex_texture(_blx, _bly, _i0, _j1); - // draw_vertex_texture(_brx, _bry, _i1, _j1); - // } - // } - // draw_primitive_end(); - //surface_reset_shader(); - return _outSurf; - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_wrap_area/node_wrap_area.gml b/scripts/node_wrap_area/node_wrap_area.gml index 603e44a8b..67b6383e3 100644 --- a/scripts/node_wrap_area/node_wrap_area.gml +++ b/scripts/node_wrap_area/node_wrap_area.gml @@ -19,6 +19,21 @@ function Node_Wrap_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) attribute_surface_depth(); attribute_interpolation(); + attributes[? "initalset"] = false; + + static onValueFromUpdate = function(index) { #region + if(index == 0 && attributes[? "initalset"] == false) { + var _surf = inputs[| 0].getValue(); + if(!is_surface(_surf)) return; + + var _sw = surface_get_width(_surf); + var _sh = surface_get_height(_surf); + + inputs[| 1].setValue([ _sw / 2, _sh / 2, _sw / 2, _sh / 2, AREA_SHAPE.rectangle ]); + attributes[? "initalset"] = true; + } + } #endregion + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); }