diff --git a/datafiles/data/Nodes/Internal.zip b/datafiles/data/Nodes/Internal.zip index c239c50b7..fc774066e 100644 Binary files a/datafiles/data/Nodes/Internal.zip and b/datafiles/data/Nodes/Internal.zip differ diff --git a/datafiles/data/Nodes/Internal/Custom/Node_Custom/info.json b/datafiles/data/Nodes/Internal/Custom/Node_Custom/info.json index 18061718c..eccd17af0 100644 --- a/datafiles/data/Nodes/Internal/Custom/Node_Custom/info.json +++ b/datafiles/data/Nodes/Internal/Custom/Node_Custom/info.json @@ -1,6 +1,6 @@ { "tooltip":"Custom node", - "spr":"__newsprite1112", + "spr":"s_node_icon", "baseNode":"Node_Custom", "io":[ ], diff --git a/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json b/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json index 62c50ccf0..6a4f4a830 100644 --- a/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json +++ b/datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr/info.json @@ -11,6 +11,6 @@ "intersection", "difference", "xor", - ] + ], "pxc_version":118069, } \ No newline at end of file diff --git a/datafiles/data/Theme.zip b/datafiles/data/Theme.zip index 2acf2fbab..8dc703365 100644 Binary files a/datafiles/data/Theme.zip and b/datafiles/data/Theme.zip differ diff --git a/scripts/__path/__path.gml b/scripts/__path/__path.gml index 81b7afba5..cf00f6daf 100644 --- a/scripts/__path/__path.gml +++ b/scripts/__path/__path.gml @@ -13,7 +13,7 @@ function Path() constructor { static getTangentRatio = function(_rat) { return 0; } - static getPointDistance = function(_seg, _ind = 0, out = undefined) { return new __vec2(0, 0); } + static getPointDistance = function(_seg, _ind = 0, out = undefined) { return new __vec2P(0, 0); } static getPointRatio = function(_rat, _ind = 0, out = undefined) { var pix = frac(_rat) * lengthTotal; return getPointDistance(pix, _ind, out); @@ -64,7 +64,7 @@ function PathSegment() : Path() constructor { } #endregion static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } for( var i = 0; i < array_length(lengths); i++ ) { if(_dist <= lengths[i]) { diff --git a/scripts/array_functions/array_functions.gml b/scripts/array_functions/array_functions.gml index a64e1d2d5..21fb2e398 100644 --- a/scripts/array_functions/array_functions.gml +++ b/scripts/array_functions/array_functions.gml @@ -132,9 +132,7 @@ var v0 = array_safe_get_fast(arr, floor(index)); var v1 = array_safe_get_fast(arr, floor(index) + 1); - return color? - merge_color(v0, v1, frac(index)) : - lerp(v0, v1, frac(index)); + return color? merge_color(v0, v1, frac(index)) : lerp(v0, v1, frac(index)); } function array_safe_length(arr) { diff --git a/scripts/collection_data/collection_data.gml b/scripts/collection_data/collection_data.gml index 0ecd1a1c2..cb3e1b1fd 100644 --- a/scripts/collection_data/collection_data.gml +++ b/scripts/collection_data/collection_data.gml @@ -1,5 +1,5 @@ function __initCollection() { - printDebug("COLLECTION", "init"); + printDebug("COLLECTION: init"); globalvar COLLECTIONS; COLLECTIONS = -1; @@ -15,7 +15,7 @@ function __initCollection() { } function refreshCollections() { - printDebug("COLLECTION", "refreshing collection base folder."); + printDebug("COLLECTION: refreshing collection base folder."); COLLECTIONS = new DirectoryObject(DIRECTORY + "Collections"); COLLECTIONS.scan([".json", ".pxcc"]); diff --git a/scripts/distance_to_line/distance_to_line.gml b/scripts/distance_to_line/distance_to_line.gml index eb4186cff..80dc9af34 100644 --- a/scripts/distance_to_line/distance_to_line.gml +++ b/scripts/distance_to_line/distance_to_line.gml @@ -1,5 +1,13 @@ -function distance_to_line(_px, _py, _x0, _y0, _x1, _y1, log = false) { - INLINE +function point_to_line(_px, _py, _x0, _y0, _x1, _y1) { + var l2 = sqr(_x0 - _x1) + sqr(_y0 - _y1); + if (l2 == 0) return [ _x0, _y0 ]; + + var t = ((_px - _x0) * (_x1 - _x0) + (_py - _y0) * (_y1 - _y0)) / l2; + t = clamp(t, 0, 1); + return [ lerp(_x0, _x1, t), lerp(_y0, _y1, t) ]; +} + +function distance_to_line(_px, _py, _x0, _y0, _x1, _y1) { var l2 = sqr(_x0 - _x1) + sqr(_y0 - _y1); if (l2 == 0) return point_distance(_px, _py, _x0, _y0); @@ -11,7 +19,6 @@ function distance_to_line(_px, _py, _x0, _y0, _x1, _y1, log = false) { } function distance_to_line_infinite(px, py, x0, y0, x1, y1) { - INLINE return abs((x1 - x0) * (y0 - py) - (x0 - px) * (y1 - y0)) / sqrt(sqr(x1 - x0) + sqr(y1 - y0)); } diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index c5d5dc1bc..55e5b2d2b 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -43,7 +43,7 @@ LATEST_VERSION = 1_18_00_0; VERSION = 1_18_06_2; SAVE_VERSION = 1_18_05_0; - VERSION_STRING = MAC? "1.18.003m" : "1.18.7.009"; + VERSION_STRING = MAC? "1.18.003m" : "1.18.7.010"; BUILD_NUMBER = 118069; PREF_VERSION = 1_17_1; diff --git a/scripts/lerp_float/lerp_float.gml b/scripts/lerp_float/lerp_float.gml index 03e501d20..4c2052f42 100644 --- a/scripts/lerp_float/lerp_float.gml +++ b/scripts/lerp_float/lerp_float.gml @@ -34,4 +34,6 @@ function lerp_color(from, to, ratio) { return merge_color(from, to, ratio); } -function lerp_invert(val, from, to) { return (val - from) / (to - from); } \ No newline at end of file +function lerp_invert(val, from, to) { return (val - from) / (to - from); } + +function lerp_smooth(_x) { return _x * _x * (3.0 - 2.0 * _x) } \ No newline at end of file diff --git a/scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.gml b/scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.gml index caee0e7bf..be88a8e0c 100644 --- a/scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.gml +++ b/scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.gml @@ -51,7 +51,7 @@ function Node_3D_Mesh_Wall_Builder(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y if(_paths == noone) return noone; var points = array_create(_segment + 1); - var p = new __vec2(); + var p = new __vec2P(); for( var i = 0; i <= _segment; i++ ) { p = _paths.getPointRatio(i / _segment, 0, p); diff --git a/scripts/node_VFX_trail/node_VFX_trail.gml b/scripts/node_VFX_trail/node_VFX_trail.gml index adae0214e..76bda77f8 100644 --- a/scripts/node_VFX_trail/node_VFX_trail.gml +++ b/scripts/node_VFX_trail/node_VFX_trail.gml @@ -47,7 +47,7 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct static getAccuLength = function(index) { return array_safe_get_fast(lengthAcc, index, []); } static getPointRatio = function(_rat, _ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _p0, _p1; var _x, _y; diff --git a/scripts/node_armature_path/node_armature_path.gml b/scripts/node_armature_path/node_armature_path.gml index 66d2bb4d7..2622d8e05 100644 --- a/scripts/node_armature_path/node_armature_path.gml +++ b/scripts/node_armature_path/node_armature_path.gml @@ -55,7 +55,7 @@ function Node_Armature_Path(_x, _y, _group = noone) : Node(_x, _y, _group) const static getPointDistance = function(_dist, _ind = 0, out = undefined) { return getPointRatio(_dist / current_length, _ind, out); } static getPointRatio = function(_rat, _ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _p0 = lines[_ind][0]; var _p1 = lines[_ind][1]; diff --git a/scripts/node_blur_path/node_blur_path.gml b/scripts/node_blur_path/node_blur_path.gml index 8e856699c..e60710b40 100644 --- a/scripts/node_blur_path/node_blur_path.gml +++ b/scripts/node_blur_path/node_blur_path.gml @@ -73,7 +73,7 @@ function Node_Blur_Path(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var _dim = surface_get_dimension(_surf) var _points_x = array_create(_pntc); var _points_y = array_create(_pntc); - var _p = new __vec2(); + var _p = new __vec2P(); var _rst = _rang[0]; var _red = _rang[1]; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 7aa08c19d..34b1f9437 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -2376,10 +2376,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { return _tool.selecting == subtool; } + static getUsingToolName = function() { + var _tool = PANEL_PREVIEW.tool_current; + return _tool == noone? "" : _tool.getName(_tool.selecting); + } + static isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; } static getTool = function() { return self; } + static getToolSettings = function() { return tool_settings; } static setTool = function(tool) { diff --git a/scripts/node_fn_smoothstep/node_fn_smoothstep.gml b/scripts/node_fn_smoothstep/node_fn_smoothstep.gml index 697766fdc..fdc7e7b23 100644 --- a/scripts/node_fn_smoothstep/node_fn_smoothstep.gml +++ b/scripts/node_fn_smoothstep/node_fn_smoothstep.gml @@ -32,7 +32,7 @@ function Node_Fn_SmoothStep(_x, _y, _group = noone) : Node_Fn(_x, _y, _group) co return i / graph_res; } - static processData = function(_output, _data, _output_index, _array_index = 0) { #region + static processData = function(_output, _data, _output_index, _array_index = 0) { value = _data[inl + 0]; type = _data[inl + 1]; @@ -40,6 +40,6 @@ function Node_Fn_SmoothStep(_x, _y, _group = noone) : Node_Fn(_x, _y, _group) co text_display = val; return val; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_line/node_line.gml b/scripts/node_line/node_line.gml index 9417a1ddc..eb0dd96cd 100644 --- a/scripts/node_line/node_line.gml +++ b/scripts/node_line/node_line.gml @@ -259,7 +259,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons random_set_seed(_sed); var _sedIndex = 0; - var p = new __vec2(); + var p = new __vec2P(); var _pathData = []; var minx = 999999, miny = 999999, maxx = -999999, maxy = -999999; @@ -402,8 +402,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons // print($"_pp = {_pp}, total = {_total}"); p = _pat.getPointDistance(_pp, i, p); - if(struct_has(_pat, "getWeightDistance")) - wght = _pat.getWeightDistance(_pp, i); + wght = p[$ "weight"] ?? 1; } else { _prog_next = min(_prog_curr + _stepLen, 1); //Move forward _stepLen or _total (if less) stop at 1 @@ -412,8 +411,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var _pp = _clamp? clamp(_pathPng, 0, 1) : _pathPng p = _pat.getPointRatio(_pp, i, p); - if(struct_has(_pat, "getWeightRatio")) - wght = _pat.getWeightRatio(_pp, i); + wght = p[$ "weight"] ?? 1; } _nx = p.x; @@ -605,7 +603,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons if(!ds_map_exists(widthMap, widProg)) widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1); _nw *= widthMap[? widProg]; - _nw *= p0.weight; + _nw *= p0.weight / 2; _nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc)); diff --git a/scripts/node_liquefy/node_liquefy.gml b/scripts/node_liquefy/node_liquefy.gml index e25b368fb..786d2592b 100644 --- a/scripts/node_liquefy/node_liquefy.gml +++ b/scripts/node_liquefy/node_liquefy.gml @@ -265,7 +265,7 @@ function Node_Liquefy(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c if(_type == LIQUEFY_TYPE.push) { var _usePath = _path != noone; var _pthList = array_create(_pthR * 2); - var _p = new __vec2(); + var _p = new __vec2P(); if(_usePath) { for( var i = 0; i < _pthR; i++ ) { diff --git a/scripts/node_mesh_to_path/node_mesh_to_path.gml b/scripts/node_mesh_to_path/node_mesh_to_path.gml index e86545e90..1433b8397 100644 --- a/scripts/node_mesh_to_path/node_mesh_to_path.gml +++ b/scripts/node_mesh_to_path/node_mesh_to_path.gml @@ -44,7 +44,7 @@ function Node_Mesh_To_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constr l -= lengths[i]; } - return new __vec2(); + return new __vec2P(); } static update = function() { diff --git a/scripts/node_mesh_warp/node_mesh_warp.gml b/scripts/node_mesh_warp/node_mesh_warp.gml index c4e6eaed5..5859b10b4 100644 --- a/scripts/node_mesh_warp/node_mesh_warp.gml +++ b/scripts/node_mesh_warp/node_mesh_warp.gml @@ -417,8 +417,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) } if(isUsingTool("Edit control point")) { - if(key_mod_press(SHIFT)) draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16); - else draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16); + if(key_mod_press(SHIFT)) draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4); + else draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4); if(mouse_press(mb_left, active)) { if(_hover == -1) { @@ -438,7 +438,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) control(input_display_list); } } else if(isUsingTool("Pin mesh")) { - draw_sprite_ui_uniform(key_mod_press(SHIFT)? THEME.cursor_path_remove : THEME.cursor_path_add, 0, _mx + 16, _my + 16); + draw_sprite_ui_uniform(key_mod_press(SHIFT)? THEME.cursor_path_remove : THEME.cursor_path_add, 0, _mx + 4, _my + 4); draw_set_color(COLORS._main_accent); var rad = 16; diff --git a/scripts/node_path/node_path.gml b/scripts/node_path/node_path.gml index 3cc96abd0..39e9227cd 100644 --- a/scripts/node_path/node_path.gml +++ b/scripts/node_path/node_path.gml @@ -10,6 +10,12 @@ enum _ANCHOR { amount } +function __vec2P(_x = 0, _y = _x, _w = 1) : __vec2(_x, _y) constructor { + weight = _w; + + static clone = function() /*=>*/ {return new __vec2P(x, y, weight)}; +} + function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Path"; @@ -26,7 +32,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { newInput(3, nodeValue_Bool("Round anchor", self, false)) .rejectArray(); - + newOutput(0, nodeValue_Output("Position out", self, VALUE_TYPE.float, [ 0, 0 ])) .setDisplay(VALUE_DISPLAY.vector); @@ -48,8 +54,8 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { setDynamicInput(1, false); tool_pathDrawer = new NodeTool( "Draw path", THEME.path_tools_draw ) - .addSetting("Smoothness", VALUE_TYPE.float, function(val) { tool_pathDrawer.attribute.thres = val; }, "thres", 4) - .addSetting("Replace", VALUE_TYPE.boolean, function() { tool_pathDrawer.attribute.create = !tool_pathDrawer.attribute.create; }, "create", true); + .addSetting("Smoothness", VALUE_TYPE.float, function(val) /*=>*/ { tool_pathDrawer.attribute.thres = val; }, "thres", 4) + .addSetting("Replace", VALUE_TYPE.boolean, function( ) /*=>*/ { tool_pathDrawer.attribute.create = !tool_pathDrawer.attribute.create; }, "create", true); tools = [ new NodeTool( "Transform", THEME.path_tools_transform ), @@ -58,6 +64,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { tool_pathDrawer, new NodeTool( "Rectangle path", THEME.path_tools_rectangle ), new NodeTool( "Circle path", THEME.path_tools_circle ), + new NodeTool( "Weight edit", THEME.path_tools_weight_edit ), ]; #region ---- path ---- @@ -66,14 +73,19 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { segments = []; lengths = []; lengthAccs = []; + lengthRatio = []; lengthTotal = 0; + weightRatio = array_create(100 + 1); boundary = new BoundingBox(); - + cached_pos = ds_map_create(); + + attributes.weight = [ [ 0, 1 ], [ 100, 1 ] ]; #endregion #region ---- editor ---- - line_hover = -1; + line_hover = -1; + weight_hover = -1; drag_point = -1; drag_points = []; @@ -89,6 +101,12 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { transform_cx = 0; transform_cy = 0; transform_sx = 0; transform_sy = 0; transform_mx = 0; transform_my = 0; + + weight_drag = noone; + weight_drag_sx = 0; + weight_drag_sy = 0; + weight_drag_mx = 0; + weight_drag_my = 0; #endregion static resetDisplayList = function() { @@ -102,7 +120,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } } - static newAnchor = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0) { return [ _x, _y, _dxx, _dxy, _dyx, _dyy, false ]; } + static newAnchor = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0) { return [ _x, _y, _dxx, _dxy, _dyx, _dyy, 0 ]; } static createNewInput = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0, rec = true) { var index = array_length(inputs); @@ -130,14 +148,17 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var ansize = array_length(inputs) - input_fix_len; var edited = false; + var _tooln = getUsingToolName(); var pos = outputs[0].getValue(); var p/*:_ANCHOR*/; - draw_set_color(COLORS._main_accent); - draw_circle(_x + pos[0] * _s, _y + pos[1] * _s, 4, false); + if(_tooln == "") { + draw_set_color(COLORS._main_accent); + draw_circle(_x + pos[0] * _s, _y + pos[1] * _s, 4, false); + } - /////////////////////////////////////////////////////// EDIT /////////////////////////////////////////////////////// + //////////////////////////////////////////////////////// EDITING //////////////////////////////////////////////////////// if(transform_type > 0) { var _transform_minx = transform_minx; @@ -296,218 +317,240 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { var dx = value_snap(drag_point_sx + (_mx - drag_point_mx) / _s, _snx); var dy = value_snap(drag_point_sy + (_my - drag_point_my) / _s, _sny); - if(drag_type < 2) { // move points - var inp = inputs[input_fix_len + drag_point]; - var anc/*:_ANCHOR*/ = array_clone(inp.getValue()); - - if(drag_type != 0 && key_mod_press(SHIFT)) - anc[@_ANCHOR.ind] = !anc[_ANCHOR.ind]; - - if(drag_type == 0) { //drag anchor point - anc[@_ANCHOR.x] = dx; - anc[@_ANCHOR.y] = dy; - if(key_mod_press(CTRL)) { - anc[@_ANCHOR.x] = round(anc[_ANCHOR.x]); - anc[@_ANCHOR.y] = round(anc[_ANCHOR.y]); - } + switch(drag_type) { + case 0 : + case 1 : + case -1 : + var inp = inputs[input_fix_len + drag_point]; + var rnd = key_mod_press(CTRL); + var anc/*:_ANCHOR*/ = array_clone(inp.getValue()); - } else if(drag_type == 1) { //drag control 1 - anc[@_ANCHOR.c1x] = dx - anc[_ANCHOR.x]; - anc[@_ANCHOR.c1y] = dy - anc[_ANCHOR.y]; - - if(!anc[_ANCHOR.ind]) { - anc[@_ANCHOR.c2x] = -anc[_ANCHOR.c1x]; - anc[@_ANCHOR.c2y] = -anc[_ANCHOR.c1y]; - } - - if(key_mod_press(CTRL)) { - anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]); - anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]); + if(drag_type == 0) { //drag anchor point + anc[@_ANCHOR.x] = dx; + anc[@_ANCHOR.y] = dy; - if(!anc[_ANCHOR.ind]) { - anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]); - anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]); + if(rnd) { + anc[@_ANCHOR.x] = round(anc[_ANCHOR.x]); + anc[@_ANCHOR.y] = round(anc[_ANCHOR.y]); } - } - - } else if(drag_type == -1) { //drag control 2 - anc[@_ANCHOR.c2x] = dx - anc[_ANCHOR.x]; - anc[@_ANCHOR.c2y] = dy - anc[_ANCHOR.y]; - - if(!anc[_ANCHOR.ind]) { - anc[@_ANCHOR.c1x] = -anc[_ANCHOR.c2x]; - anc[@_ANCHOR.c1y] = -anc[_ANCHOR.c2y]; - } - - if(key_mod_press(CTRL)) { - anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]); - anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]); - if(!anc[_ANCHOR.ind]) { + } else if(drag_type == 1) { //drag control 1 + anc[@_ANCHOR.c1x] = dx - anc[_ANCHOR.x]; + anc[@_ANCHOR.c1y] = dy - anc[_ANCHOR.y]; + + if(anc[_ANCHOR.ind] == 0) { + anc[@_ANCHOR.c2x] = -anc[_ANCHOR.c1x]; + anc[@_ANCHOR.c2y] = -anc[_ANCHOR.c1y]; + + } else if(anc[_ANCHOR.ind] == 1) { + var _dir = point_direction(0, 0, anc[_ANCHOR.c1x], anc[_ANCHOR.c1y]); + var _dis = point_distance(0, 0, anc[_ANCHOR.c2x], anc[_ANCHOR.c2y]); + + anc[@_ANCHOR.c2x] = lengthdir_x(_dis, _dir + 180); + anc[@_ANCHOR.c2y] = lengthdir_y(_dis, _dir + 180); + } + + if(rnd) { anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]); anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]); - } - } - } - - if(inp.setValue(anc)) - edited = true; - - } else if(drag_type == 2) { // pen tools - var ox, oy, nx, ny; - var pxx = (_mx - _x) / _s; - var pxy = (_my - _y) / _s; - - draw_set_color(COLORS._main_accent); - for( var i = 0, n = array_length(drag_points); i < n; i++ ) { - var _p/*:_ANCHOR*/ = drag_points[i]; - nx = _x + _p[_ANCHOR.x] * _s; - ny = _y + _p[_ANCHOR.y] * _s; - - if(i) draw_line(ox, oy, nx, ny); - - ox = nx; - oy = ny; - } - - if(point_distance(drag_point_mx, drag_point_my, pxx, pxy) > 4 / _s) { - array_push(drag_points, [ pxx, pxy ]); - - drag_point_mx = pxx; - drag_point_my = pxy; - } - - if(mouse_release(mb_left)) { - var amo = array_length(drag_points); - var _p = 0; - var points = []; - var thres = tool_pathDrawer.attribute.thres; - var replace = tool_pathDrawer.attribute.create; - var asize = array_length(inputs) - input_fix_len; - - for( var i = 0; i < amo; i++ ) { - var pT = drag_points[i]; - - if(i == 0 || i == amo - 1) { - array_push(points, i); - continue; - } - - var maxT = 0; - var pF = drag_points[_p]; - - for( var j = _p; j < i; j++ ) { - var pP = drag_points[j]; - maxT = max(maxT, distance_to_line(pP[0], pP[1], pF[0], pF[1], pT[0], pT[1])); - } - - if(maxT >= thres) { - array_push(points, i); - _p = i; - } - } - - var amo = array_length(points); - if(!replace) amo = min(amo, asize); - - var i = 0; - var anc = []; - - for( i = 0; i < amo; i++ ) { - var ind = replace? i : clamp(i / amo * array_length(points), 0, array_length(points) - 1); - var _ind = points[ind]; - var _p = drag_points[_ind]; - var dxx = 0; - var dxy = 0; - var dyx = 0; - var dyy = 0; - - if(i > 0 && i < amo - 1) { - var _p0/*:_ANCHOR*/ = drag_points[points[i - 1]]; - var _p1/*:_ANCHOR*/ = drag_points[points[i + 1]]; - var d0 = point_direction(_p0[_ANCHOR.x], _p0[_ANCHOR.y], _p[_ANCHOR.x], _p[_ANCHOR.y]); - var d1 = point_direction( _p[_ANCHOR.x], _p[_ANCHOR.y], _p1[_ANCHOR.x], _p1[_ANCHOR.y]); - - var dd = d0 + angle_difference(d1, d0) / 2; - var ds0 = point_distance(_p0[_ANCHOR.x], _p0[_ANCHOR.y], _p[_ANCHOR.x], _p[_ANCHOR.y]); - var ds1 = point_distance( _p[_ANCHOR.x], _p[_ANCHOR.y], _p1[_ANCHOR.x], _p1[_ANCHOR.y]); - - dxx = lengthdir_x(ds0 / 3, dd + 180); - dxy = lengthdir_y(ds0 / 3, dd + 180); - dyx = lengthdir_x(ds1 / 3, dd); - dyy = lengthdir_y(ds1 / 3, dd); + if(anc[_ANCHOR.ind] < 2) { + anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]); + anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]); + } } - anc = [ _p[_ANCHOR.x], _p[_ANCHOR.y], dxx, dxy, dyx, dyy ]; - if(input_fix_len + i >= array_length(inputs)) - createNewInput(_p[_ANCHOR.x], _p[_ANCHOR.y], dxx, dxy, dyx, dyy); - else - inputs[input_fix_len + i].setValue(anc); - } - - if(!replace) { - for(; i < asize; i++ ) - inputs[input_fix_len + i].setValue(anc); - } - } - - } else if(drag_type == 3 || drag_type == 4) { // draw rectangle - var minx = min((_mx - _x) / _s, (drag_point_mx - _x) / _s); - var maxx = max((_mx - _x) / _s, (drag_point_mx - _x) / _s); - var miny = min((_my - _y) / _s, (drag_point_my - _y) / _s); - var maxy = max((_my - _y) / _s, (drag_point_my - _y) / _s); - - minx = value_snap(minx, _snx); - maxx = value_snap(maxx, _snx); - miny = value_snap(miny, _sny); - maxy = value_snap(maxy, _sny); - - if(key_mod_press(ALT)) { - var _ccx = (drag_point_mx - _x) / _s; - var _ccy = (drag_point_my - _y) / _s; - - var _ww = (maxx - minx) / 2; - var _hh = (maxy - miny) / 2; - - if(key_mod_press(SHIFT)) { - var _n = max(_ww, _hh); - _ww = _n; - _hh = _n; - } - - minx = _ccx - _ww; - maxx = _ccx + _ww; - - miny = _ccy - _hh; - maxy = _ccy + _hh; - - } else if(key_mod_press(SHIFT)) { - var _n = max(maxx - minx, maxy - miny); - maxx = minx + _n; - maxy = miny + _n; - } - - if(drag_type == 3) { - edited |= inputs[input_fix_len + 0].setValue(newAnchor(minx, miny)); - edited |= inputs[input_fix_len + 1].setValue(newAnchor(maxx, miny)); - edited |= inputs[input_fix_len + 2].setValue(newAnchor(maxx, maxy)); - edited |= inputs[input_fix_len + 3].setValue(newAnchor(minx, maxy)); - - } else if(drag_type == 4) { + } else if(drag_type == -1) { //drag control 2 + anc[@_ANCHOR.c2x] = dx - anc[_ANCHOR.x]; + anc[@_ANCHOR.c2y] = dy - anc[_ANCHOR.y]; - var _cnx = (maxx + minx) / 2; - var _cny = (maxy + miny) / 2; - var _ccx = (maxx - minx) * 0.27614; - var _ccy = (maxy - miny) * 0.27614; + if(anc[_ANCHOR.ind] == 0) { + anc[@_ANCHOR.c1x] = -anc[_ANCHOR.c2x]; + anc[@_ANCHOR.c1y] = -anc[_ANCHOR.c2y]; + + } else if(anc[_ANCHOR.ind] == 1) { + var _dir = point_direction(0, 0, anc[_ANCHOR.c2x], anc[_ANCHOR.c2y]); + var _dis = point_distance(0, 0, anc[_ANCHOR.c1x], anc[_ANCHOR.c1y]); + + anc[@_ANCHOR.c1x] = lengthdir_x(_dis, _dir + 180); + anc[@_ANCHOR.c1y] = lengthdir_y(_dis, _dir + 180); + } + + if(rnd) { + anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]); + anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]); + + if(anc[_ANCHOR.ind] < 2) { + anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]); + anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]); + } + } + } - edited |= inputs[input_fix_len + 0].setValue(newAnchor( _cnx, miny, -_ccx, 0, _ccx, 0)); - edited |= inputs[input_fix_len + 1].setValue(newAnchor( maxx, _cny, 0, -_ccy, 0, _ccy)); - edited |= inputs[input_fix_len + 2].setValue(newAnchor( _cnx, maxy, _ccx, 0, -_ccx, 0)); - edited |= inputs[input_fix_len + 3].setValue(newAnchor( minx, _cny, 0, _ccy, 0, -_ccy)); + if(inp.setValue(anc)) + edited = true; + break; - } - } + case 2 : + var ox, oy, nx, ny; + var pxx = (_mx - _x) / _s; + var pxy = (_my - _y) / _s; + + draw_set_color(COLORS._main_accent); + for( var i = 0, n = array_length(drag_points); i < n; i++ ) { + var _p/*:_ANCHOR*/ = drag_points[i]; + nx = _x + _p[_ANCHOR.x] * _s; + ny = _y + _p[_ANCHOR.y] * _s; + + if(i) draw_line(ox, oy, nx, ny); + + ox = nx; + oy = ny; + } + + if(point_distance(drag_point_mx, drag_point_my, pxx, pxy) > 4 / _s) { + array_push(drag_points, [ pxx, pxy ]); + + drag_point_mx = pxx; + drag_point_my = pxy; + } + + if(mouse_release(mb_left)) { + var amo = array_length(drag_points); + var _p = 0; + var points = []; + var thres = tool_pathDrawer.attribute.thres; + var replace = tool_pathDrawer.attribute.create; + var asize = array_length(inputs) - input_fix_len; + + for( var i = 0; i < amo; i++ ) { + var pT = drag_points[i]; + + if(i == 0 || i == amo - 1) { + array_push(points, i); + continue; + } + + var maxT = 0; + var pF = drag_points[_p]; + + for( var j = _p; j < i; j++ ) { + var pP = drag_points[j]; + maxT = max(maxT, distance_to_line(pP[0], pP[1], pF[0], pF[1], pT[0], pT[1])); + } + + if(maxT >= thres) { + array_push(points, i); + _p = i; + } + } + + var amo = array_length(points); + if(!replace) amo = min(amo, asize); + + var i = 0; + var anc = []; + + for( i = 0; i < amo; i++ ) { + var ind = replace? i : clamp(i / amo * array_length(points), 0, array_length(points) - 1); + var _ind = points[ind]; + var _p = drag_points[_ind]; + var dxx = 0; + var dxy = 0; + var dyx = 0; + var dyy = 0; + + if(i > 0 && i < amo - 1) { + var _p0/*:_ANCHOR*/ = drag_points[points[i - 1]]; + var _p1/*:_ANCHOR*/ = drag_points[points[i + 1]]; + + var d0 = point_direction(_p0[_ANCHOR.x], _p0[_ANCHOR.y], _p[_ANCHOR.x], _p[_ANCHOR.y]); + var d1 = point_direction( _p[_ANCHOR.x], _p[_ANCHOR.y], _p1[_ANCHOR.x], _p1[_ANCHOR.y]); + + var dd = d0 + angle_difference(d1, d0) / 2; + var ds0 = point_distance(_p0[_ANCHOR.x], _p0[_ANCHOR.y], _p[_ANCHOR.x], _p[_ANCHOR.y]); + var ds1 = point_distance( _p[_ANCHOR.x], _p[_ANCHOR.y], _p1[_ANCHOR.x], _p1[_ANCHOR.y]); + + dxx = lengthdir_x(ds0 / 3, dd + 180); + dxy = lengthdir_y(ds0 / 3, dd + 180); + dyx = lengthdir_x(ds1 / 3, dd); + dyy = lengthdir_y(ds1 / 3, dd); + } + + anc = [ _p[_ANCHOR.x], _p[_ANCHOR.y], dxx, dxy, dyx, dyy ]; + if(input_fix_len + i >= array_length(inputs)) + createNewInput(_p[_ANCHOR.x], _p[_ANCHOR.y], dxx, dxy, dyx, dyy); + else + inputs[input_fix_len + i].setValue(anc); + } + + if(!replace) { + for(; i < asize; i++ ) + inputs[input_fix_len + i].setValue(anc); + } + } + + break; + + case 3 : + case 4 : + var minx = min((_mx - _x) / _s, (drag_point_mx - _x) / _s); + var maxx = max((_mx - _x) / _s, (drag_point_mx - _x) / _s); + var miny = min((_my - _y) / _s, (drag_point_my - _y) / _s); + var maxy = max((_my - _y) / _s, (drag_point_my - _y) / _s); + + minx = value_snap(minx, _snx); + maxx = value_snap(maxx, _snx); + miny = value_snap(miny, _sny); + maxy = value_snap(maxy, _sny); + + if(key_mod_press(ALT)) { + var _ccx = (drag_point_mx - _x) / _s; + var _ccy = (drag_point_my - _y) / _s; + + var _ww = (maxx - minx) / 2; + var _hh = (maxy - miny) / 2; + + if(key_mod_press(SHIFT)) { + var _n = max(_ww, _hh); + _ww = _n; + _hh = _n; + } + + minx = _ccx - _ww; + maxx = _ccx + _ww; + + miny = _ccy - _hh; + maxy = _ccy + _hh; + + } else if(key_mod_press(SHIFT)) { + var _n = max(maxx - minx, maxy - miny); + maxx = minx + _n; + maxy = miny + _n; + } + + if(drag_type == 3) { + edited |= inputs[input_fix_len + 0].setValue(newAnchor(minx, miny)); + edited |= inputs[input_fix_len + 1].setValue(newAnchor(maxx, miny)); + edited |= inputs[input_fix_len + 2].setValue(newAnchor(maxx, maxy)); + edited |= inputs[input_fix_len + 3].setValue(newAnchor(minx, maxy)); + + } else if(drag_type == 4) { + + var _cnx = (maxx + minx) / 2; + var _cny = (maxy + miny) / 2; + var _ccx = (maxx - minx) * 0.27614; + var _ccy = (maxy - miny) * 0.27614; + + edited |= inputs[input_fix_len + 0].setValue(newAnchor( _cnx, miny, -_ccx, 0, _ccx, 0)); + edited |= inputs[input_fix_len + 1].setValue(newAnchor( maxx, _cny, 0, -_ccy, 0, _ccy)); + edited |= inputs[input_fix_len + 2].setValue(newAnchor( _cnx, maxy, _ccx, 0, -_ccx, 0)); + edited |= inputs[input_fix_len + 3].setValue(newAnchor( minx, _cny, 0, _ccy, 0, -_ccy)); + + } + break; + + } if(edited) UNDO_HOLDING = true; @@ -516,11 +559,33 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { RENDER_ALL UNDO_HOLDING = false; } + + } else if(weight_drag != noone) { + + var _mmx = weight_drag_sx + (_mx - weight_drag_mx); + var _mmy = weight_drag_sy + (_my - weight_drag_my); + + var _dis = point_distance(weight_drag_sx, weight_drag_sy, _mmx, _mmy) / _s; + attributes.weight[weight_drag][1] = _dis; + + updateLength(); + + if(mouse_release(mb_left)) { + weight_drag = noone; + triggerRender(); + UNDO_HOLDING = false; + } + } /////////////////////////////////////////////////////// DRAW PATH /////////////////////////////////////////////////////// - var _line_hover = -1; + var _line_hover = -1; + var _weight_hover = -1; + var _closet_dist = undefined; + var _point_hover = noone; + var _point_ratio = 0; + var anchor_hover = -1; var hover_type = 0; @@ -530,7 +595,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { var minx = 99999, miny = 99999; var maxx = -99999, maxy = -99999; - if(isUsingTool(4) || isUsingTool(5)) { + if(_tooln == "Rectangle path" || _tooln == "Circle path") { draw_set_color(COLORS._main_icon); if(drag_point > -1) { @@ -587,245 +652,399 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } if(!array_empty(anchors)) { - draw_set_color(isUsingTool(0)? COLORS._main_icon : COLORS._main_accent); + draw_set_color(_tooln == "Transform"? COLORS._main_icon : COLORS._main_accent); + + var _ox = 0, _oy = 0, _ow = 0; + var _nx = 0, _ny = 0, _nw = 0; + + var _ow1x = 0, _ow1y = 0, _ow2x = 0, _ow2y = 0; + var _nw1x = 0, _nw1y = 0, _nw2x = 0, _nw2y = 0; for( var i = 0, n = array_length(segments); i < n; i++ ) { // draw path var _seg = segments[i]; - var _ox = 0, _oy = 0, _nx = 0, _ny = 0, p = 0; - - for( var j = 0, m = array_length(_seg); j < m; j += 2 ) { + var p = 0; + + var _amo = array_length(_seg); + var _rat_s = lengthRatio[i]; + var _rat_e = lengthRatio[i + 1]; + var _wdir = point_direction(_seg[0], _seg[1], _seg[2], _seg[3]); + + for( var j = 0; j < _amo; j += 2 ) { _nx = _x + _seg[j + 0] * _s; _ny = _y + _seg[j + 1] * _s; - + minx = min(minx, _nx); maxx = max(maxx, _nx); miny = min(miny, _ny); maxy = max(maxy, _ny); + var _rat = round(lerp(_rat_s, _rat_e, j / _amo) * 100); + _nw = weightRatio[clamp(_rat, 0, array_length(weightRatio) - 1)]; + + if(_tooln == "Weight edit") { + if(j) _wdir = point_direction(_ox, _oy, _nx, _ny); + _nw1x = _nx + lengthdir_x(_nw, _wdir + 90); + _nw1y = _ny + lengthdir_y(_nw, _wdir + 90); + _nw2x = _nx + lengthdir_x(_nw, _wdir - 90); + _nw2y = _ny + lengthdir_y(_nw, _wdir - 90); + + if(i == 0 && j == 0) { + draw_set_color(COLORS._main_icon); + draw_line(_nx, _ny, _nw1x, _nw1y); + draw_line(_nx, _ny, _nw2x, _nw2y); + } + } + if(j) { - if(hover && (key_mod_press(CTRL) || isUsingTool(1)) && distance_to_line(_mx, _my, _ox, _oy, _nx, _ny) < 4) - _line_hover = i; - draw_line_width(_ox, _oy, _nx, _ny, 1 + 2 * (line_hover == i)); + if(hover) { + var _p = point_to_line(_mx, _my, _ox, _oy, _nx, _ny); + var _d = point_distance(_mx, _my, _p[0], _p[1]); + + if(_d < 16 && (_closet_dist == undefined || _d < _closet_dist)) { + _closet_dist = _d; + _point_hover = _p; + _point_ratio = _rat; + } + + if(_d < 4) _line_hover = i; + } + + if(_tooln == "Weight edit") { + draw_set_color(COLORS._main_accent); + draw_line(_ox, _oy, _nx, _ny); + + draw_set_color(COLORS._main_icon); + draw_line(_ow1x, _ow1y, _nw1x, _nw1y); + draw_line(_ow2x, _ow2y, _nw2x, _nw2y); + + if(i == n - 1 && j + 2 >= _amo) { + draw_set_color(COLORS._main_icon); + draw_line(_nx, _ny, _nw1x, _nw1y); + draw_line(_nx, _ny, _nw2x, _nw2y); + } + + } else + draw_line_width(_ox, _oy, _nx, _ny, 1 + (line_hover == i)); } _ox = _nx; _oy = _ny; + + _ow = _nw; + _ow1x = _nw1x; + _ow1y = _nw1y; + _ow2x = _nw2x; + _ow2y = _nw2y; } } - #region draw anchor - if(hover != -1 && !isUsingTool(0)) - for(var i = 0; i < ansize; i++) { - var _a = anchors[i]; - var xx = _x + _a[0] * _s; - var yy = _y + _a[1] * _s; - var cont = false; - var _ax0 = 0, _ay0 = 0; - var _ax1 = 0, _ay1 = 0; + var _showAnchor = hover != -1; + switch(_tooln) { + case "Transform" : + case "Weight edit" : + _showAnchor = false; + break; + } - if(array_length(_a) < 6) continue; - - if(_a[2] != 0 || _a[3] != 0 || _a[4] != 0 || _a[5] != 0) { - _ax0 = _x + (_a[0] + _a[2]) * _s; - _ay0 = _y + (_a[1] + _a[3]) * _s; - _ax1 = _x + (_a[0] + _a[4]) * _s; - _ay1 = _y + (_a[1] + _a[5]) * _s; - cont = true; - - draw_set_color(COLORS.node_path_overlay_control_line); - draw_line(_ax0, _ay0, xx, yy); - draw_line(_ax1, _ay1, xx, yy); + if(_showAnchor) + for(var i = 0; i < ansize; i++) { // draw anchor + var _a = anchors[i]; + var xx = _x + _a[0] * _s; + var yy = _y + _a[1] * _s; + var cont = false; + var _ax0 = 0, _ay0 = 0; + var _ax1 = 0, _ay1 = 0; + + if(array_length(_a) < 6) continue; - draw_sprite_colored(THEME.anchor_selector, 2, _ax0, _ay0); - draw_sprite_colored(THEME.anchor_selector, 2, _ax1, _ay1); + if(_a[2] != 0 || _a[3] != 0 || _a[4] != 0 || _a[5] != 0) { + _ax0 = _x + (_a[0] + _a[2]) * _s; + _ay0 = _y + (_a[1] + _a[3]) * _s; + _ax1 = _x + (_a[0] + _a[4]) * _s; + _ay1 = _y + (_a[1] + _a[5]) * _s; + cont = true; + + draw_set_color(COLORS.node_path_overlay_control_line); + draw_line(_ax0, _ay0, xx, yy); + draw_line(_ax1, _ay1, xx, yy); + + draw_sprite_colored(THEME.anchor_selector, 2, _ax0, _ay0); + draw_sprite_colored(THEME.anchor_selector, 2, _ax1, _ay1); + } + + draw_sprite_colored(THEME.anchor_selector, 0, xx, yy); + draw_set_text(f_p1, fa_left, fa_bottom, COLORS._main_accent); + draw_text(xx + ui(4), yy - ui(4), inputs[input_fix_len + i].name); + + if(drag_point == i) { + draw_sprite_colored(THEME.anchor_selector, 1, xx, yy); + + } else if(hover && point_in_circle(_mx, _my, xx, yy, 8)) { + draw_sprite_colored(THEME.anchor_selector, 1, xx, yy); + anchor_hover = i; + hover_type = 0; + + } else if(cont && hover && point_in_circle(_mx, _my, _ax0, _ay0, 8)) { + draw_sprite_colored(THEME.anchor_selector, 0, _ax0, _ay0); + anchor_hover = i; + hover_type = 1; + + } else if(cont && hover && point_in_circle(_mx, _my, _ax1, _ay1, 8)) { + draw_sprite_colored(THEME.anchor_selector, 0, _ax1, _ay1); + anchor_hover = i; + hover_type = -1; + } + } + + if(_tooln == "Weight edit") { + var _w = attributes.weight; + var _wd = 12; + + for( var i = 0, n = array_length(_w); i < n; i++ ) { + var _wg = _w[i]; + var _wrat = _wg[0]; + var _wp = getPointDistance(_wrat / 100 * lengthTotal); + + var _wx = _x + _wp.x * _s; + var _wy = _y + _wp.y * _s; + var _pd = point_distance(_mx, _my, _wx, _wy); + + if(_pd < _wd) { + _weight_hover = i; + _wd = _pd; } - draw_sprite_colored(THEME.anchor_selector, 0, xx, yy); - draw_set_text(f_p1, fa_left, fa_bottom, COLORS._main_accent); - draw_text(xx + ui(4), yy - ui(4), inputs[input_fix_len + i].name); - - if(drag_point == i) { - draw_sprite_colored(THEME.anchor_selector, 1, xx, yy); - - } else if(hover && point_in_circle(_mx, _my, xx, yy, 8)) { - draw_sprite_colored(THEME.anchor_selector, 1, xx, yy); - anchor_hover = i; - hover_type = 0; - - } else if(cont && hover && point_in_circle(_mx, _my, _ax0, _ay0, 8)) { - draw_sprite_colored(THEME.anchor_selector, 0, _ax0, _ay0); - anchor_hover = i; - hover_type = 1; - - } else if(cont && hover && point_in_circle(_mx, _my, _ax1, _ay1, 8)) { - draw_sprite_colored(THEME.anchor_selector, 0, _ax1, _ay1); - anchor_hover = i; - hover_type = -1; - } + var _sel = weight_hover == i || weight_drag == i; + draw_set_color(_sel? COLORS._main_accent : COLORS._main_icon_light); + draw_circle(_wx, _wy, _sel? 5 : 3, false); + } - #endregion + } } if(hover == -1) return false; - line_hover = _line_hover; + line_hover = _line_hover; + weight_hover = _weight_hover; /////////////////////////////////////////////////////// TOOLS /////////////////////////////////////////////////////// - if(isUsingTool(0)) { // transform tools - var hov = 0; - if(hover && point_in_circle(_mx, _my, minx, miny, 8)) hov = 1; - else if(hover && point_in_circle(_mx, _my, maxx, miny, 8)) hov = 2; - else if(hover && point_in_circle(_mx, _my, minx, maxy, 8)) hov = 3; - else if(hover && point_in_circle(_mx, _my, maxx, maxy, 8)) hov = 4; - else if(hover && point_in_rectangle(_mx, _my, minx, miny, maxx, maxy)) hov = 5; - - draw_set_color(COLORS._main_accent); - draw_rectangle_border(minx, miny, maxx, maxy, 1 + (hov == 5)); - - draw_sprite_colored(THEME.anchor_selector, hov == 1, minx, miny); - draw_sprite_colored(THEME.anchor_selector, hov == 2, maxx, miny); - draw_sprite_colored(THEME.anchor_selector, hov == 3, minx, maxy); - draw_sprite_colored(THEME.anchor_selector, hov == 4, maxx, maxy); - - if(hov && mouse_press(mb_left, active)) { - transform_type = hov; - transform_minx = (minx - _x) / _s; transform_maxx = (maxx - _x) / _s; - transform_miny = (miny - _y) / _s; transform_maxy = (maxy - _y) / _s; - transform_mx = _mx; transform_my = _my; - transform_sx = _mx; transform_sy = _my; + switch(_tooln) { + case "Transform" : + var hov = 0; + if(hover && point_in_circle(_mx, _my, minx, miny, 8)) hov = 1; + else if(hover && point_in_circle(_mx, _my, maxx, miny, 8)) hov = 2; + else if(hover && point_in_circle(_mx, _my, minx, maxy, 8)) hov = 3; + else if(hover && point_in_circle(_mx, _my, maxx, maxy, 8)) hov = 4; + else if(hover && point_in_rectangle(_mx, _my, minx, miny, maxx, maxy)) hov = 5; - transform_cx = (transform_minx + transform_maxx) / 2; - transform_cy = (transform_miny + transform_maxy) / 2; - } - - } else if(isUsingTool(3)) { //pen tools - draw_sprite_ui_uniform(THEME.path_tools_draw, 0, _mx + 16, _my + 16); + draw_set_color(COLORS._main_accent); + draw_rectangle_border(minx, miny, maxx, maxy, 1 + (hov == 5)); + + draw_sprite_colored(THEME.anchor_selector, hov == 1, minx, miny); + draw_sprite_colored(THEME.anchor_selector, hov == 2, maxx, miny); + draw_sprite_colored(THEME.anchor_selector, hov == 3, minx, maxy); + draw_sprite_colored(THEME.anchor_selector, hov == 4, maxx, maxy); + + if(hov && mouse_press(mb_left, active)) { + transform_type = hov; + transform_minx = (minx - _x) / _s; transform_maxx = (maxx - _x) / _s; + transform_miny = (miny - _y) / _s; transform_maxy = (maxy - _y) / _s; + transform_mx = _mx; transform_my = _my; + transform_sx = _mx; transform_sy = _my; + + transform_cx = (transform_minx + transform_maxx) / 2; + transform_cy = (transform_miny + transform_maxy) / 2; + } + break; + + case "Anchor add / remove" : + draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4); + + if(mouse_press(mb_left, active)) { + var ind = array_length(inputs); + var anc = createNewInput(value_snap((_mx - _x) / _s, _snx), value_snap((_my - _y) / _s, _sny), 0, 0, 0, 0, false); + + if(_line_hover == -1) { + drag_point = array_length(inputs) - input_fix_len - 1; + } else { + array_remove(inputs, anc); + array_insert(inputs, input_fix_len + _line_hover + 1, anc); + drag_point = _line_hover + 1; + ind = input_fix_len + _line_hover + 1; + } + + recordAction(ACTION_TYPE.array_insert, inputs, [ inputs[ind], ind, $"add path anchor point {ind}" ]); + resetDisplayList(); + UNDO_HOLDING = true; + + drag_type = -1; + drag_point_mx = _mx; + drag_point_my = _my; + drag_point_sx = (_mx - _x) / _s; + drag_point_sy = (_my - _y) / _s; + + RENDER_ALL + } + break; - if(mouse_press(mb_left, active)) { - var replace = tool_pathDrawer.attribute.create; - if(replace) { + case "Draw path" : + draw_sprite_ui_uniform(THEME.path_tools_draw, 0, _mx + 16, _my + 16); + + if(mouse_press(mb_left, active)) { + var replace = tool_pathDrawer.attribute.create; + if(replace) { + while(array_length(inputs) > input_fix_len) + array_delete(inputs, input_fix_len, 1); + resetDisplayList(); + } + + drag_point = 0; + drag_type = 2; + drag_points = [ [ (_mx - _x) / _s, (_my - _y) / _s ] ]; + drag_point_mx = (_mx - _x) / _s; + drag_point_my = (_my - _y) / _s; + } + break; + + case "Rectangle path" : + case "Circle path" : + draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4); + + if(mouse_press(mb_left, active)) { while(array_length(inputs) > input_fix_len) array_delete(inputs, input_fix_len, 1); resetDisplayList(); + + drag_point = 0; + drag_type = isUsingTool(4)? 3 : 4; + drag_point_mx = _mx; + drag_point_my = _my; + inputs[1].setValue(true); + + repeat(4) + createNewInput(value_snap((_mx - _x) / _s, _snx), value_snap((_my - _y) / _s, _sny)); } + break; - drag_point = 0; - drag_type = 2; - drag_points = [ [ (_mx - _x) / _s, (_my - _y) / _s ] ]; - drag_point_mx = (_mx - _x) / _s; - drag_point_my = (_my - _y) / _s; - } - - } else if(isUsingTool(4) || isUsingTool(5)) { // shape tools - draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16); - - if(mouse_press(mb_left, active)) { - while(array_length(inputs) > input_fix_len) - array_delete(inputs, input_fix_len, 1); - resetDisplayList(); - - drag_point = 0; - drag_type = isUsingTool(4)? 3 : 4; - drag_point_mx = _mx; - drag_point_my = _my; - inputs[1].setValue(true); - - repeat(4) - createNewInput(value_snap((_mx - _x) / _s, _snx), value_snap((_my - _y) / _s, _sny)); - } - - } else if(anchor_hover != -1) { // no tool, dragging existing point - var _a/*:_ANCHOR*/ = array_clone(getInputData(input_fix_len + anchor_hover)); - if(isUsingTool(2) && hover_type == 0) { - draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 16, _my + 16); - - if(mouse_press(mb_left, active)) { - if(_a[_ANCHOR.c1x] != 0 || _a[_ANCHOR.c1y] != 0 || _a[_ANCHOR.c2x] != 0 || _a[_ANCHOR.c2y] != 0) { - _a[@_ANCHOR.c1x] = 0; - _a[@_ANCHOR.c1y] = 0; - _a[@_ANCHOR.c2x] = 0; - _a[@_ANCHOR.c2y] = 0; - _a[@_ANCHOR.ind] = false; - inputs[input_fix_len + anchor_hover].setValue(_a); - } else { - _a[@_ANCHOR.c1x] = -8; - _a[@_ANCHOR.c1y] = 0; - _a[@_ANCHOR.c2x] = 8; - _a[@_ANCHOR.c2y] = 0; - _a[@_ANCHOR.ind] = false; + case "Weight edit" : + if(_point_hover != noone) { + + if(_weight_hover == -1) { + draw_set_color(COLORS._main_accent); + draw_circle(_point_hover[0], _point_hover[1], 4, false); + } else if(_weight_hover != -1 && key_mod_press(SHIFT)) { + draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4); + + if(mouse_press(mb_left, active)) { + if(_weight_hover == 0 || _weight_hover == array_length(attributes.weight) - 1) + attributes.weight[_weight_hover][0] = 1; + else + array_delete(attributes.weight, _weight_hover, 1); + triggerRender(); + } + break; + } + + if(mouse_press(mb_left, active)) { + if(array_empty(attributes.weight)) attributes.weight = [ [ 0, 1 ], [ 100, 1 ] ]; + var _w = attributes.weight; + + if(_weight_hover != -1) { + weight_drag = _weight_hover; + } else { + for( var i = 0, n = array_length(_w) - 1; i < n; i++ ) { + if(_point_ratio > _w[i + 1][0]) continue; + + array_insert(_w, i + 1, [ _point_ratio, 1 ]); + weight_drag = i + 1; + break; + } + } + + weight_drag_sx = _point_hover[0]; + weight_drag_sy = _point_hover[1]; + weight_drag_mx = _mx; + weight_drag_my = _my; + + } + } + break; + + default : + if(anchor_hover == -1) break; + + var _a/*:_ANCHOR*/ = array_clone(getInputData(input_fix_len + anchor_hover)); + + if(_tooln == "Edit Control point" && hover_type == 0) { // add / remove anchor point + draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 4, _my + 4); + + if(mouse_press(mb_left, active)) { + if(_a[_ANCHOR.c1x] != 0 || _a[_ANCHOR.c1y] != 0 || _a[_ANCHOR.c2x] != 0 || _a[_ANCHOR.c2y] != 0) { + _a[@_ANCHOR.c1x] = 0; + _a[@_ANCHOR.c1y] = 0; + _a[@_ANCHOR.c2x] = 0; + _a[@_ANCHOR.c2y] = 0; + _a[@_ANCHOR.ind] = 0; + inputs[input_fix_len + anchor_hover].setValue(_a); + + } else { + _a[@_ANCHOR.c1x] = -8; + _a[@_ANCHOR.c1y] = 0; + _a[@_ANCHOR.c2x] = 8; + _a[@_ANCHOR.c2y] = 0; + _a[@_ANCHOR.ind] = 0; + + drag_point = anchor_hover; + drag_type = 1; + drag_point_mx = _mx; + drag_point_my = _my; + drag_point_sx = _a[_ANCHOR.x]; + drag_point_sy = _a[_ANCHOR.y]; + } + } + + } else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove + draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4); + + if(mouse_press(mb_left, active)) { + var _indx = input_fix_len + anchor_hover; + recordAction(ACTION_TYPE.array_delete, inputs, [ inputs[_indx], _indx, "remove path anchor point" ]); + + array_delete(inputs, _indx, 1); + resetDisplayList(); + doUpdate(); + } + + } else { + var _spr = THEME.cursor_path_move; + if(_tooln == "Edit Control point") + _spr = key_mod_press(SHIFT)? THEME.cursor_path_anchor_detach : THEME.cursor_path_anchor_unmirror; + + draw_sprite_ui_uniform(_spr, 0, _mx + 4, _my + 4); + + if(mouse_press(mb_left, active)) { + if(_tooln == "Edit Control point") { + _a[@_ANCHOR.ind] = key_mod_press(SHIFT)? 2 : 1; + inputs[input_fix_len + anchor_hover].setValue(_a); + } + drag_point = anchor_hover; - drag_type = 1; + drag_type = hover_type; drag_point_mx = _mx; drag_point_my = _my; drag_point_sx = _a[_ANCHOR.x]; drag_point_sy = _a[_ANCHOR.y]; + + if(hover_type == 1) { + drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c1x]; + drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c1y]; + + } else if(hover_type == -1) { + drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c2x]; + drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c2y]; + } } } - } else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove - draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16); - - if(mouse_press(mb_left, active)) { - var _indx = input_fix_len + anchor_hover; - recordAction(ACTION_TYPE.array_delete, inputs, [ inputs[_indx], _indx, "remove path anchor point" ]); - - array_delete(inputs, _indx, 1); - resetDisplayList(); - doUpdate(); - } - } else { - draw_sprite_ui_uniform(THEME.cursor_path_move, 0, _mx + 16, _my + 16); - - if(mouse_press(mb_left, active)) { - if(isUsingTool(2)) { - _a[@_ANCHOR.ind] = true; - inputs[input_fix_len + anchor_hover].setValue(_a); - } - - drag_point = anchor_hover; - drag_type = hover_type; - drag_point_mx = _mx; - drag_point_my = _my; - drag_point_sx = _a[_ANCHOR.x]; - drag_point_sy = _a[_ANCHOR.y]; - - if(hover_type == 1) { - drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c1x]; - drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c1y]; - - } else if(hover_type == -1) { - drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c2x]; - drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c2y]; - } - } - } - - } else if(key_mod_press(CTRL) || isUsingTool(1)) { // anchor edit - draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16); - - if(mouse_press(mb_left, active)) { - var ind = array_length(inputs); - var anc = createNewInput(value_snap((_mx - _x) / _s, _snx), value_snap((_my - _y) / _s, _sny), 0, 0, 0, 0, false); - - if(_line_hover == -1) { - drag_point = array_length(inputs) - input_fix_len - 1; - } else { - array_remove(inputs, anc); - array_insert(inputs, input_fix_len + _line_hover + 1, anc); - drag_point = _line_hover + 1; - ind = input_fix_len + _line_hover + 1; - } - - recordAction(ACTION_TYPE.array_insert, inputs, [ inputs[ind], ind, $"add path anchor point {ind}" ]); - resetDisplayList(); - UNDO_HOLDING = true; - - drag_type = -1; - drag_point_mx = _mx; - drag_point_my = _my; - drag_point_sx = (_mx - _x) / _s; - drag_point_sy = (_my - _y) / _s; - - RENDER_ALL - } + break; } return true; @@ -879,6 +1098,34 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { lengthAccs[i] = lengthTotal; } + lengthRatio = array_create(ansize + 1); + lengthRatio[0] = 0; + for( var i = 0; i < con; i++ ) + lengthRatio[i + 1] = lengthAccs[i] / lengthTotal; + + var _w = attributes.weight; + + if(array_empty(_w)) weightRatio = array_map(weightRatio, function(i) /*=>*/ {return 1}); + else if(array_length(_w) == 1) weightRatio = array_map(weightRatio, function(i) /*=>*/ {return attributes.weight[0][1]}); + else { + var _wi = 0; + var _wamo = array_length(_w); + var _amo = 100; + + var _wf = _w[_wi + 0]; + var _wt = _w[_wi + 1]; + + for( var i = 0; i <= _amo; i++ ) { + if(i < _amo && i == _wt[0]) { + _wi++; + _wf = _w[_wi + 0]; + _wt = _w[_wi + 1]; + } + + weightRatio[i] = lerp(_wf[1], _wt[1], lerp_smooth((i - _wf[0]) / (_wt[0] - _wf[0]))); + } + } + // Surface generate var pad = min(8, abs(boundary.maxx - boundary.minx) * 0.1, abs(boundary.maxy - boundary.miny) * 0.1); @@ -935,15 +1182,17 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { static getAccuLength = function() { return lengthAccs; } static getPointDistance = function(_dist, _ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } if(array_empty(lengths)) return out; - var _cKey = _dist; + out.weight = 1; + var _cKey = _dist; if(ds_map_exists(cached_pos, _cKey)) { var _cachep = cached_pos[? _cKey]; out.x = _cachep.x; out.y = _cachep.y; + out.weight = _cachep.weight; return out; } @@ -965,17 +1214,22 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { continue; } - var _t = _l == 0? 0 : _dist / _l; + var _t = _l == 0? 0 : _dist / _l; + var _rat = lerp(lengthRatio[i], lengthRatio[i + 1], _t) * 100; + var _nw = array_get_decimal(weightRatio, _rat); if(_a0[4] == 0 && _a0[5] == 0 && _a1[2] == 0 && _a1[3] == 0) { out.x = lerp(_a0[0], _a1[0], _t); out.y = lerp(_a0[1], _a1[1], _t); + } else { out.x = eval_bezier_x(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]); out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]); } - cached_pos[? _cKey] = out.clone(); + out.weight = _nw; + + cached_pos[? _cKey] = new __vec2P(out.x, out.y, _nw); return out; } @@ -988,19 +1242,19 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } static getPointSegment = function(_rat) { - if(array_empty(lengths)) return new __vec2(); + if(array_empty(lengths)) return new __vec2P(); var loop = getInputData(1); var ansize = array_length(inputs) - input_fix_len; - if(_rat < 0) return new __vec2(anchors[0][0], anchors[0][1]); + if(_rat < 0) return new __vec2P(anchors[0][0], anchors[0][1]); _rat = safe_mod(_rat, ansize); var _i0 = clamp(floor(_rat), 0, ansize - 1); var _i1 = (_i0 + 1) % ansize; var _t = frac(_rat); - if(_i1 >= ansize && !loop) return new __vec2(anchors[ansize - 1][0], anchors[ansize - 1][1]); + if(_i1 >= ansize && !loop) return new __vec2P(anchors[ansize - 1][0], anchors[ansize - 1][1]); var _a0 = anchors[_i0]; var _a1 = anchors[_i1]; @@ -1014,7 +1268,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { py = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]); } - return new __vec2(px, py); + return new __vec2P(px, py); } static update = function(frame = CURRENT_FRAME) { diff --git a/scripts/node_path_3d/node_path_3d.gml b/scripts/node_path_3d/node_path_3d.gml index 9863a805b..291458390 100644 --- a/scripts/node_path_3d/node_path_3d.gml +++ b/scripts/node_path_3d/node_path_3d.gml @@ -353,7 +353,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor if(anchor_hover != -1) { // no tool, dragging existing point var _a = array_clone(getInputData(input_fix_len + anchor_hover)); if(isUsingTool(2) && hover_type == 0) { - draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 16, _my + 16); + draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 4, _my + 4); if(mouse_press(mb_left, active)) { @@ -387,7 +387,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } } } else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove - draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16); + draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4); if(mouse_press(mb_left, active)) { var _indx = input_fix_len + anchor_hover; @@ -398,7 +398,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor doUpdate(); } } else { - draw_sprite_ui_uniform(THEME.cursor_path_move, 0, _mx + 16, _my + 16); + draw_sprite_ui_uniform(THEME.cursor_path_move, 0, _mx + 4, _my + 4); if(mouse_press(mb_left, active)) { if(isUsingTool(2)) { @@ -436,7 +436,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } } else if(key_mod_press(CTRL) || isUsingTool(1)) { // anchor edit - draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16); + draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4); if(mouse_press(mb_left, active)) { diff --git a/scripts/node_path_array/node_path_array.gml b/scripts/node_path_array/node_path_array.gml index a3f6df256..a13e7d600 100644 --- a/scripts/node_path_array/node_path_array.gml +++ b/scripts/node_path_array/node_path_array.gml @@ -69,7 +69,7 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc ind -= lc; } - return new __vec2(); + return new __vec2P(); } static getPointDistance = function(_dist, ind = 0) { @@ -81,7 +81,7 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc ind -= lc; } - return new __vec2(); + return new __vec2P(); } static getBoundary = function(ind = 0) { diff --git a/scripts/node_path_bake/node_path_bake.gml b/scripts/node_path_bake/node_path_bake.gml index ea758d100..b10230558 100644 --- a/scripts/node_path_bake/node_path_bake.gml +++ b/scripts/node_path_bake/node_path_bake.gml @@ -55,7 +55,7 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct path_amount = _amo; var _segs = array_create(_amo); - var _p = new __vec2(); + var _p = new __vec2P(); for( var i = 0; i < _amo; i++ ) { var _len = _path.getLength(i); diff --git a/scripts/node_path_blend/node_path_blend.gml b/scripts/node_path_blend/node_path_blend.gml index 2a1413324..89f31fcbd 100644 --- a/scripts/node_path_blend/node_path_blend.gml +++ b/scripts/node_path_blend/node_path_blend.gml @@ -19,7 +19,7 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc cached_pos = ds_map_create(); - static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _p0 = getInputData(0); var _p1 = getInputData(1); @@ -33,7 +33,7 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc var _len = getLength(_amo); var _stp = 1 / clamp(_len * _s, 1, 64); var ox, oy, nx, ny; - var _p = new __vec2(); + var _p = new __vec2P(); for( var j = 0; j < 1; j += _stp ) { _p = getPointRatio(j, i, _p); @@ -46,14 +46,14 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc oy = ny; } } - } #endregion + } - static getLineCount = function() { #region + static getLineCount = function() { var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } #endregion + } - static getSegmentCount = function(ind = 0) { #region + static getSegmentCount = function(ind = 0) { var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -66,9 +66,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc if(!p1 && p2) return _path2.getSegmentCount(ind); return max(_path1.getSegmentCount(ind), _path2.getSegmentCount(ind)); - } #endregion + } - static getLength = function(ind = 0) { #region + static getLength = function(ind = 0) { var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -84,9 +84,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc var _p2 = _path2.getLength(ind); return lerp(_p1, _p2, _lerp); - } #endregion + } - static getAccuLength = function(ind = 0) { #region + static getAccuLength = function(ind = 0) { var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -112,16 +112,17 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc } return res; - } #endregion + } - static getPointRatio = function(_rat, ind = 0, out = undefined) { #region - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + static getPointRatio = function(_rat, ind = 0, out = undefined) { + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _cKey = $"{string_format(_rat, 0, 6)},{ind}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -141,15 +142,16 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc out.x = lerp(_p1.x, _p2.x, _lerp); out.y = lerp(_p1.y, _p2.y, _lerp); + out.weight = lerp(_p1.weight, _p2.weight, _lerp); - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; - } #endregion + } static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(ind), ind, out); } - static getBoundary = function(ind = 0) { #region + static getBoundary = function(ind = 0) { var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -165,15 +167,15 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc var _p2 = _path2.getBoundary(ind); return _p1.lerpTo(_p2, _lerp); - } #endregion + } - static update = function() { #region + static update = function() { ds_map_clear(cached_pos); outputs[0].setValue(self); - } #endregion + } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_blend, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_path_bridge/node_path_bridge.gml b/scripts/node_path_bridge/node_path_bridge.gml index 719a633c2..7d7cf5993 100644 --- a/scripts/node_path_bridge/node_path_bridge.gml +++ b/scripts/node_path_bridge/node_path_bridge.gml @@ -31,14 +31,14 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru cached_pos = ds_map_create(); #endregion - static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _path = getInputData(0); var _smt = getInputData(2); if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); var _amo = array_length(anchors); var ox, oy, nx, ny; - var _p = new __vec2(); + var _p = new __vec2P(); draw_set_color(COLORS._main_icon); for( var i = 0, n = _amo; i < n; i++ ) { @@ -69,7 +69,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru } } } - } #endregion + } static getLineCount = function() { return getInputData(1); } @@ -83,14 +83,15 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru static getPointRatio = function(_rat, ind = 0, out = undefined) { return getPointDistance(clamp(_rat, 0, 1) * getLength(ind), ind, out); } - static getPointDistance = function(_dist, ind = 0, out = undefined) { #region - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + static getPointDistance = function(_dist, ind = 0, out = undefined) { + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _cKey = $"{string_format(_dist, 0, 6)},{ind}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -103,7 +104,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru out.x = _p[0]; out.y = _p[1]; - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } @@ -117,7 +118,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru out.x = _p[0]; out.y = _p[1]; - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } @@ -141,12 +142,12 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru out.y = lerp(p0[1], p1[1], _rat); } - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; - } #endregion + } - static update = function() { #region + static update = function() { ds_map_clear(cached_pos); var _path = getInputData(0); @@ -157,7 +158,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru #region bridge var _lines = _path.getLineCount(); - var _p = new __vec2(); + var _p = new __vec2P(); var _rat; anchors = array_create(_amo); @@ -259,5 +260,5 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru } } #endregion - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_path_builder/node_path_builder.gml b/scripts/node_path_builder/node_path_builder.gml index 098af28ff..de8296093 100644 --- a/scripts/node_path_builder/node_path_builder.gml +++ b/scripts/node_path_builder/node_path_builder.gml @@ -110,13 +110,14 @@ function Node_Path_Builder(_x, _y, _group = noone) : Node(_x, _y, _group) constr static getAccuLength = function(ind = 0) { return lengthAccs[ind]; } static getPointDistance = function(_dist, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _cKey = $"{ind}, {string_format(_dist, 0, 6)}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -148,7 +149,7 @@ function Node_Path_Builder(_x, _y, _group = noone) : Node(_x, _y, _group) constr out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]); } - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } diff --git a/scripts/node_path_fill/node_path_fill.gml b/scripts/node_path_fill/node_path_fill.gml index 65c7a310c..1ccddbf0e 100644 --- a/scripts/node_path_fill/node_path_fill.gml +++ b/scripts/node_path_fill/node_path_fill.gml @@ -45,7 +45,7 @@ function Node_Path_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) __tpath = _path; __step = 1 / _reso; - path_points = array_verify_ext(path_points, _reso, function() /*=>*/ {return new __vec2()}); + path_points = array_verify_ext(path_points, _reso, function() /*=>*/ {return new __vec2P()}); surface_set_target(_outSurf); if(_invt) { draw_clear(_colr); BLEND_SUBTRACT } diff --git a/scripts/node_path_from_mask/node_path_from_mask.gml b/scripts/node_path_from_mask/node_path_from_mask.gml index 8b744a5bd..2f34a4af4 100644 --- a/scripts/node_path_from_mask/node_path_from_mask.gml +++ b/scripts/node_path_from_mask/node_path_from_mask.gml @@ -28,13 +28,14 @@ function Node_Path_From_Mask(_x, _y, _group = noone) : Node(_x, _y, _group) cons static getLineCount = function() { return 1; } static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _cKey = $"{string_format(_dist, 0, 6)},{_ind}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; // print($"Getting cache {_cKey} : {_dist} > {out}"); return out; @@ -67,7 +68,7 @@ function Node_Path_From_Mask(_x, _y, _group = noone) : Node(_x, _y, _group) cons // print($"Getting position {_cKey} : {_dist} - {i} > {out}"); - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } #endregion diff --git a/scripts/node_path_l_system/node_path_l_system.gml b/scripts/node_path_l_system/node_path_l_system.gml index 6193377ee..9a5b6f0af 100644 --- a/scripts/node_path_l_system/node_path_l_system.gml +++ b/scripts/node_path_l_system/node_path_l_system.gml @@ -248,7 +248,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr } static getPointRatio = function(_rat, _ind = 0, out = undefined) { - if(out == undefined) out = path_3d? new __vec3() : new __vec2(); + if(out == undefined) out = path_3d? new __vec3() : new __vec2P(); else { out.x = 0; out.y = 0; if(path_3d) out.z = 0; } var _p0 = lines[_ind][0]; diff --git a/scripts/node_path_map/node_path_map.gml b/scripts/node_path_map/node_path_map.gml index 9197ba7f2..48f5202a8 100644 --- a/scripts/node_path_map/node_path_map.gml +++ b/scripts/node_path_map/node_path_map.gml @@ -50,7 +50,7 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo var _pnt = array_create(_amo + 1); var _isb = 1 / (_sub - 1); - var _pp = new __vec2(); + var _pp = new __vec2P(); for( var i = 0; i < _amo; i++ ) { var _p = array_create(_sub + 1); @@ -92,7 +92,7 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo draw_vertex_texture(p1[0], p1[1], p1u, p1v); draw_vertex_texture(p2[0], p2[1], p2u, p2v); draw_vertex_texture(p3[0], p3[1], p3u, p3v); - + } draw_primitive_end(); surface_reset_shader(); diff --git a/scripts/node_path_map_area/node_path_map_area.gml b/scripts/node_path_map_area/node_path_map_area.gml index 55dcd9e16..cf7920a8b 100644 --- a/scripts/node_path_map_area/node_path_map_area.gml +++ b/scripts/node_path_map_area/node_path_map_area.gml @@ -37,7 +37,7 @@ function Node_Path_Map_Area(_x, _y, _group = noone) : Node(_x, _y, _group) const } static getPointRatio = function(_rat, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _path = getInputData(0); var _area = getInputData(1); @@ -55,6 +55,7 @@ function Node_Path_Map_Area(_x, _y, _group = noone) : Node(_x, _y, _group) const out.x = (_area[AREA_INDEX.center_x] - _area[AREA_INDEX.half_w]) + (_p.x - _b.minx) / _b.width * _area[AREA_INDEX.half_w] * 2; out.y = (_area[AREA_INDEX.center_y] - _area[AREA_INDEX.half_h]) + (_p.y - _b.miny) / _b.height * _area[AREA_INDEX.half_h] * 2; + out.weight = _p.weight; return out; } diff --git a/scripts/node_path_morph/node_path_morph.gml b/scripts/node_path_morph/node_path_morph.gml index 984a0ceba..a2c685b79 100644 --- a/scripts/node_path_morph/node_path_morph.gml +++ b/scripts/node_path_morph/node_path_morph.gml @@ -53,7 +53,7 @@ function Node_Path_Morph(_x, _y, _group = noone) : Node_Processor(_x, _y, _group var _mid = _data[6]; var _isb = 1 / (_sub - 1); - var _pp = new __vec2(); + var _pp = new __vec2P(); if(_mid) { var _p1 = array_create(_sub * 2); diff --git a/scripts/node_path_plot/node_path_plot.gml b/scripts/node_path_plot/node_path_plot.gml index c22a7cde6..0cb9a0475 100644 --- a/scripts/node_path_plot/node_path_plot.gml +++ b/scripts/node_path_plot/node_path_plot.gml @@ -44,7 +44,7 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct static getAccuLength = function(ind = 0) { return [ length ]; } static getPointRatio = function(_rat, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _sca = getInputData(0); var _coor = getInputData(1); @@ -76,7 +76,7 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct } break; case 1 : - var _a = new __vec2(); + var _a = new __vec2P(); switch(_eqa) { case 0 : _a.x = _rat * _iran[0] + _shf[0]; diff --git a/scripts/node_path_profile/node_path_profile.gml b/scripts/node_path_profile/node_path_profile.gml index 0c13def86..d3c92d73f 100644 --- a/scripts/node_path_profile/node_path_profile.gml +++ b/scripts/node_path_profile/node_path_profile.gml @@ -55,7 +55,7 @@ function Node_Path_Profile(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro if(_path == noone) return; var _points = array_create(_res * 2); - var _p = new __vec2(); + var _p = new __vec2P(); for( var i = 0; i < _res; i++ ) { _p = _path.getPointRatio(i / _res, 0, _p); diff --git a/scripts/node_path_repeat/node_path_repeat.gml b/scripts/node_path_repeat/node_path_repeat.gml index ea9f79ece..58e6946cc 100644 --- a/scripts/node_path_repeat/node_path_repeat.gml +++ b/scripts/node_path_repeat/node_path_repeat.gml @@ -56,7 +56,7 @@ function Node_Path_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou static getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)}; static getPointRatio = function(_rat, ind = 0, out = undefined) { - out ??= new __vec2(); + out ??= new __vec2P(); var _path = array_safe_get_fast(paths, ind, 0); if(_path == 0) return out; diff --git a/scripts/node_path_reverse/node_path_reverse.gml b/scripts/node_path_reverse/node_path_reverse.gml index 7187cd2f9..9cbe19b30 100644 --- a/scripts/node_path_reverse/node_path_reverse.gml +++ b/scripts/node_path_reverse/node_path_reverse.gml @@ -9,54 +9,54 @@ function Node_Path_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constr cached_pos = ds_map_create(); - static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _path = getInputData(0); if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); - } #endregion + } - static getLineCount = function() { #region + static getLineCount = function() { var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } #endregion + } - static getSegmentCount = function(ind = 0) { #region + static getSegmentCount = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0; - } #endregion + } - static getLength = function(ind = 0) { #region + static getLength = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getLength")? _path.getLength(ind) : 0; - } #endregion + } - static getAccuLength = function(ind = 0) { #region + static getAccuLength = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getAccuLength")? array_reverse(_path.getAccuLength(ind)) : []; - } #endregion + } - static getBoundary = function(ind = 0) { #region + static getBoundary = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1); - } #endregion + } - static getPointRatio = function(_rat, ind = 0, out = undefined) { #region - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + static getPointRatio = function(_rat, ind = 0, out = undefined) { + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _path = getInputData(0); if(!is_struct(_path) || !struct_has(_path, "getPointRatio")) return out; return _path.getPointRatio(1 - _rat, ind, out); - } #endregion + } static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } - static update = function() { #region + static update = function() { ds_map_clear(cached_pos); outputs[0].setValue(self); - } #endregion + } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_path_scatter/node_path_scatter.gml b/scripts/node_path_scatter/node_path_scatter.gml index 8982ee73b..bb5abe77b 100644 --- a/scripts/node_path_scatter/node_path_scatter.gml +++ b/scripts/node_path_scatter/node_path_scatter.gml @@ -67,7 +67,7 @@ function Node_Path_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro static getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)}; static getPointRatio = function(_rat, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _path = array_safe_get_fast(paths, ind, 0); if(_path == 0) return out; @@ -140,7 +140,7 @@ function Node_Path_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro random_set_seed(_seed); var _ind = 0; - var p = new __vec2(); + var p = new __vec2P(); var ori, pos; var _prog_raw, _prog; var _dir, _sca, _rot, _rotW, _trm; diff --git a/scripts/node_path_sdf/node_path_sdf.gml b/scripts/node_path_sdf/node_path_sdf.gml index a0ad87917..e5f7edef6 100644 --- a/scripts/node_path_sdf/node_path_sdf.gml +++ b/scripts/node_path_sdf/node_path_sdf.gml @@ -43,7 +43,7 @@ function Node_Path_SDF(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var _p = array_create((_sub + 1) * 2); var _isb = 1 / _sub; - var _pp = new __vec2(); + var _pp = new __vec2P(); for( var i = 0; i <= _sub; i++ ) { var _prog = frac(i * _isb); diff --git a/scripts/node_path_shape/node_path_shape.gml b/scripts/node_path_shape/node_path_shape.gml index ac416af4c..56fa81781 100644 --- a/scripts/node_path_shape/node_path_shape.gml +++ b/scripts/node_path_shape/node_path_shape.gml @@ -75,7 +75,7 @@ function Node_Path_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) construc static getAccuLength = function() /*=>*/ {return lengthAccs}; static getPointRatio = function(_rat, _ind = 0, out = undefined) { - out ??= new __vec2(); + out ??= new __vec2P(); _rat = frac(_rat); switch(shapeScroll[shape].name) { @@ -115,7 +115,7 @@ function Node_Path_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) construc } static getPointDistance = function(_dist, _ind = 0, out = undefined) { - out ??= new __vec2(); + out ??= new __vec2P(); _dist = safe_mod(_dist, lengthTotal); var _d = _dist, l; diff --git a/scripts/node_path_shift/node_path_shift.gml b/scripts/node_path_shift/node_path_shift.gml index d74f85120..130c17139 100644 --- a/scripts/node_path_shift/node_path_shift.gml +++ b/scripts/node_path_shift/node_path_shift.gml @@ -22,7 +22,7 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc var _len = getLength(_amo); var _stp = 1 / clamp(_len * _s, 1, 64); var ox, oy, nx, ny; - var _p = new __vec2(); + var _p = new __vec2P(); for( var j = 0; j < 1; j += _stp ) { _p = getPointRatio(j, i, _p); @@ -58,13 +58,14 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc } static getPointRatio = function(_rat, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _cKey = $"{string_format(_rat, 0, 6)},{ind}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -87,8 +88,9 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc out.x += _p.x + lengthdir_x(_shf, dir); out.y += _p.y + lengthdir_y(_shf, dir); + out.weight = _p.weight; - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } diff --git a/scripts/node_path_smooth/node_path_smooth.gml b/scripts/node_path_smooth/node_path_smooth.gml index 0b1e78e31..89b4760ad 100644 --- a/scripts/node_path_smooth/node_path_smooth.gml +++ b/scripts/node_path_smooth/node_path_smooth.gml @@ -109,7 +109,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru line_hover = _line_hover; if(key_mod_press(CTRL) || isUsingTool(0)) { // anchor edit - draw_sprite_ui_uniform(_anchor_hover == -1? THEME.cursor_path_add : THEME.cursor_path_remove, 0, _mx + 16, _my + 16); + draw_sprite_ui_uniform(_anchor_hover == -1? THEME.cursor_path_add : THEME.cursor_path_remove, 0, _mx + 4, _my + 4); if(mouse_press(mb_left, active)) { if(_anchor_hover == -1) { @@ -238,7 +238,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru static getAccuLength = function() { return lengthAccs; } static getPointDistance = function(_dist, _ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } if(array_empty(lengths)) return out; var _cKey = _dist; @@ -246,6 +246,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -276,7 +277,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _c0[2], _a0[1] + _c0[3], _a1[0] + _c1[0], _a1[1] + _c1[1]); } - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } diff --git a/scripts/node_path_transform/node_path_transform.gml b/scripts/node_path_transform/node_path_transform.gml index dac18a137..a2721dbd1 100644 --- a/scripts/node_path_transform/node_path_transform.gml +++ b/scripts/node_path_transform/node_path_transform.gml @@ -23,7 +23,7 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons rot = 0; sca = [ 1, 1 ]; anc = [ 0, 0 ]; - p = new __vec2(); + p = new __vec2P(); static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _path = getInputData(0); @@ -91,13 +91,14 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons } static getPointRatio = function(_rat, ind = 0, out = undefined) { - out ??= new __vec2(); + out ??= new __vec2P(); var _cKey = $"{string_format(_rat, 0, 6)},{ind}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -118,8 +119,9 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons out.x = _pp[0] + pos[0]; out.y = _pp[1] + pos[1]; + out.weight = _p.weight; - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } diff --git a/scripts/node_path_trim/node_path_trim.gml b/scripts/node_path_trim/node_path_trim.gml index 3da413add..e0ceddf1f 100644 --- a/scripts/node_path_trim/node_path_trim.gml +++ b/scripts/node_path_trim/node_path_trim.gml @@ -11,7 +11,7 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct cached_pos = ds_map_create(); - static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _path = getInputData(0); if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); @@ -22,7 +22,7 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct var _len = getLength(_amo); var _stp = 1 / clamp(_len * _s, 1, 64); var ox, oy, nx, ny; - var _p = new __vec2(); + var _p = new __vec2P(); for( var j = 0; j < 1; j += _stp ) { _p = getPointRatio(j, i, _p); @@ -35,30 +35,30 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct oy = ny; } } - } #endregion + } - static getLineCount = function() { #region + static getLineCount = function() { var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } #endregion + } - static getSegmentCount = function(ind = 0) { #region + static getSegmentCount = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0; - } #endregion + } - static getLength = function(ind = 0) { #region + static getLength = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getLength")? _path.getLength(ind) : 0; - } #endregion + } - static getAccuLength = function(ind = 0) { #region + static getAccuLength = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : []; - } #endregion + } - static getPointRatio = function(_rat, ind = 0, out = undefined) { #region - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + static getPointRatio = function(_rat, ind = 0, out = undefined) { + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _path = getInputData(0); var _rng = getInputData(1); @@ -74,22 +74,22 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct _rat = _rng[0] + _rat * (_rng[1] - _rng[0]); return _path.getPointRatio(_rat, ind, out); - } #endregion + } static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } - static getBoundary = function(ind = 0) { #region + static getBoundary = function(ind = 0) { var _path = getInputData(0); return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 ); - } #endregion + } - static update = function() { #region + static update = function() { ds_map_clear(cached_pos); outputs[0].setValue(self); - } #endregion + } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_path_wave/node_path_wave.gml b/scripts/node_path_wave/node_path_wave.gml index 2bffea18f..fd045b782 100644 --- a/scripts/node_path_wave/node_path_wave.gml +++ b/scripts/node_path_wave/node_path_wave.gml @@ -47,9 +47,9 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct wig_map = noone; amp_curve = noone; - p = new __vec2(); - p0 = new __vec2(); - p1 = new __vec2(); + p = new __vec2P(); + p0 = new __vec2P(); + p1 = new __vec2P(); cached_pos = ds_map_create(); @@ -112,13 +112,14 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct } static getPointRatio = function(_rat, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } var _cKey = $"{string_format(_rat, 0, 6)},{ind}"; if(ds_map_exists(cached_pos, _cKey)) { var _p = cached_pos[? _cKey]; out.x = _p.x; out.y = _p.y; + out.weight = _p.weight; return out; } @@ -175,8 +176,9 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct out.x = p.x + lengthdir_x(_amp * prg, dir); out.y = p.y + lengthdir_y(_amp * prg, dir); + out.weight = p.weight; - cached_pos[? _cKey] = out.clone(); + cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight); return out; } diff --git a/scripts/node_text/node_text.gml b/scripts/node_text/node_text.gml index 4b232e199..7bec0f190 100644 --- a/scripts/node_text/node_text.gml +++ b/scripts/node_text/node_text.gml @@ -361,8 +361,8 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons __temp_tx = tx + _pthS; __temp_ty = ty; - __temp_p0 = new __vec2(); - __temp_p1 = new __vec2(); + __temp_p0 = new __vec2P(); + __temp_p1 = new __vec2P(); string_foreach(_str_line, function(_chr, _ind) { var _p1 = __temp_pt.getPointDistance(__temp_tx, 0, __temp_p0);