From 5d3a1f7835cd224c05309a56df465e0d39a07473 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Mon, 1 Apr 2024 16:10:01 +0700 Subject: [PATCH] Bug fixes and optimizations --- objects/o_dialog_preference/Create_0.gml | 2 +- scripts/console_commands/console_commands.gml | 4 +- .../curve_bezier_function.gml | 34 +++---- scripts/draw_UI_scale/draw_UI_scale.gml | 13 +-- scripts/font_loader/font_loader.gml | 31 +++++++ .../function_register/function_register.gml | 8 +- scripts/node_armature/node_armature.gml | 3 + .../node_armature_bind/node_armature_bind.gml | 64 +++++++------- .../node_armature_pose/node_armature_pose.gml | 4 +- scripts/node_collection/node_collection.gml | 1 + scripts/node_data/node_data.gml | 17 +++- .../node_feedback_inline.gml | 5 +- .../node_feedback_input.gml | 11 ++- scripts/node_functions/node_functions.gml | 5 +- .../node_iterate_inline.gml | 7 +- .../node_iterator_each_input.gml | 7 +- .../node_iterator_filter_input.gml | 7 +- .../node_iterator_input.gml | 19 ++-- scripts/node_keyframe/node_keyframe.gml | 9 +- scripts/node_line/node_line.gml | 4 +- .../node_noise_simplex/node_noise_simplex.gml | 2 +- scripts/node_value/node_value.gml | 56 ++++++------ scripts/obj_reader/obj_reader.gml | 18 ++-- scripts/panel_animation/panel_animation.gml | 39 ++++---- scripts/pcx_ast/pcx_ast.gml | 88 +++++++++---------- scripts/pcx_parse/pcx_parse.gml | 6 +- scripts/pcx_server/pcx_server.gml | 6 +- scripts/string_decimal/string_decimal.gml | 45 +++++----- scripts/textArea/textArea.gml | 11 ++- 29 files changed, 298 insertions(+), 228 deletions(-) diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index 0478f82f2..4540c2f69 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -510,7 +510,7 @@ event_inherited(); ds_list_add(pref_node, __txt("Node")); ds_list_add(pref_node, new __Panel_Linear_Setting_Item_Preference( - __txtx("pref_node_param_show", "Show paramater"), + __txtx("pref_node_param_show", "Show paramater on new node"), "node_param_show", new checkBox(function() { diff --git a/scripts/console_commands/console_commands.gml b/scripts/console_commands/console_commands.gml index 8e8861d01..e0bde27ce 100644 --- a/scripts/console_commands/console_commands.gml +++ b/scripts/console_commands/console_commands.gml @@ -86,8 +86,8 @@ function cmd_submit(command) { #region break; default: - if(struct_has(FUNCTIONS, cmd[0])) { - var _f = FUNCTIONS[$ cmd[0]]; + if(struct_has(CMD_FUNCTIONS, cmd[0])) { + var _f = CMD_FUNCTIONS[$ cmd[0]]; var _vars = string_splice(array_safe_get_fast(cmd, 1, ""), ","); var _args = []; diff --git a/scripts/curve_bezier_function/curve_bezier_function.gml b/scripts/curve_bezier_function/curve_bezier_function.gml index 857a80ea5..a6e7e7827 100644 --- a/scripts/curve_bezier_function/curve_bezier_function.gml +++ b/scripts/curve_bezier_function/curve_bezier_function.gml @@ -124,18 +124,17 @@ function eval_curve_segment_x(_bz, _x, _tolr = 0.00001) { #region if(_bz[0] == _bz[2] && _bz[0] == _bz[4] && _bz[0] == _bz[5]) return _bz[0]; repeat(_binRep) { - var _ftx = power(1 - _xt, 3) * 0 - + 3 * power(1 - _xt, 2) * _xt * _bz[1] - + 3 * (1 - _xt) * power(_xt, 2) * _bz[3] - + power(_xt, 3) * 1; + var _1xt = 1 - _xt; + + var _ftx = 3 * _1xt * _1xt * _xt * _bz[1] + + 3 * _1xt * _xt * _xt * _bz[3] + + _xt * _xt * _xt; if(abs(_ftx - _x) < _tolr) return eval_curve_segment_t(_bz, _xt); - if(_xt < _x) - st = _xt; - else - ed = _xt; + if(_xt < _x) st = _xt; + else ed = _xt; _xt = (st + ed) / 2; } @@ -143,13 +142,18 @@ function eval_curve_segment_x(_bz, _x, _tolr = 0.00001) { #region var _newRep = 8; repeat(_newRep) { - var slope = ( 9 * _bz[1] - 9 * _bz[3] + 3) * _xt * _xt - + (-12 * _bz[1] + 6 * _bz[3]) * _xt - + 3 * _bz[1]; - var _ftx = power(1 - _xt, 3) * 0 - + 3 * power(1 - _xt, 2) * _xt * _bz[1] - + 3 * (1 - _xt) * power(_xt, 2) * _bz[3] - + power(_xt, 3) * 1 + var _bz1 = _bz[1]; + var _bz3 = _bz[3]; + + var slope = ( 9 * _bz1 - 9 * _bz3 + 3) * _xt * _xt + + (-12 * _bz1 + 6 * _bz3) * _xt + + 3 * _bz1; + + var _1xt = 1 - _xt; + + var _ftx = 3 * _1xt * _1xt * _xt * _bz1 + + 3 * _1xt * _xt * _xt * _bz3 + + _xt * _xt * _xt - _x; _xt -= _ftx / slope; diff --git a/scripts/draw_UI_scale/draw_UI_scale.gml b/scripts/draw_UI_scale/draw_UI_scale.gml index 539d06990..aeeee7092 100644 --- a/scripts/draw_UI_scale/draw_UI_scale.gml +++ b/scripts/draw_UI_scale/draw_UI_scale.gml @@ -1,18 +1,7 @@ -global.LINE_HEIGHTS = {}; - function line_get_height(font = noone, offset = 0) { INLINE var _f = font != noone? font : draw_get_font(); - if(struct_has(global.LINE_HEIGHTS, _f)) return global.LINE_HEIGHTS[$ _f] + offset * UI_SCALE; - - var ff = draw_get_font(); - - if(font != noone) draw_set_font(font); - var hh = string_height("l"); - global.LINE_HEIGHTS[$ _f] = hh; - draw_set_font(ff); - - return hh + offset * UI_SCALE; + return global.LINE_HEIGHTS[$ _f] + offset * UI_SCALE; } function line_get_width(txt, font = noone, offset = 0) { diff --git a/scripts/font_loader/font_loader.gml b/scripts/font_loader/font_loader.gml index a8bcf4a80..847b8533b 100644 --- a/scripts/font_loader/font_loader.gml +++ b/scripts/font_loader/font_loader.gml @@ -1,6 +1,8 @@ globalvar FONT_DEF, FONT_ISLOADED, FONT_CACHE, FONT_CUST_CACHE, GLYPH_MAP; globalvar f_h1, f_h2, f_h3, f_h5, f_p0, f_p0b, f_p1, f_p2, f_p3, f_code, f_sdf, f_sdf_medium; +global.LINE_HEIGHTS = {}; + #region default FONT_DEF = true; FONT_CACHE = {}; @@ -23,6 +25,31 @@ globalvar f_h1, f_h2, f_h3, f_h5, f_p0, f_p0b, f_p1, f_p2, f_p3, f_code, f_sdf, FONT_ISLOADED = false; #endregion +function __font_add_height(font) { #region + INLINE + + draw_set_font(font); + global.LINE_HEIGHTS[$ font] = string_height("l"); +} #endregion + +function __font_refresh() { #region + __font_add_height(f_h1); + __font_add_height(f_h2); + __font_add_height(f_h3); + __font_add_height(f_h5); + + __font_add_height(f_p0); + __font_add_height(f_p0b); + + __font_add_height(f_p1); + __font_add_height(f_p2); + __font_add_height(f_p3); + + __font_add_height(f_code); + __font_add_height(f_sdf); + __font_add_height(f_sdf_medium); +} #endregion + function _font_add(path, size, sdf = false, custom = false) { #region var _cache = custom? FONT_CUST_CACHE : FONT_CACHE; var font_cache_dir = DIRECTORY + "font_cache"; @@ -134,6 +161,8 @@ function loadFonts() { #region f_sdf = _f_sdf; f_sdf_medium = _f_sdf_medium; FONT_ISLOADED = false; + + __font_refresh(); return; } @@ -157,6 +186,8 @@ function loadFonts() { #region f_sdf_medium = _font_load_from_struct(fontDef, "sdf_medium", _f_sdf_medium); FONT_ISLOADED = true; + + __font_refresh(); } #endregion #region unused font cache diff --git a/scripts/function_register/function_register.gml b/scripts/function_register/function_register.gml index abca394d5..7b98243ef 100644 --- a/scripts/function_register/function_register.gml +++ b/scripts/function_register/function_register.gml @@ -11,8 +11,8 @@ } function __fnInit() { - globalvar FUNCTIONS; - FUNCTIONS = {}; + globalvar CMD_FUNCTIONS; + CMD_FUNCTIONS = {}; __registerFunction("new", NEW); __registerFunction("save", SAVE_AT, [ ARG("project", function() { return PROJECT; }, true), ARG("path", ""), ARG("log", "save at ") ]); @@ -34,7 +34,7 @@ function __registerFunction(name, fn, args = []) { #region INLINE - FUNCTIONS[$ name] = { fn, args }; + CMD_FUNCTIONS[$ name] = { fn, args }; } #endregion function callStatusFunction(name) { #region @@ -48,7 +48,7 @@ function callStatusFunction(name) { #region function callFunction(name, args) { #region INLINE - var _f = FUNCTIONS[$ name]; + var _f = CMD_FUNCTIONS[$ name]; switch(array_length(_f.args)) { case 0 : _f.fn(); break; diff --git a/scripts/node_armature/node_armature.gml b/scripts/node_armature/node_armature.gml index 7b42b1fb6..cceec9b7c 100644 --- a/scripts/node_armature/node_armature.gml +++ b/scripts/node_armature/node_armature.gml @@ -437,12 +437,14 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo builder_sx = smx; builder_sy = smy; UNDO_HOLDING = true; + } else if(anchor_selecting[1] == 1) { builder_bone = createBone(anchor_selecting[0], 0, 0); builder_type = 1; builder_sx = smx; builder_sy = smy; UNDO_HOLDING = true; + } else if(anchor_selecting[1] == 2) { var _pr = anchor_selecting[0]; recordAction(ACTION_TYPE.struct_modify, attributes.bones, attributes.bones.serialize()); @@ -457,6 +459,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo _pr.addChild(_md); UNDO_HOLDING = true; + triggerRender(); } } diff --git a/scripts/node_armature_bind/node_armature_bind.gml b/scripts/node_armature_bind/node_armature_bind.gml index 19b5bba96..c4964c3d7 100644 --- a/scripts/node_armature_bind/node_armature_bind.gml +++ b/scripts/node_armature_bind/node_armature_bind.gml @@ -1,3 +1,13 @@ +function __armature_bind_data(_surface, _bone, _tran, _aang, _pang, _asca, _psca) constructor { + surface = new Surface(_surface); + bone = _bone.ID; + transform = _tran; + applyRot = _aang; + applyRotl = _pang; + applySca = _asca; + applyScal = _psca; +} + function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Armature Bind"; @@ -60,6 +70,8 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var index = -1; var amo = min(ds_list_size(inputs) - data_length, array_length(current_data)); + var _bind = getSingleValue(2); + var use_data = _bind != noone; for(var i = input_fix_len; i < amo; i += data_length) { index++; @@ -186,10 +198,12 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var amo = floor((ds_list_size(inputs) - input_fix_len) / data_length) - 1; if(array_length(current_data) != ds_list_size(inputs)) return 0; - var ty = _y + bh + ui(8); + if(use_data) { + layer_renderer.h = bh + ui(8); + return layer_renderer.h; + } - //draw_set_color(COLORS.node_composite_separator); - //draw_line(_x + 16, ty - ui(4), _x + _w - 16, ty - ui(4)); + var ty = _y + bh + ui(8); draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); draw_text_add(_x + ui(16), ty + ui(4), __txt("Surfaces")); @@ -445,21 +459,6 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr return input_fix_len + (index - input_fix_len) * data_length; } #endregion - static setHeight = function() { #region - var _hi = ui(32); - var _ho = ui(32); - - for( var i = 0; i < getInputAmount(); i++ ) - if(inputs[| getInputIndex(i)].isVisible()) - _hi += 24; - - for( var i = 0; i < ds_list_size(outputs); i++ ) - if(outputs[| i].isVisible()) - _ho += 24; - - h = max(min_h, (preview_surface && previewable)? 128 : 0, _hi, _ho); - } #endregion - static onValueFromUpdate = function(index) { #region if(LOADING || APPENDING) return; @@ -803,22 +802,31 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var bg = 0; var imageAmo = use_data? array_length(_bind) : (ds_list_size(inputs) - input_fix_len) / data_length; var _vis = attributes.layer_visible; - var _bg = 0; + var _bg = 0, _s; for(var i = 0; i < imageAmo; i++) { var vis = array_safe_get_fast(_vis, i, true); if(!vis) continue; var datInd = input_fix_len + i * data_length; - var _s = use_data? _bind[i].getSurface() : _data[datInd]; + _s = noone; + + if(use_data) { + var _bindData = array_safe_get(_bind, i); + if(is_instanceof(_bindData, __armature_bind_data)) + _s = _bindData.surface.get(); + + } else { + _s = array_safe_get(_data, datInd); + } + if(!is_surface(_s)) continue; var _b = use_data? _bind[i].bone : inputs[| datInd].display_data.bone_id; - if(!ds_map_exists(boneMap, _b)) { - //print($"Bone not exist {_bone} from map {ds_map_size(boneMap)}") + if(!ds_map_exists(boneMap, _b)) continue; - } + _b = boneMap[? _b]; var _tran = use_data? _bind[i].transform : _data[datInd + 1]; @@ -848,15 +856,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr ]; array_push(atlas_data, new SurfaceAtlas(_s, _pos[0], _pos[1], _rot, _sca[0], _sca[1])); - array_push(bind_data, { - surface: new Surface(_s), - bone: _b.ID, - transform: _tran, - applyRot: _aang, - applyRotl: _pang, - applySca: _asca, - applyScal: _psca, - }); + array_push(bind_data, new __armature_bind_data(_s, _b, _tran, _aang, _pang, _asca, _psca)); surface_set_shader(temp_surface[_bg], sh_sample, true, BLEND.alphamulp); blend_temp_surface = temp_surface[2]; diff --git a/scripts/node_armature_pose/node_armature_pose.gml b/scripts/node_armature_pose/node_armature_pose.gml index ce5c949d5..7810299f0 100644 --- a/scripts/node_armature_pose/node_armature_pose.gml +++ b/scripts/node_armature_pose/node_armature_pose.gml @@ -135,7 +135,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const var ss = point_distance(posing_mx, posing_my, smx, smy) / posing_sx; var ori = posing_bone.getPoint(0); var ang = point_direction(ori.x, ori.y, smx, smy); - var rot = ang - posing_sy; + var rot = ang - posing_sy - posing_bone.parent.pose_angle; var val = array_clone(posing_input.getValue()); val[TRANSFORM.sca_x] = ss; @@ -190,7 +190,7 @@ function Node_Armature_Pose(_x, _y, _group = noone) : Node(_x, _y, _group) const var ori = posing_bone.getPoint(0); var val = posing_input.getValue(); - posing_sx = posing_bone.length / posing_bone.pose_local_scale; + posing_sx = posing_bone.length / posing_bone.pose_scale * posing_bone.parent.pose_scale; posing_sy = posing_bone.angle - posing_bone.pose_local_angle; posing_sz = point_direction(ori.x, ori.y, smx, smy); diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index 0f0a55cfc..4a29e8f63 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -458,6 +458,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static getTool = function() { #region for(var i = 0; i < node_length; i++) { var _node = nodes[| i]; + if(!_node.active) continue; if(_node.isTool) return _node.getTool(); } diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index ca241d040..433e59176 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1103,11 +1103,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { } #endregion static drawJunctionWidget = function(_x, _y, _mx, _my, _s, _hover, _focus) { #region - if(!active) return; + var hover = noone; var wh = junction_draw_hei_y * _s; var ww = w * _s * 0.5; + var wt = w * _s * 0.25; var wx = _x + w * _s - ww - 8; var lx = _x + 12 * _s; @@ -1120,6 +1121,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { var boundH = _x > draw_boundary[0] - w * _s && _x < draw_boundary[2]; var boundV = 1;//_y > draw_boundary[1] - h * _s && _y < draw_boundary[3]; var extY = 0; + var drawText = _s > 0.5; for(var i = 0, n = array_length(inputDisplayList); i < n; i++) { var jun = inputDisplayList[i]; @@ -1127,8 +1129,14 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { jun.y = jy; - draw_set_text(f_sdf, fa_left, fa_center, jun.color_display); - draw_text_add(lx, jun.y, jun.getName(), _s * 0.25); + if(drawText) { + draw_set_text(f_sdf, fa_left, fa_center, jun.color_display); + draw_text_add(lx, jun.y, jun.getName(), _s * 0.25); + + } else { + draw_set_color(jun.color_display); + draw_rectangle(lx, jun.y - 1 * _s, lx + wt, jun.y + 4 * _s, false); + } if(jun.value_from || wd == noone) { jy += wh; @@ -1180,6 +1188,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { for(var i = 0; i < ds_list_size(outputs); i++) { var jun = outputs[| i]; + if(!jun.isVisible()) continue; if(jun.drawJunction(_s, _mx, _my)) hover = jun; @@ -1649,6 +1658,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { outputs[| i].destroy(); onDestroy(); + if(group) group.refreshNodes(); RENDER_ALL_REORDER } #endregion @@ -1657,6 +1667,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(active) return; enable(); ds_list_add(group == noone? PROJECT.nodes : group.getNodeList(), self); + if(group) group.refreshNodes(); RENDER_ALL_REORDER } #endregion diff --git a/scripts/node_feedback_inline/node_feedback_inline.gml b/scripts/node_feedback_inline/node_feedback_inline.gml index 66bafbfdd..8871afd33 100644 --- a/scripts/node_feedback_inline/node_feedback_inline.gml +++ b/scripts/node_feedback_inline/node_feedback_inline.gml @@ -56,7 +56,10 @@ function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) con } #endregion static getValue = function() { #region - return [ value_buffer, junc_out ]; + INLINE + + arr[@ 0] = value_buffer; + arr[@ 1] = junc_out; } #endregion static drawConnections = function(params = {}) { #region diff --git a/scripts/node_feedback_input/node_feedback_input.gml b/scripts/node_feedback_input/node_feedback_input.gml index aa04536d7..2b1dfc6cb 100644 --- a/scripts/node_feedback_input/node_feedback_input.gml +++ b/scripts/node_feedback_input/node_feedback_input.gml @@ -5,7 +5,7 @@ function Node_Feedback_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y, setDimension(96, 32 + 24 * 2); outputs[| 0].getValueDefault = method(outputs[| 0], outputs[| 0].getValueRecursive); //Get value from outside loop - outputs[| 0].getValueRecursive = function(_time) { + outputs[| 0].getValueRecursive = function(arr, _time) { var _node_output = noone; for( var i = 0; i < array_length(outputs[| 1].value_to); i++ ) { var vt = outputs[| 1].value_to[i]; @@ -13,10 +13,13 @@ function Node_Feedback_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y, _node_output = vt; } - if(CURRENT_FRAME > 0 && _node_output != noone && _node_output.node.cache_value != noone) //use cache from output - return [ _node_output.node.cache_value, inParent ]; + if(CURRENT_FRAME > 0 && _node_output != noone && _node_output.node.cache_value != noone) { //use cache from output + arr[@ 0] = _node_output.node.cache_value; + arr[@ 1] = inParent; + return; + } - return outputs[| 0].getValueDefault(); + outputs[| 0].getValueDefault(arr); } outputs[| 1] = nodeValue("Feedback loop", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, 0).nonForward(); diff --git a/scripts/node_functions/node_functions.gml b/scripts/node_functions/node_functions.gml index c3fb9f51b..abf83d63d 100644 --- a/scripts/node_functions/node_functions.gml +++ b/scripts/node_functions/node_functions.gml @@ -206,7 +206,10 @@ if(array_length(strs) == 1) { var splt = string_splice(strs[0], "["); var inp = PROJECT.globalNode.getInput(strs[0]); - return inp == noone? 0 : inp.getValueRecursive()[0]; + if(inp == 0) return 0; + + return inp.getValueRecursive([ 0, 0 ])[0]; + } else if(struct_has(PROJECT_VARIABLES, strs[0])) { var _str_var = PROJECT_VARIABLES[$ strs[0]]; if(!struct_has(_str_var, strs[1])) return 0; diff --git a/scripts/node_iterate_inline/node_iterate_inline.gml b/scripts/node_iterate_inline/node_iterate_inline.gml index 7adf601cf..95cc85cea 100644 --- a/scripts/node_iterate_inline/node_iterate_inline.gml +++ b/scripts/node_iterate_inline/node_iterate_inline.gml @@ -71,8 +71,11 @@ function Node_Iterate_Inline(_x, _y, _group = noone) : Node_Collection_Inline(_x } } #endregion - static getValue = function() { #region - return [ value_buffer, junc_out ]; + static getValue = function(arr) { #region + INLINE + + arr[@ 0] = value_buffer; + arr[@ 1] = junc_out; } #endregion static update = function() { #region diff --git a/scripts/node_iterator_each_input/node_iterator_each_input.gml b/scripts/node_iterator_each_input/node_iterator_each_input.gml index 5af060df3..79c5c0859 100644 --- a/scripts/node_iterator_each_input/node_iterator_each_input.gml +++ b/scripts/node_iterator_each_input/node_iterator_each_input.gml @@ -9,15 +9,16 @@ function Node_Iterator_Each_Input(_x, _y, _group = noone) : Node(_x, _y, _group) outputs[| 0].getValueDefault = method(outputs[| 0], outputs[| 0].getValueRecursive); //Get value from outside loop - outputs[| 0].getValueRecursive = function() { + outputs[| 0].getValueRecursive = function(arr) { if(!variable_struct_exists(group, "iterated")) - return outputs[| 0].getValueDefault(); + return outputs[| 0].getValueDefault(arr); var ind = group.iterated; var val = group.getInputData(0); var ivl = array_safe_get_fast(val, ind); - return [ ivl, group.inputs[| 0] ]; + arr[@ 0] = ivl; + arr[@ 1] = group.inputs[| 0]; } static step = function() { diff --git a/scripts/node_iterator_filter_input/node_iterator_filter_input.gml b/scripts/node_iterator_filter_input/node_iterator_filter_input.gml index e1dae5917..32dee4847 100644 --- a/scripts/node_iterator_filter_input/node_iterator_filter_input.gml +++ b/scripts/node_iterator_filter_input/node_iterator_filter_input.gml @@ -7,14 +7,15 @@ function Node_Iterator_Filter_Input(_x, _y, _group = noone) : Node(_x, _y, _grou outputs[| 0] = nodeValue("Value in", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0 ); outputs[| 0].getValueDefault = method(outputs[| 0], outputs[| 0].getValueRecursive); //Get value from outside loop - outputs[| 0].getValueRecursive = function() { #region + outputs[| 0].getValueRecursive = function(arr) { #region if(!variable_struct_exists(group, "iterated")) - return outputs[| 0].getValueDefault(); + return outputs[| 0].getValueDefault(arr); var ind = group.iterated; var val = group.getInputData(0); - return [ array_safe_get_fast(val, ind), group.inputs[| 0] ]; + arr[@ 0] = array_safe_get_fast(val, ind) + arr[@ 1] = group.inputs[| 0]; } #endregion static step = function() { #region diff --git a/scripts/node_iterator_input/node_iterator_input.gml b/scripts/node_iterator_input/node_iterator_input.gml index 509e4892c..306b1020b 100644 --- a/scripts/node_iterator_input/node_iterator_input.gml +++ b/scripts/node_iterator_input/node_iterator_input.gml @@ -9,26 +9,31 @@ function Node_Iterator_Input(_x, _y, _group = noone) : Node_Group_Input(_x, _y, outputs[| 0].getValueDefault = method(outputs[| 0], outputs[| 0].getValueRecursive); //Get value from outside loop - outputs[| 0].getValueRecursive = function() { + outputs[| 0].getValueRecursive = function(arr) { if(!struct_has(group, "iterated")) - return outputs[| 0].getValueDefault(); + return outputs[| 0].getValueDefault(arr); var _to = outputs[| 1].getJunctionTo(); // Not connect to any loop output - if(array_empty(_to)) - return [ noone, inParent ]; + if(array_empty(_to)) { + arr[@ 0] = noone; + arr[@ 1] = inParent; + return; + } var _node_output = _to[0]; // First iteration, get value from outside if(_node_output == noone || group.iterated == 0) { - var _def = outputs[| 0].getValueDefault(); - return [ variable_clone(_def[0]), _def[1] ]; + outputs[| 0].getValueDefault(arr); + arr[@ 0] = variable_clone(arr[@ 0]); + return; } // Later iteration, get value from output - return [ _node_output.node.cache_value, inParent ]; + arr[@ 0] = _node_output.node.cache_value; + arr[@ 1] = inParent; } outputs[| 1] = nodeValue("Loop entrance", self, JUNCTION_CONNECT.output, VALUE_TYPE.node, 0) diff --git a/scripts/node_keyframe/node_keyframe.gml b/scripts/node_keyframe/node_keyframe.gml index bb9138c9e..ba32cd1e3 100644 --- a/scripts/node_keyframe/node_keyframe.gml +++ b/scripts/node_keyframe/node_keyframe.gml @@ -90,8 +90,10 @@ function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor { function valueAnimator(_val, _prop, _sep_axis = false) constructor { #region ---- main ---- - suffix = ""; - values = ds_list_create(); + suffix = ""; + values = ds_list_create(); + //staticValue = 0; + length = 1; sep_axis = _sep_axis; @@ -259,6 +261,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { static getName = function() { return prop.name + suffix; } static getValue = function(_time = CURRENT_FRAME) { #region + //if(!prop.is_anim) return staticValue; ///////////////////////////////////////////////////////////// TRIGGER TYPE ///////////////////////////////////////////////////////////// @@ -515,6 +518,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { } #endregion static setValue = function(_val = 0, _record = true, _time = CURRENT_FRAME, ease_in = 0, ease_out = 0) { #region + //staticValue = _val; if(prop.type == VALUE_TYPE.trigger) { if(!prop.is_anim) { @@ -718,6 +722,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { ds_list_add(values, vk); } + //staticValue = ds_list_empty(values)? 0 : values[| 0].value; updateKeyMap(); } #endregion diff --git a/scripts/node_line/node_line.gml b/scripts/node_line/node_line.gml index e220adca6..883ae845a 100644 --- a/scripts/node_line/node_line.gml +++ b/scripts/node_line/node_line.gml @@ -263,7 +263,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons //print($"===== {_prog_curr} / {_segLength} : {_segIndex} - {_pathLength} ====="); - while(_total >= 0) { + while(_total > 0) { wght = 1; _segIndexPrev = _segIndex; @@ -339,6 +339,8 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons if(_total_prev == _total && _segIndexPrev == _segIndex && ++_freeze > 16) { print("Terminate line not moving"); break; } _total_prev = _total; + + if(_segIndex >= _segLengthAmo) break; } array_resize(points, pointAmo); diff --git a/scripts/node_noise_simplex/node_noise_simplex.gml b/scripts/node_noise_simplex/node_noise_simplex.gml index af5cc19d1..df9ce715e 100644 --- a/scripts/node_noise_simplex/node_noise_simplex.gml +++ b/scripts/node_noise_simplex/node_noise_simplex.gml @@ -78,7 +78,7 @@ function Node_Noise_Simplex(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr surface_set_shader(_outSurf, sh_simplex); shader_set_f("dimension", _dim); shader_set_f("position", _pos); - shader_set_f("rotation", radtodeg(_ang)); + shader_set_f("rotation", degtorad(_ang)); shader_set_f_map("scale", _data[2], _data[8], inputs[| 2]); shader_set_f_map("iteration", _data[3], _data[9], inputs[| 3]); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 29d29d8ba..7b162a2d1 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -635,6 +635,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru node.inputs_data[index] = _value; node.input_value_map[$ internalName] = _value; + __curr_get_val = [ 0, 0 ]; #endregion #region ---- draw ---- @@ -1456,7 +1457,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru static valueProcess = function(value, nodeFrom, applyUnit = true, arrIndex = 0) { #region var typeFrom = nodeFrom.type; - var display = nodeFrom.display_type; #region color compatibility [ color, palette, gradient ] if(type == VALUE_TYPE.gradient && typeFrom == VALUE_TYPE.color) { @@ -1589,7 +1589,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(type == VALUE_TYPE.trigger) useCache = false; - global.cache_call++; + //global.cache_call++; if(useCache && use_cache) { var cache_hit = cache_value[0]; cache_hit &= !isActiveDynamic(_time) || cache_value[1] == _time; @@ -1599,12 +1599,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cache_hit &= unit.reference == noone || unit.mode == VALUE_UNIT.constant; if(cache_hit) { - //print($"Get cache {name} = {cache_value[2]}"); - - global.cache_hit++; + //global.cache_hit++; return cache_value[2]; } - } var val = _getValue(_time, applyUnit, arrIndex, log); @@ -1623,9 +1620,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cache_value[1] = _time; } - cache_value[2] = variable_clone(val, 1); + cache_value[2] = val; cache_value[3] = applyUnit; - updateColor(val); + + if(!IS_PLAYING) updateColor(val); return val; } #endregion @@ -1643,7 +1641,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru for( var i = 0, n = array_length(animators); i < n; i++ ) val[i] = animators[i].values[| 0].value; return val; - } + } if(ds_list_empty(animator.values)) return 0; @@ -1683,9 +1681,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } #endregion static _getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, log = false) { #region - var _val = getValueRecursive(_time); - var val = _val[0]; - var nod = _val[1]; + + getValueRecursive(self.__curr_get_val, _time); + var val = __curr_get_val[0]; + var nod = __curr_get_val[1]; + var typ = nod.type; var dis = nod.display_type; @@ -1741,18 +1741,22 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return valueProcess(val, nod, applyUnit, arrIndex); } #endregion - static getValueRecursive = function(_time = CURRENT_FRAME) { #region + static getValueRecursive = function(arr = __curr_get_val, _time = CURRENT_FRAME) { #region - if(type == VALUE_TYPE.trigger && connect_type == JUNCTION_CONNECT.output) //trigger event will not propagate from input to output, need to be done manually - return [ ds_list_empty(animator.values)? 0 : animator.values[| 0].value, self ]; + if(type == VALUE_TYPE.trigger && connect_type == JUNCTION_CONNECT.output) { //trigger event will not propagate from input to output, need to be done manually + arr[@ 0] = ds_list_empty(animator.values)? 0 : animator.values[| 0].value; + arr[@ 1] = self; + return; + } - var val = [ __getAnimValue(_time), self ]; + arr[@ 0] = __getAnimValue(_time); + arr[@ 1] = self; if(value_from_loop && value_from_loop.bypassConnection() && value_from_loop.junc_out) - val = value_from_loop.getValue(_time); + value_from_loop.getValue(arr); else if(value_from && value_from != self) - val = value_from.getValueRecursive(_time); + value_from.getValueRecursive(arr, _time); if(expUse && is_struct(expTree) && expTree.validate()) { @@ -1763,27 +1767,23 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru global.EVALUATE_HEAD = self; expContext = { - name: name, - node_name: node.display_name, - value: val[0], - node_values: node.input_value_map, + name : name, + node_name : node.display_name, + value : arr[0], + node_values : node.input_value_map, }; var _exp_res = expTree.eval(variable_clone(expContext)); printIf(global.LOG_EXPRESSION, $">>>> Result = {_exp_res}"); if(is_undefined(_exp_res)) { - val[0] = 0; + arr[@ 0] = 0; noti_warning("Expression not returning valid values."); } else - val[0] = _exp_res; + arr[@ 0] = _exp_res; global.EVALUATE_HEAD = noone; } - - return val; } - - return val; } #endregion static setAnim = function(anim, record = false) { #region diff --git a/scripts/obj_reader/obj_reader.gml b/scripts/obj_reader/obj_reader.gml index cdd227999..486eff29c 100644 --- a/scripts/obj_reader/obj_reader.gml +++ b/scripts/obj_reader/obj_reader.gml @@ -34,18 +34,18 @@ function readObj_file() { switch(sep[0]) { case "v" : - ds_list_add(v, [ toNumberFast(sep[1]), toNumberFast(sep[2]), toNumberFast(sep[3]) ]); + ds_list_add(v, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]); break; case "vt" : - var _u = toNumberFast(sep[1]); - var _v = toNumberFast(sep[2]); + var _u = toNumber(sep[1]); + var _v = toNumber(sep[2]); ds_list_add(vt, [ _u, _v ]); break; case "vn" : - var _nx = toNumberFast(sep[1]); - var _ny = toNumberFast(sep[2]); - var _nz = toNumberFast(sep[3]); + var _nx = toNumber(sep[1]); + var _ny = toNumber(sep[2]); + var _nz = toNumber(sep[3]); //var _di = sqrt(_nx * _nx + _ny * _ny + _nz * _nz); //_nx /= _di; @@ -64,9 +64,9 @@ function readObj_file() { var _sp = string_split(sep[i], "/"); if(array_length(_sp) < 2) continue; - _f[i - 1] = toNumberFast(_sp[0]); - _ft[i - 1] = toNumberFast(_sp[1]); - _fn[i - 1] = toNumberFast(_sp[2]); + _f[i - 1] = toNumber(_sp[0]); + _ft[i - 1] = toNumber(_sp[1]); + _fn[i - 1] = toNumber(_sp[2]); if(array_length(_sp) < 3) use_normal = false; } diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index d82f537d8..64a45e17a 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -599,7 +599,7 @@ function Panel_Animation() : PanelContent() constructor { if(inspecting) inspecting.drawAnimationTimeline(timeline_shift, bar_w, bar_h, timeline_scale); - var _fr = ceil(bar_w / timeline_scale / timeline_separate) * timeline_separate; + var _fr = ceil((bar_w / timeline_scale - timeline_shift) / timeline_separate) * timeline_separate; for(var i = timeline_separate; i <= _fr; i += timeline_separate) { var bar_line_x = i * timeline_scale + timeline_shift; @@ -1582,7 +1582,7 @@ function Panel_Animation() : PanelContent() constructor { dope_sheet_y_max = max(0, dope_sheet_y_max - dope_sheet_h + ui(48)); - var _fr = ceil(bar_w / timeline_scale / timeline_separate) * timeline_separate; + var _fr = ceil((bar_w / timeline_scale - timeline_shift) / timeline_separate) * timeline_separate; for(var i = timeline_sep_line; i <= _fr; i += timeline_sep_line) { var bar_line_x = i * timeline_scale + timeline_shift; @@ -1827,7 +1827,7 @@ function Panel_Animation() : PanelContent() constructor { draw_set_color(COLORS.panel_animation_timeline_top); draw_rectangle(0, 0, bar_w, hh, false); - var _fr = ceil(bar_w / timeline_scale / timeline_separate) * timeline_separate; + var _fr = ceil((bar_w / timeline_scale - timeline_shift) / timeline_separate) * timeline_separate; for(var i = timeline_separate; i <= _fr; i += timeline_separate) { var bar_line_x = i * timeline_scale + timeline_shift; @@ -1926,7 +1926,7 @@ function Panel_Animation() : PanelContent() constructor { if(timeline_stretch == 1) { var len = round((mx - bar_x - timeline_shift) / timeline_scale) - 2; - len = max(1, len); + len = max(1, len); TOOLTIP = __txtx("panel_animation_length", "Animation length") + " " + string(len); TOTAL_FRAMES = len; @@ -1934,10 +1934,11 @@ function Panel_Animation() : PanelContent() constructor { timeline_stretch = 0; draw_sprite_ui(THEME.animation_stretch, 0, stx, sty, 1, 1, 0, COLORS.panel_animation_end_line, 1); + } else if(timeline_stretch == 2) { - var len = round((mx - bar_x - timeline_shift) / timeline_scale) - 2; - len = max(1, len); - TOOLTIP = __txtx("panel_animation_length", "Animation length") + " " + string(len); + var len = round((mx - bar_x - timeline_shift) / timeline_scale) - 2; + len = max(1, len); + TOOLTIP = __txtx("panel_animation_length", "Animation length") + " " + string(len); var _len = TOTAL_FRAMES; TOTAL_FRAMES = len; @@ -1970,6 +1971,7 @@ function Panel_Animation() : PanelContent() constructor { timeline_stretch = 0; draw_sprite_ui(THEME.animation_stretch, 1, stx, sty, 1, 1, 0, COLORS.panel_animation_end_line, 1); + } else { if(!IS_PLAYING && pHOVER && point_in_circle(msx, msy, stx, sty, sty)) { if(key_mod_press(CTRL)) { @@ -2027,21 +2029,19 @@ function Panel_Animation() : PanelContent() constructor { } #endregion function drawAnimationControl() { #region - var bx = ui(8); - var by = h - ui(40); var mini = w < ui(348); - if(mini) by = h - ui(40); - var amo = array_length(control_buttons); var col = floor((w - ui(8)) / ui(36)); var row = ceil(amo / col); if(col < 1) return; + var bx = tool_width / 2 - ui(36) * amo / 2 + ui(8); + var by = h - ui(40); + for( var i = 0; i < row; i++ ) { var colAmo = min(amo - i * col, col); - if(mini) - bx = w / 2 - ui(36) * colAmo / 2; + if(mini) bx = w / 2 - ui(36) * colAmo / 2; for( var j = 0; j < colAmo; j++ ) { var ind = i * col + j; @@ -2108,6 +2108,7 @@ function Panel_Animation() : PanelContent() constructor { if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, __txtx("panel_animation_scale_animation", "Scale animation"), THEME.animation_timing, 2) == 2) dialogPanelCall(new Panel_Animation_Scaler(), x + bx + ui(32), y + by - ui(8), { anchor: ANCHOR.right | ANCHOR.bottom }); + var max_y = by - ui(28); if(by < ui(28)) return; by = ui(8); @@ -2117,23 +2118,23 @@ function Panel_Animation() : PanelContent() constructor { PROJECT.timelines.addItem(_dir); } - by += ui(32); + by += ui(32); if(by > max_y) return; node_name_tooltip.index = node_name_type; if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(28), [mx, my], pFOCUS, pHOVER, node_name_tooltip, THEME.node_name_type, node_name_type) == 2) node_name_type = (node_name_type + 1) % 3; - by += ui(32); + by += ui(32); if(by > max_y) return; txt = __txtx("panel_animation_show_node", "Toggle node label"); if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(28), [mx, my], pFOCUS, pHOVER, txt, THEME.junc_visible, show_nodes) == 2) show_nodes = !show_nodes; - by += ui(32); + by += ui(32); if(by > max_y) return; txt = __txtx("panel_animation_keyframe_override", "Override Keyframe"); if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(28), [mx, my], pFOCUS, pHOVER, txt, THEME.keyframe_override, global.FLAG.keyframe_override) == 2) global.FLAG.keyframe_override = !global.FLAG.keyframe_override; - by += ui(32); + by += ui(32); if(by > max_y) return; txt = __txt("Onion skin"); if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(28), [mx, my], pFOCUS, pHOVER, txt, THEME.onion_skin,, PROJECT.onion_skin.enabled? c_white : COLORS._main_icon) == 2) PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled; @@ -2161,7 +2162,7 @@ function Panel_Animation() : PanelContent() constructor { if(dope_sheet_h > 8) { drawDopesheet(); - if(pHOVER && point_in_rectangle(mx, my, tool_width + ui(10), ui(8), tool_width + ui(12), ui(8) + dope_sheet_h)) { + if(pHOVER && point_in_rectangle(mx, my, tool_width + ui(8), ui(8), tool_width + ui(12), ui(8) + dope_sheet_h)) { CURSOR = cr_size_we; if(mouse_press(mb_left, pFOCUS)) { tool_width_drag = true; @@ -2174,7 +2175,7 @@ function Panel_Animation() : PanelContent() constructor { drawAnimationControl(); if(timeline_show_time > -1) { - TOOLTIP = __txt("Frame") + " " + string(timeline_show_time + 1) + "/" + string(TOTAL_FRAMES); + TOOLTIP = $"{__txt("Frame")} {timeline_show_time + 1}/{TOTAL_FRAMES}"; timeline_show_time = -1; } } #endregion diff --git a/scripts/pcx_ast/pcx_ast.gml b/scripts/pcx_ast/pcx_ast.gml index 1ddc89f0f..986c0ce77 100644 --- a/scripts/pcx_ast/pcx_ast.gml +++ b/scripts/pcx_ast/pcx_ast.gml @@ -1,72 +1,72 @@ #region data global.EVALUATE_HEAD = noone; - global.FUNCTIONS = ds_map_create(); - global.FUNCTIONS[? "sin"] = [ ["radian"], function(val) { return sin(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "cos"] = [ ["radian"], function(val) { return cos(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "tan"] = [ ["radian"], function(val) { return tan(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS = ds_map_create(); + global.PCX_FUNCTIONS[? "sin"] = [ ["radian"], function(val) { return sin(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "cos"] = [ ["radian"], function(val) { return cos(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "tan"] = [ ["radian"], function(val) { return tan(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "dsin"] = [ ["degree"], function(val) { return dsin(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "dcos"] = [ ["degree"], function(val) { return dcos(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "dtan"] = [ ["degree"], function(val) { return dtan(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "dsin"] = [ ["degree"], function(val) { return dsin(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "dcos"] = [ ["degree"], function(val) { return dcos(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "dtan"] = [ ["degree"], function(val) { return dtan(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "arcsin"] = [ ["x"], function(val) { return arcsin(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "arccos"] = [ ["x"], function(val) { return arccos(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "arctan"] = [ ["x"], function(val) { return arctan(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "arctan2"] = [ ["y", "x"], function(val) { return arctan2(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; + global.PCX_FUNCTIONS[? "arcsin"] = [ ["x"], function(val) { return arcsin(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "arccos"] = [ ["x"], function(val) { return arccos(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "arctan"] = [ ["x"], function(val) { return arctan(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "arctan2"] = [ ["y", "x"], function(val) { return arctan2(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; - global.FUNCTIONS[? "darcsin"] = [ ["x"], function(val) { return darcsin(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "darccos"] = [ ["x"], function(val) { return darccos(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "darctan"] = [ ["x"], function(val) { return darctan(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "darctan2"] = [ ["y", "x"], function(val) { return darctan2(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; + global.PCX_FUNCTIONS[? "darcsin"] = [ ["x"], function(val) { return darcsin(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "darccos"] = [ ["x"], function(val) { return darccos(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "darctan"] = [ ["x"], function(val) { return darctan(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "darctan2"] = [ ["y", "x"], function(val) { return darctan2(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; - global.FUNCTIONS[? "abs"] = [ ["x"], function(val) { return abs(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "round"] = [ ["x"], function(val) { return round(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "ceil"] = [ ["x"], function(val) { return ceil(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "floor"] = [ ["x"], function(val) { return floor(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "fract"] = [ ["x"], function(val) { return frac(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "sign"] = [ ["x"], function(val) { return sign(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "abs"] = [ ["x"], function(val) { return abs(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "round"] = [ ["x"], function(val) { return round(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "ceil"] = [ ["x"], function(val) { return ceil(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "floor"] = [ ["x"], function(val) { return floor(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "fract"] = [ ["x"], function(val) { return frac(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "sign"] = [ ["x"], function(val) { return sign(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "min"] = [ ["x", "y"], function(val) { return min(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; - global.FUNCTIONS[? "max"] = [ ["x", "y"], function(val) { return max(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; - global.FUNCTIONS[? "clamp"] = [ ["x", "min = 0", "max = 1"], function(val) { return clamp(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1, 0), array_safe_get_fast(val, 2, 1)); } ]; + global.PCX_FUNCTIONS[? "min"] = [ ["x", "y"], function(val) { return min(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; + global.PCX_FUNCTIONS[? "max"] = [ ["x", "y"], function(val) { return max(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1)); } ]; + global.PCX_FUNCTIONS[? "clamp"] = [ ["x", "min = 0", "max = 1"], function(val) { return clamp(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1, 0), array_safe_get_fast(val, 2, 1)); } ]; - global.FUNCTIONS[? "lerp"] = [ ["x", "y", "amount"], function(val) { return lerp(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1), array_safe_get_fast(val, 2)); } ]; + global.PCX_FUNCTIONS[? "lerp"] = [ ["x", "y", "amount"], function(val) { return lerp(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1), array_safe_get_fast(val, 2)); } ]; - global.FUNCTIONS[? "wiggle"] = [ ["time", "frequency", "octave = 1", "seed = 0"], function(val) { + global.PCX_FUNCTIONS[? "wiggle"] = [ ["time", "frequency", "octave = 1", "seed = 0"], function(val) { return wiggle(0, 1, TOTAL_FRAMES / array_safe_get_fast(val, 1), array_safe_get_fast(val, 0), array_safe_get_fast(val, 3, 0), array_safe_get_fast(val, 2, 1)); } ]; - global.FUNCTIONS[? "random"] = [ ["min = 0", "max = 1"], function(val) { + global.PCX_FUNCTIONS[? "random"] = [ ["min = 0", "max = 1"], function(val) { return random_range(array_safe_get_fast(val, 0, 0), array_safe_get_fast(val, 1, 1)); } ]; - global.FUNCTIONS[? "irandom"] = [ ["min = 0", "max = 1"], function(val) { + global.PCX_FUNCTIONS[? "irandom"] = [ ["min = 0", "max = 1"], function(val) { return irandom_range(array_safe_get_fast(val, 0, 0), array_safe_get_fast(val, 1, 1)); } ]; - global.FUNCTIONS[? "range"] = [ ["length", "start = 0", "step = 1"], function(val) { + global.PCX_FUNCTIONS[? "range"] = [ ["length", "start = 0", "step = 1"], function(val) { var arr = array_create(array_safe_get_fast(val, 0, 0)); for( var i = 0, n = array_length(arr); i < n; i++ ) arr[i] = array_safe_get_fast(val, 1, 0) + i * array_safe_get_fast(val, 2, 1); return arr; } ]; - global.FUNCTIONS[? "length"] = [ ["value"], function(val) { + global.PCX_FUNCTIONS[? "length"] = [ ["value"], function(val) { if(is_array(val)) return array_length(val); if(is_string(val)) return string_length(val); return 0; } ]; - global.FUNCTIONS[? "string"] = [ ["value"], function(val) { return string(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "number"] = [ ["value"], function(val) { return toNumber(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "chr"] = [ ["x"], function(val) { return chr(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "ord"] = [ ["char"], function(val) { return ord(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "string"] = [ ["value"], function(val) { return string(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "number"] = [ ["value"], function(val) { return toNumber(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "chr"] = [ ["x"], function(val) { return chr(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "ord"] = [ ["char"], function(val) { return ord(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "draw"] = [ ["surface", "x = 0", "y = 0", "xs = 1", "ys = 1", "rot = 0", "color = white", "alpha = 1"], + global.PCX_FUNCTIONS[? "draw"] = [ ["surface", "x = 0", "y = 0", "xs = 1", "ys = 1", "rot = 0", "color = white", "alpha = 1"], function(val) { var _surface = array_safe_get_fast(val, 0, -1); if(!is_surface(_surface)) return false; @@ -82,13 +82,13 @@ return true; } ]; - global.FUNCTIONS[? "surface_get_dimension"] = [ ["surface"], function(val) { var s = array_safe_get_fast(val, 0); return [ surface_get_width_safe(s), surface_get_height_safe(s) ]; } ]; - global.FUNCTIONS[? "surface_get_width"] = [ ["surface"], function(val) { return surface_get_width_safe(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "surface_get_height"] = [ ["surface"], function(val) { return surface_get_height_safe(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "surface_get_dimension"] = [ ["surface"], function(val) { var s = array_safe_get_fast(val, 0); return [ surface_get_width_safe(s), surface_get_height_safe(s) ]; } ]; + global.PCX_FUNCTIONS[? "surface_get_width"] = [ ["surface"], function(val) { return surface_get_width_safe(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "surface_get_height"] = [ ["surface"], function(val) { return surface_get_height_safe(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "color_hex"] = [ ["char"], function(val) { return colorFromHex(array_safe_get_fast(val, 0)); } ]; - global.FUNCTIONS[? "color_rgb"] = [ ["red", "green", "blue"], function(val) { return make_color_rgb(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1), array_safe_get_fast(val, 2)); } ]; - global.FUNCTIONS[? "color_hsv"] = [ ["red", "green", "blue"], function(val) { return make_color_hsv(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1), array_safe_get_fast(val, 2)); } ]; + global.PCX_FUNCTIONS[? "color_hex"] = [ ["char"], function(val) { return colorFromHex(array_safe_get_fast(val, 0)); } ]; + global.PCX_FUNCTIONS[? "color_rgb"] = [ ["red", "green", "blue"], function(val) { return make_color_rgb(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1), array_safe_get_fast(val, 2)); } ]; + global.PCX_FUNCTIONS[? "color_hsv"] = [ ["red", "green", "blue"], function(val) { return make_color_hsv(array_safe_get_fast(val, 0), array_safe_get_fast(val, 1), array_safe_get_fast(val, 2)); } ]; globalvar PROJECT_VARIABLES; PROJECT_VARIABLES = {}; @@ -312,7 +312,7 @@ static validate = function() { #region dependency = []; - if(ds_map_exists(global.FUNCTIONS, symbol)) { + if(ds_map_exists(global.PCX_FUNCTIONS, symbol)) { if(!is_array(l)) return false; for( var i = 0, n = array_length(l); i < n; i++ ) if(!_validate(l[i])) return false; @@ -355,10 +355,10 @@ //print($"{symbol}, {l} | {r}") //print(params); - if(ds_map_exists(global.FUNCTIONS, symbol)) { + if(ds_map_exists(global.PCX_FUNCTIONS, symbol)) { if(!is_array(l)) return 0; - var _fn = global.FUNCTIONS[? symbol]; + var _fn = global.PCX_FUNCTIONS[? symbol]; var _ev = _fn[1]; var _l = array_create(array_length(l)); diff --git a/scripts/pcx_parse/pcx_parse.gml b/scripts/pcx_parse/pcx_parse.gml index 46f00684b..59041749e 100644 --- a/scripts/pcx_parse/pcx_parse.gml +++ b/scripts/pcx_parse/pcx_parse.gml @@ -233,7 +233,7 @@ if(ds_stack_empty(op)) ds_stack_push(op, ch); else { var _top = ds_stack_top(op); - if(_top == "(" || ds_map_exists(global.FUNCTIONS, _top) || pres[? ch] > pres[? _top]) { + if(_top == "(" || ds_map_exists(global.PCX_FUNCTIONS, _top) || pres[? ch] > pres[? _top]) { ds_stack_push(op, ch); } else { while(pres[? ch] <= pres[? ds_stack_top(op)] && !ds_stack_empty(op)) @@ -320,7 +320,7 @@ if(vsl == "") continue; - if(ds_map_exists(global.FUNCTIONS, vsl)) { //function + if(ds_map_exists(global.PCX_FUNCTIONS, vsl)) { //function ds_stack_push(op, vsl); last_push = "fn"; } else { @@ -361,7 +361,7 @@ function buildFuncTree(operator, vl) { #region if(ds_stack_empty(vl)) return noone; - if(ds_map_exists(global.FUNCTIONS, operator)) { + if(ds_map_exists(global.PCX_FUNCTIONS, operator)) { if(ds_stack_empty(vl)) return noone; diff --git a/scripts/pcx_server/pcx_server.gml b/scripts/pcx_server/pcx_server.gml index 96d119852..380bf8156 100644 --- a/scripts/pcx_server/pcx_server.gml +++ b/scripts/pcx_server/pcx_server.gml @@ -196,7 +196,7 @@ function pxl_autocomplete_server(prompt, params = [], context = {}) { ////////////////////////////////// ds_priority_clear(pr_list); - var F = global.FUNCTIONS; + var F = global.PCX_FUNCTIONS; var _keys = ds_map_keys_to_array(F); for( var i = 0, n = array_length(_keys); i < n; i++ ) { @@ -217,9 +217,9 @@ function pxl_autocomplete_server(prompt, params = [], context = {}) { } function pxl_function_guide_server(prompt) { - if(!ds_map_exists(global.FUNCTIONS, prompt)) return ""; + if(!ds_map_exists(global.PCX_FUNCTIONS, prompt)) return ""; - var fn = global.FUNCTIONS[? prompt]; + var fn = global.PCX_FUNCTIONS[? prompt]; var guide = prompt + "("; for( var i = 0, n = array_length(fn[0]); i < n; i++ ) guide += (i? ", " : "") + string(fn[0][i]); diff --git a/scripts/string_decimal/string_decimal.gml b/scripts/string_decimal/string_decimal.gml index ecd87559a..529333f8f 100644 --- a/scripts/string_decimal/string_decimal.gml +++ b/scripts/string_decimal/string_decimal.gml @@ -22,34 +22,35 @@ function string_decimal(str) { return (neg? "-" : "") + string_digits(pre) + "." + string_digits(pos); } -function toNumberFast(str) { - INLINE - - var r = real(str); - if(is_real(r)) return r; - return 0; -} - function toNumber(str) { INLINE - if(is_real(str)) return str; - if(!isNumber(str)) return 0; + try { return real(str); } + catch(e) {} - var expo = 0; - if(string_pos("e", str)) { - var pos = string_pos("e", str); - expo = real(string_copy(str, pos + 1, string_length(str) - pos)); - } - - str = string_replace_all(str, ",", "."); - str = string_decimal(str); - if(str == "") return 0; - if(str == ".") return 0; - if(str == "-") return 0; - return real(str) * power(10, expo); + return 0; } +//function toNumber(str) { +// INLINE + +// if(is_real(str)) return str; +// if(!isNumber(str)) return 0; + +// var expo = 0; +// if(string_pos("e", str)) { +// var pos = string_pos("e", str); +// expo = real(string_copy(str, pos + 1, string_length(str) - pos)); +// } + +// str = string_replace_all(str, ",", "."); +// str = string_decimal(str); +// if(str == "") return 0; +// if(str == ".") return 0; +// if(str == "-") return 0; +// return real(str) * power(10, expo); +//} + function isNumber(str) { if(is_real(str)) return true; str = string_trim(str); diff --git a/scripts/textArea/textArea.gml b/scripts/textArea/textArea.gml index c57005e5e..895ef93a4 100644 --- a/scripts/textArea/textArea.gml +++ b/scripts/textArea/textArea.gml @@ -811,7 +811,8 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _hw, _y + hh); var tsw = _w; var tsh = hh; - text_surface = surface_verify(text_surface, tsw, tsh); + var _update = !surface_valid(text_surface, tsw, tsh); + if(_update) text_surface = surface_verify(text_surface, tsw, tsh); draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, hh, boxColor, 1); @@ -955,9 +956,11 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor deactivate(); } else { - surface_set_shader(text_surface, noone, false, BLEND.add); - display_text(tx, text_y + ui(7), _text); - surface_reset_shader(); + if(_update && _input_text != _text) { + surface_set_shader(text_surface, noone, false, BLEND.add); + display_text(tx, text_y + ui(7), _text); + surface_reset_shader(); + } BLEND_ALPHA draw_surface(text_surface, _x, _y);