[Path] Add variable weight support.

This commit is contained in:
Tanasart 2025-01-15 13:55:00 +07:00
parent e305ae3793
commit 3aba27f9bd
46 changed files with 839 additions and 561 deletions

Binary file not shown.

View file

@ -1,6 +1,6 @@
{ {
"tooltip":"Custom node", "tooltip":"Custom node",
"spr":"__newsprite1112", "spr":"s_node_icon",
"baseNode":"Node_Custom", "baseNode":"Node_Custom",
"io":[ "io":[
], ],

View file

@ -11,6 +11,6 @@
"intersection", "intersection",
"difference", "difference",
"xor", "xor",
] ],
"pxc_version":118069, "pxc_version":118069,
} }

Binary file not shown.

View file

@ -13,7 +13,7 @@ function Path() constructor {
static getTangentRatio = function(_rat) { return 0; } 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) { static getPointRatio = function(_rat, _ind = 0, out = undefined) {
var pix = frac(_rat) * lengthTotal; var pix = frac(_rat) * lengthTotal;
return getPointDistance(pix, _ind, out); return getPointDistance(pix, _ind, out);
@ -64,7 +64,7 @@ function PathSegment() : Path() constructor {
} #endregion } #endregion
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region 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++ ) { for( var i = 0; i < array_length(lengths); i++ ) {
if(_dist <= lengths[i]) { if(_dist <= lengths[i]) {

View file

@ -132,9 +132,7 @@
var v0 = array_safe_get_fast(arr, floor(index)); var v0 = array_safe_get_fast(arr, floor(index));
var v1 = array_safe_get_fast(arr, floor(index) + 1); var v1 = array_safe_get_fast(arr, floor(index) + 1);
return color? return color? merge_color(v0, v1, frac(index)) : lerp(v0, v1, frac(index));
merge_color(v0, v1, frac(index)) :
lerp(v0, v1, frac(index));
} }
function array_safe_length(arr) { function array_safe_length(arr) {

View file

@ -1,5 +1,5 @@
function __initCollection() { function __initCollection() {
printDebug("COLLECTION", "init"); printDebug("COLLECTION: init");
globalvar COLLECTIONS; globalvar COLLECTIONS;
COLLECTIONS = -1; COLLECTIONS = -1;
@ -15,7 +15,7 @@ function __initCollection() {
} }
function refreshCollections() { function refreshCollections() {
printDebug("COLLECTION", "refreshing collection base folder."); printDebug("COLLECTION: refreshing collection base folder.");
COLLECTIONS = new DirectoryObject(DIRECTORY + "Collections"); COLLECTIONS = new DirectoryObject(DIRECTORY + "Collections");
COLLECTIONS.scan([".json", ".pxcc"]); COLLECTIONS.scan([".json", ".pxcc"]);

View file

@ -1,5 +1,13 @@
function distance_to_line(_px, _py, _x0, _y0, _x1, _y1, log = false) { function point_to_line(_px, _py, _x0, _y0, _x1, _y1) {
INLINE 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); var l2 = sqr(_x0 - _x1) + sqr(_y0 - _y1);
if (l2 == 0) return point_distance(_px, _py, _x0, _y0); 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) { 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)); return abs((x1 - x0) * (y0 - py) - (x0 - px) * (y1 - y0)) / sqrt(sqr(x1 - x0) + sqr(y1 - y0));
} }

View file

@ -43,7 +43,7 @@
LATEST_VERSION = 1_18_00_0; LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_06_2; VERSION = 1_18_06_2;
SAVE_VERSION = 1_18_05_0; 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; BUILD_NUMBER = 118069;
PREF_VERSION = 1_17_1; PREF_VERSION = 1_17_1;

View file

@ -34,4 +34,6 @@ function lerp_color(from, to, ratio) {
return merge_color(from, to, ratio); return merge_color(from, to, ratio);
} }
function lerp_invert(val, from, to) { return (val - from) / (to - from); } function lerp_invert(val, from, to) { return (val - from) / (to - from); }
function lerp_smooth(_x) { return _x * _x * (3.0 - 2.0 * _x) }

View file

@ -51,7 +51,7 @@ function Node_3D_Mesh_Wall_Builder(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
if(_paths == noone) return noone; if(_paths == noone) return noone;
var points = array_create(_segment + 1); var points = array_create(_segment + 1);
var p = new __vec2(); var p = new __vec2P();
for( var i = 0; i <= _segment; i++ ) { for( var i = 0; i <= _segment; i++ ) {
p = _paths.getPointRatio(i / _segment, 0, p); p = _paths.getPointRatio(i / _segment, 0, p);

View file

@ -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 getAccuLength = function(index) { return array_safe_get_fast(lengthAcc, index, []); }
static getPointRatio = function(_rat, _ind = 0, out = undefined) { 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 _p0, _p1;
var _x, _y; var _x, _y;

View file

@ -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 getPointDistance = function(_dist, _ind = 0, out = undefined) { return getPointRatio(_dist / current_length, _ind, out); }
static getPointRatio = function(_rat, _ind = 0, out = undefined) { 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 _p0 = lines[_ind][0];
var _p1 = lines[_ind][1]; var _p1 = lines[_ind][1];

View file

@ -73,7 +73,7 @@ function Node_Blur_Path(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _dim = surface_get_dimension(_surf) var _dim = surface_get_dimension(_surf)
var _points_x = array_create(_pntc); var _points_x = array_create(_pntc);
var _points_y = array_create(_pntc); var _points_y = array_create(_pntc);
var _p = new __vec2(); var _p = new __vec2P();
var _rst = _rang[0]; var _rst = _rang[0];
var _red = _rang[1]; var _red = _rang[1];

View file

@ -2376,10 +2376,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return _tool.selecting == subtool; 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 isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; }
static getTool = function() { return self; } static getTool = function() { return self; }
static getToolSettings = function() { return tool_settings; } static getToolSettings = function() { return tool_settings; }
static setTool = function(tool) { static setTool = function(tool) {

View file

@ -32,7 +32,7 @@ function Node_Fn_SmoothStep(_x, _y, _group = noone) : Node_Fn(_x, _y, _group) co
return i / graph_res; 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]; value = _data[inl + 0];
type = _data[inl + 1]; 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; text_display = val;
return val; return val;
} #endregion }
} }

View file

@ -259,7 +259,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
random_set_seed(_sed); random_set_seed(_sed);
var _sedIndex = 0; var _sedIndex = 0;
var p = new __vec2(); var p = new __vec2P();
var _pathData = []; var _pathData = [];
var minx = 999999, miny = 999999, maxx = -999999, maxy = -999999; 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}"); // print($"_pp = {_pp}, total = {_total}");
p = _pat.getPointDistance(_pp, i, p); p = _pat.getPointDistance(_pp, i, p);
if(struct_has(_pat, "getWeightDistance")) wght = p[$ "weight"] ?? 1;
wght = _pat.getWeightDistance(_pp, i);
} else { } else {
_prog_next = min(_prog_curr + _stepLen, 1); //Move forward _stepLen or _total (if less) stop at 1 _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 var _pp = _clamp? clamp(_pathPng, 0, 1) : _pathPng
p = _pat.getPointRatio(_pp, i, p); p = _pat.getPointRatio(_pp, i, p);
if(struct_has(_pat, "getWeightRatio")) wght = p[$ "weight"] ?? 1;
wght = _pat.getWeightRatio(_pp, i);
} }
_nx = p.x; _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)) if(!ds_map_exists(widthMap, widProg))
widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1); widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1);
_nw *= widthMap[? widProg]; _nw *= widthMap[? widProg];
_nw *= p0.weight; _nw *= p0.weight / 2;
_nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc)); _nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc));

View file

@ -265,7 +265,7 @@ function Node_Liquefy(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
if(_type == LIQUEFY_TYPE.push) { if(_type == LIQUEFY_TYPE.push) {
var _usePath = _path != noone; var _usePath = _path != noone;
var _pthList = array_create(_pthR * 2); var _pthList = array_create(_pthR * 2);
var _p = new __vec2(); var _p = new __vec2P();
if(_usePath) { if(_usePath) {
for( var i = 0; i < _pthR; i++ ) { for( var i = 0; i < _pthR; i++ ) {

View file

@ -44,7 +44,7 @@ function Node_Mesh_To_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constr
l -= lengths[i]; l -= lengths[i];
} }
return new __vec2(); return new __vec2P();
} }
static update = function() { static update = function() {

View file

@ -417,8 +417,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
} }
if(isUsingTool("Edit control point")) { if(isUsingTool("Edit control point")) {
if(key_mod_press(SHIFT)) draw_sprite_ui_uniform(THEME.cursor_path_remove, 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 + 16, _my + 16); else draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4);
if(mouse_press(mb_left, active)) { if(mouse_press(mb_left, active)) {
if(_hover == -1) { if(_hover == -1) {
@ -438,7 +438,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
control(input_display_list); control(input_display_list);
} }
} else if(isUsingTool("Pin mesh")) { } 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); draw_set_color(COLORS._main_accent);
var rad = 16; var rad = 16;

File diff suppressed because it is too large Load diff

View file

@ -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 if(anchor_hover != -1) { // no tool, dragging existing point
var _a = array_clone(getInputData(input_fix_len + anchor_hover)); var _a = array_clone(getInputData(input_fix_len + anchor_hover));
if(isUsingTool(2) && hover_type == 0) { 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)) { 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 } 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)) { if(mouse_press(mb_left, active)) {
var _indx = input_fix_len + anchor_hover; 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(); doUpdate();
} }
} else { } 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(mouse_press(mb_left, active)) {
if(isUsingTool(2)) { 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 } 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)) { if(mouse_press(mb_left, active)) {

View file

@ -69,7 +69,7 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc
ind -= lc; ind -= lc;
} }
return new __vec2(); return new __vec2P();
} }
static getPointDistance = function(_dist, ind = 0) { 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; ind -= lc;
} }
return new __vec2(); return new __vec2P();
} }
static getBoundary = function(ind = 0) { static getBoundary = function(ind = 0) {

View file

@ -55,7 +55,7 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct
path_amount = _amo; path_amount = _amo;
var _segs = array_create(_amo); var _segs = array_create(_amo);
var _p = new __vec2(); var _p = new __vec2P();
for( var i = 0; i < _amo; i++ ) { for( var i = 0; i < _amo; i++ ) {
var _len = _path.getLength(i); var _len = _path.getLength(i);

View file

@ -19,7 +19,7 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
cached_pos = ds_map_create(); 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 _p0 = getInputData(0);
var _p1 = getInputData(1); 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 _len = getLength(_amo);
var _stp = 1 / clamp(_len * _s, 1, 64); var _stp = 1 / clamp(_len * _s, 1, 64);
var ox, oy, nx, ny; var ox, oy, nx, ny;
var _p = new __vec2(); var _p = new __vec2P();
for( var j = 0; j < 1; j += _stp ) { for( var j = 0; j < 1; j += _stp ) {
_p = getPointRatio(j, i, _p); _p = getPointRatio(j, i, _p);
@ -46,14 +46,14 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
oy = ny; oy = ny;
} }
} }
} #endregion }
static getLineCount = function() { #region static getLineCount = function() {
var _path = getInputData(0); var _path = getInputData(0);
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; 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 _path1 = getInputData(0);
var _path2 = getInputData(1); var _path2 = getInputData(1);
var _lerp = getInputData(2); 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); if(!p1 && p2) return _path2.getSegmentCount(ind);
return max(_path1.getSegmentCount(ind), _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 _path1 = getInputData(0);
var _path2 = getInputData(1); var _path2 = getInputData(1);
var _lerp = getInputData(2); 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); var _p2 = _path2.getLength(ind);
return lerp(_p1, _p2, _lerp); return lerp(_p1, _p2, _lerp);
} #endregion }
static getAccuLength = function(ind = 0) { #region static getAccuLength = function(ind = 0) {
var _path1 = getInputData(0); var _path1 = getInputData(0);
var _path2 = getInputData(1); var _path2 = getInputData(1);
var _lerp = getInputData(2); var _lerp = getInputData(2);
@ -112,16 +112,17 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
} }
return res; return res;
} #endregion }
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region 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}"; var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; 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.x = lerp(_p1.x, _p2.x, _lerp);
out.y = lerp(_p1.y, _p2.y, _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; return out;
} #endregion }
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(ind), ind, out); } 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 _path1 = getInputData(0);
var _path2 = getInputData(1); var _path2 = getInputData(1);
var _lerp = getInputData(2); 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); var _p2 = _path2.getBoundary(ind);
return _p1.lerpTo(_p2, _lerp); return _p1.lerpTo(_p2, _lerp);
} #endregion }
static update = function() { #region static update = function() {
ds_map_clear(cached_pos); ds_map_clear(cached_pos);
outputs[0].setValue(self); 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); var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_path_blend, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); draw_sprite_fit(s_node_path_blend, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
} #endregion }
} }

View file

@ -31,14 +31,14 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
cached_pos = ds_map_create(); cached_pos = ds_map_create();
#endregion #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 _path = getInputData(0);
var _smt = getInputData(2); var _smt = getInputData(2);
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
var _amo = array_length(anchors); var _amo = array_length(anchors);
var ox, oy, nx, ny; var ox, oy, nx, ny;
var _p = new __vec2(); var _p = new __vec2P();
draw_set_color(COLORS._main_icon); draw_set_color(COLORS._main_icon);
for( var i = 0, n = _amo; i < n; i++ ) { 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); } 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 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 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 = $"{string_format(_dist, 0, 6)},{ind}"; var _cKey = $"{string_format(_dist, 0, 6)},{ind}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; return out;
} }
@ -103,7 +104,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
out.x = _p[0]; out.x = _p[0];
out.y = _p[1]; out.y = _p[1];
cached_pos[? _cKey] = out.clone(); cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
return out; return out;
} }
@ -117,7 +118,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
out.x = _p[0]; out.x = _p[0];
out.y = _p[1]; out.y = _p[1];
cached_pos[? _cKey] = out.clone(); cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
return out; 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); 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; return out;
} #endregion }
static update = function() { #region static update = function() {
ds_map_clear(cached_pos); ds_map_clear(cached_pos);
var _path = getInputData(0); var _path = getInputData(0);
@ -157,7 +158,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
#region bridge #region bridge
var _lines = _path.getLineCount(); var _lines = _path.getLineCount();
var _p = new __vec2(); var _p = new __vec2P();
var _rat; var _rat;
anchors = array_create(_amo); anchors = array_create(_amo);
@ -259,5 +260,5 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
} }
} }
#endregion #endregion
} #endregion }
} }

View file

@ -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 getAccuLength = function(ind = 0) { return lengthAccs[ind]; }
static getPointDistance = function(_dist, ind = 0, out = undefined) { 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)}"; var _cKey = $"{ind}, {string_format(_dist, 0, 6)}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; 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]); 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; return out;
} }

View file

@ -45,7 +45,7 @@ function Node_Path_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
__tpath = _path; __tpath = _path;
__step = 1 / _reso; __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); surface_set_target(_outSurf);
if(_invt) { draw_clear(_colr); BLEND_SUBTRACT } if(_invt) { draw_clear(_colr); BLEND_SUBTRACT }

View file

@ -28,13 +28,14 @@ function Node_Path_From_Mask(_x, _y, _group = noone) : Node(_x, _y, _group) cons
static getLineCount = function() { return 1; } static getLineCount = function() { return 1; }
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region 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}"; var _cKey = $"{string_format(_dist, 0, 6)},{_ind}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
// print($"Getting cache {_cKey} : {_dist} > {out}"); // print($"Getting cache {_cKey} : {_dist} > {out}");
return 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}"); // 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; return out;
} #endregion } #endregion

View file

@ -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) { 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; } else { out.x = 0; out.y = 0; if(path_3d) out.z = 0; }
var _p0 = lines[_ind][0]; var _p0 = lines[_ind][0];

View file

@ -50,7 +50,7 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var _pnt = array_create(_amo + 1); var _pnt = array_create(_amo + 1);
var _isb = 1 / (_sub - 1); var _isb = 1 / (_sub - 1);
var _pp = new __vec2(); var _pp = new __vec2P();
for( var i = 0; i < _amo; i++ ) { for( var i = 0; i < _amo; i++ ) {
var _p = array_create(_sub + 1); 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(p1[0], p1[1], p1u, p1v);
draw_vertex_texture(p2[0], p2[1], p2u, p2v); draw_vertex_texture(p2[0], p2[1], p2u, p2v);
draw_vertex_texture(p3[0], p3[1], p3u, p3v); draw_vertex_texture(p3[0], p3[1], p3u, p3v);
} }
draw_primitive_end(); draw_primitive_end();
surface_reset_shader(); surface_reset_shader();

View file

@ -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) { 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 _path = getInputData(0);
var _area = getInputData(1); 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.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.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; return out;
} }

View file

@ -53,7 +53,7 @@ function Node_Path_Morph(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
var _mid = _data[6]; var _mid = _data[6];
var _isb = 1 / (_sub - 1); var _isb = 1 / (_sub - 1);
var _pp = new __vec2(); var _pp = new __vec2P();
if(_mid) { if(_mid) {
var _p1 = array_create(_sub * 2); var _p1 = array_create(_sub * 2);

View file

@ -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 getAccuLength = function(ind = 0) { return [ length ]; }
static getPointRatio = function(_rat, ind = 0, out = undefined) { 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 _sca = getInputData(0);
var _coor = getInputData(1); var _coor = getInputData(1);
@ -76,7 +76,7 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct
} }
break; break;
case 1 : case 1 :
var _a = new __vec2(); var _a = new __vec2P();
switch(_eqa) { switch(_eqa) {
case 0 : case 0 :
_a.x = _rat * _iran[0] + _shf[0]; _a.x = _rat * _iran[0] + _shf[0];

View file

@ -55,7 +55,7 @@ function Node_Path_Profile(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
if(_path == noone) return; if(_path == noone) return;
var _points = array_create(_res * 2); var _points = array_create(_res * 2);
var _p = new __vec2(); var _p = new __vec2P();
for( var i = 0; i < _res; i++ ) { for( var i = 0; i < _res; i++ ) {
_p = _path.getPointRatio(i / _res, 0, _p); _p = _path.getPointRatio(i / _res, 0, _p);

View file

@ -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 getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)};
static getPointRatio = function(_rat, ind = 0, out = undefined) { static getPointRatio = function(_rat, ind = 0, out = undefined) {
out ??= new __vec2(); out ??= new __vec2P();
var _path = array_safe_get_fast(paths, ind, 0); var _path = array_safe_get_fast(paths, ind, 0);
if(_path == 0) return out; if(_path == 0) return out;

View file

@ -9,54 +9,54 @@ function Node_Path_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constr
cached_pos = ds_map_create(); 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); var _path = getInputData(0);
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); 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); var _path = getInputData(0);
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
} #endregion }
static getSegmentCount = function(ind = 0) { #region static getSegmentCount = function(ind = 0) {
var _path = getInputData(0); var _path = getInputData(0);
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 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); var _path = getInputData(0);
return struct_has(_path, "getLength")? _path.getLength(ind) : 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); var _path = getInputData(0);
return struct_has(_path, "getAccuLength")? array_reverse(_path.getAccuLength(ind)) : []; 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); var _path = getInputData(0);
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1); return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1);
} #endregion }
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region 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 _path = getInputData(0);
if(!is_struct(_path) || !struct_has(_path, "getPointRatio")) if(!is_struct(_path) || !struct_has(_path, "getPointRatio"))
return out; return out;
return _path.getPointRatio(1 - _rat, ind, out); return _path.getPointRatio(1 - _rat, ind, out);
} #endregion }
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } 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); ds_map_clear(cached_pos);
outputs[0].setValue(self); 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); var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
} #endregion }
} }

View file

@ -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 getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)};
static getPointRatio = function(_rat, ind = 0, out = undefined) { 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); var _path = array_safe_get_fast(paths, ind, 0);
if(_path == 0) return out; 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); random_set_seed(_seed);
var _ind = 0; var _ind = 0;
var p = new __vec2(); var p = new __vec2P();
var ori, pos; var ori, pos;
var _prog_raw, _prog; var _prog_raw, _prog;
var _dir, _sca, _rot, _rotW, _trm; var _dir, _sca, _rot, _rotW, _trm;

View file

@ -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 _p = array_create((_sub + 1) * 2);
var _isb = 1 / _sub; var _isb = 1 / _sub;
var _pp = new __vec2(); var _pp = new __vec2P();
for( var i = 0; i <= _sub; i++ ) { for( var i = 0; i <= _sub; i++ ) {
var _prog = frac(i * _isb); var _prog = frac(i * _isb);

View file

@ -75,7 +75,7 @@ function Node_Path_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) construc
static getAccuLength = function() /*=>*/ {return lengthAccs}; static getAccuLength = function() /*=>*/ {return lengthAccs};
static getPointRatio = function(_rat, _ind = 0, out = undefined) { static getPointRatio = function(_rat, _ind = 0, out = undefined) {
out ??= new __vec2(); out ??= new __vec2P();
_rat = frac(_rat); _rat = frac(_rat);
switch(shapeScroll[shape].name) { 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) { static getPointDistance = function(_dist, _ind = 0, out = undefined) {
out ??= new __vec2(); out ??= new __vec2P();
_dist = safe_mod(_dist, lengthTotal); _dist = safe_mod(_dist, lengthTotal);
var _d = _dist, l; var _d = _dist, l;

View file

@ -22,7 +22,7 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc
var _len = getLength(_amo); var _len = getLength(_amo);
var _stp = 1 / clamp(_len * _s, 1, 64); var _stp = 1 / clamp(_len * _s, 1, 64);
var ox, oy, nx, ny; var ox, oy, nx, ny;
var _p = new __vec2(); var _p = new __vec2P();
for( var j = 0; j < 1; j += _stp ) { for( var j = 0; j < 1; j += _stp ) {
_p = getPointRatio(j, i, _p); _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) { 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}"; var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; 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.x += _p.x + lengthdir_x(_shf, dir);
out.y += _p.y + lengthdir_y(_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; return out;
} }

View file

@ -109,7 +109,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
line_hover = _line_hover; line_hover = _line_hover;
if(key_mod_press(CTRL) || isUsingTool(0)) { // anchor edit 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(mouse_press(mb_left, active)) {
if(_anchor_hover == -1) { 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 getAccuLength = function() { return lengthAccs; }
static getPointDistance = function(_dist, _ind = 0, out = undefined) { 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; if(array_empty(lengths)) return out;
var _cKey = _dist; 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]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; 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]); 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; return out;
} }

View file

@ -23,7 +23,7 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons
rot = 0; rot = 0;
sca = [ 1, 1 ]; sca = [ 1, 1 ];
anc = [ 0, 0 ]; anc = [ 0, 0 ];
p = new __vec2(); p = new __vec2P();
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _path = getInputData(0); 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) { static getPointRatio = function(_rat, ind = 0, out = undefined) {
out ??= new __vec2(); out ??= new __vec2P();
var _cKey = $"{string_format(_rat, 0, 6)},{ind}"; var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; 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.x = _pp[0] + pos[0];
out.y = _pp[1] + pos[1]; 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; return out;
} }

View file

@ -11,7 +11,7 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct
cached_pos = ds_map_create(); 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); var _path = getInputData(0);
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); 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 _len = getLength(_amo);
var _stp = 1 / clamp(_len * _s, 1, 64); var _stp = 1 / clamp(_len * _s, 1, 64);
var ox, oy, nx, ny; var ox, oy, nx, ny;
var _p = new __vec2(); var _p = new __vec2P();
for( var j = 0; j < 1; j += _stp ) { for( var j = 0; j < 1; j += _stp ) {
_p = getPointRatio(j, i, _p); _p = getPointRatio(j, i, _p);
@ -35,30 +35,30 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct
oy = ny; oy = ny;
} }
} }
} #endregion }
static getLineCount = function() { #region static getLineCount = function() {
var _path = getInputData(0); var _path = getInputData(0);
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
} #endregion }
static getSegmentCount = function(ind = 0) { #region static getSegmentCount = function(ind = 0) {
var _path = getInputData(0); var _path = getInputData(0);
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 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); var _path = getInputData(0);
return struct_has(_path, "getLength")? _path.getLength(ind) : 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); var _path = getInputData(0);
return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : []; return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : [];
} #endregion }
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region 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 _path = getInputData(0);
var _rng = getInputData(1); 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]); _rat = _rng[0] + _rat * (_rng[1] - _rng[0]);
return _path.getPointRatio(_rat, ind, out); return _path.getPointRatio(_rat, ind, out);
} #endregion }
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } 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); var _path = getInputData(0);
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 ); 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); ds_map_clear(cached_pos);
outputs[0].setValue(self); 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); var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
} #endregion }
} }

View file

@ -47,9 +47,9 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
wig_map = noone; wig_map = noone;
amp_curve = noone; amp_curve = noone;
p = new __vec2(); p = new __vec2P();
p0 = new __vec2(); p0 = new __vec2P();
p1 = new __vec2(); p1 = new __vec2P();
cached_pos = ds_map_create(); 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) { 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}"; var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
if(ds_map_exists(cached_pos, _cKey)) { if(ds_map_exists(cached_pos, _cKey)) {
var _p = cached_pos[? _cKey]; var _p = cached_pos[? _cKey];
out.x = _p.x; out.x = _p.x;
out.y = _p.y; out.y = _p.y;
out.weight = _p.weight;
return out; 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.x = p.x + lengthdir_x(_amp * prg, dir);
out.y = p.y + lengthdir_y(_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; return out;
} }

View file

@ -361,8 +361,8 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
__temp_tx = tx + _pthS; __temp_tx = tx + _pthS;
__temp_ty = ty; __temp_ty = ty;
__temp_p0 = new __vec2(); __temp_p0 = new __vec2P();
__temp_p1 = new __vec2(); __temp_p1 = new __vec2P();
string_foreach(_str_line, function(_chr, _ind) { string_foreach(_str_line, function(_chr, _ind) {
var _p1 = __temp_pt.getPointDistance(__temp_tx, 0, __temp_p0); var _p1 = __temp_pt.getPointDistance(__temp_tx, 0, __temp_p0);