Bug fixes and optimizations

This commit is contained in:
Tanasart 2024-04-01 16:10:01 +07:00
parent 574472b8a3
commit 5d3a1f7835
29 changed files with 298 additions and 228 deletions

View file

@ -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() {

View file

@ -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 = [];

View file

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

View file

@ -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) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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,9 +1129,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
jun.y = jy;
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;
continue;
@ -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

View file

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

View file

@ -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();

View file

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

View file

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

View file

@ -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() {

View file

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

View file

@ -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)

View file

@ -92,6 +92,8 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
#region ---- main ----
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

View file

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

View file

@ -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]);

View file

@ -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
@ -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()) {
@ -1765,7 +1769,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
expContext = {
name : name,
node_name : node.display_name,
value: val[0],
value : arr[0],
node_values : node.input_value_map,
};
@ -1773,17 +1777,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
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

View file

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

View file

@ -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;
@ -1934,6 +1934,7 @@ 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);
@ -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

View file

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

View file

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

View file

@ -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]);

View file

@ -22,33 +22,34 @@ 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));
return 0;
}
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 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;

View file

@ -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 {
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);