- Fix nodes in group render twice per frame.

This commit is contained in:
Tanasart 2023-11-30 14:55:33 +07:00
parent 9ac2861330
commit 12f185f3cd
14 changed files with 152 additions and 122 deletions

View file

@ -309,5 +309,6 @@
#region debug
//instance_create_depth(0, 0, 0, addon_key_displayer);
global.__debug_runner = 0;
__debug_animator_counter = 0;
#endregion

View file

@ -1,4 +1,5 @@
/// @description init
global.__debug_runner++;
global.cache_call = 0;
global.cache_hit = 0;

View file

@ -26,17 +26,13 @@ function argumentRenderer(_typeArray = []) {
draw_text_add(tx + ui(8), ty + _th + ui(8 + 6), __txt("Value"));
var _jValue = inputs[| i + 2];
if(_jValue.editWidget != noone) {
var params = new widgetParam(tx + ui(64), ty + _th + ui(10), _w - ui(64), TEXTBOX_HEIGHT, _jValue.showValue(), -1, _m, argument_renderer.rx, argument_renderer.ry);
if(argument_renderer.showValue && _jValue.editWidget != noone) {
var params = new widgetParam(tx + ui(64), ty + _th + ui(10), _w - ui(64), TEXTBOX_HEIGHT, _jValue.showValue(), {}, _m, argument_renderer.rx, argument_renderer.ry);
_jValue.editWidget.setFocusHover(_focus, _hover);
_h += _jValue.editWidget.drawParam(params) + ui(10);
}
//var _ly = ty + _h - ui(9);
//draw_set_color(COLORS.panel_separator);
//draw_line_width(_x + ui(16), _ly, _x + _w - ui(16 * 2), _ly, 2);
hh += _h;
ty += _h;
}
@ -53,4 +49,6 @@ function argumentRenderer(_typeArray = []) {
inputs[| i + 2].editWidget.register(parent);
}
}
argument_renderer.showValue = true;
}

View file

@ -25,10 +25,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
LATEST_VERSION = 11500;
VERSION = 11586;
VERSION = 11587;
SAVE_VERSION = 11600;
VERSION_STRING = "1.16rc6";
BUILD_NUMBER = 11586;
VERSION_STRING = "1.16rc7";
BUILD_NUMBER = 11587;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -52,25 +52,28 @@ function gradientObject(color = c_black) constructor { #region
} #endregion
static eval = function(position) { #region
if(array_length(keys) == 0) return c_black;
if(array_length(keys) == 1) return keys[0].value;
var _len = array_length(keys);
if(_len == 0) return c_black;
if(_len == 1) return keys[0].value;
for(var i = 0; i < array_length(keys); i++) {
if(position <= keys[0].time) return keys[0].value;
if(position >= keys[_len - 1].time) return keys[_len - 1].value;
var _pkey = keys[0];
for(var i = 1; i < _len; i++) {
var _key = keys[i];
if(_key.time < position) continue;
if(_key.time == position) return keys[i].value;
if(i == 0) //before first color
return keys[0].value;
var c0 = keys[i - 1].value;
if(type == GRADIENT_INTER.smooth) {
var rat = (position - keys[i - 1].time) / (keys[i].time - keys[i - 1].time);
var c1 = keys[i].value;
return merge_color(c0, c1, rat);
var rat = (position - _pkey.time) / (_key.time - _pkey.time);
return merge_color(_pkey.value, _key.value, rat);
} else if(type == GRADIENT_INTER.none) {
return c0;
return _pkey.value;
}
_pkey = _key;
}
return keys[array_length(keys) - 1].value; //after last color

View file

@ -8,7 +8,7 @@ var reserved = ["and", "break", "do", "else", "elseif", "end", "false",
for( var i = 0, n = array_length(reserved); i < n; i++ )
global.lua_reserved[? reserved[i]] = 1;
global.CODE_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ",", ";", "+", "-", "*", "/", "^", "=", "--"];
global.CODE_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ".", ",", ";", "+", "-", "*", "/", "^", "=", "--"];
function lua_token_splice(str) {
var st = [];

View file

@ -53,8 +53,13 @@ function Node_VFX_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group
for( var i = 0; i < TOTAL_FRAMES; i++ )
for( var j = 0, m = ds_list_size(topoList); j < m; j++ ) {
var node = topoList[| j];
if(is_instanceof(node, Node_VFX_Renderer_Output) ||
is_instanceof(node, Node_VFX_Renderer)) continue;
var _ins = instanceof(node);
if(!string_pos("Node_VFX", _ins))
continue;
if(_ins == "Node_VFX_Renderer" || _ins == "Node_VFX_Renderer_Output")
continue;
node.doUpdate(i);
}

View file

@ -46,16 +46,18 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var _x, _y;
var line = lines[_ind];
var _st = _rat * (lineLength[_ind] - 1);
var _len = lineLength[_ind] - 1;
var _st = _rat * _len;
var _fl = floor(_st);
var _fr = frac(_st);
_p0 = line[clamp(floor(_st) + 0, 0, array_length(line) - 1)];
_p1 = line[clamp(floor(_st) + 1, 0, array_length(line) - 1)];
_p0 = line[clamp(_fl + 0, 0, _len)];
_p1 = line[clamp(_fl + 1, 0, _len)];
if(!is_array(_p0)) return out;
if(!is_array(_p1)) return out;
if(!is_array(_p0) || !is_array(_p1)) return out;
out.x = lerp(_p0[0], _p1[0], frac(_st));
out.y = lerp(_p0[1], _p1[1], frac(_st));
out.x = lerp(_p0[0], _p1[0], _fr);
out.y = lerp(_p0[1], _p1[1], _fr);
return out;
} #endregion
@ -83,13 +85,16 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var _life = getInputData(1); _life = max(_life, 1);
var _colr = getInputData(2);
lines = [];
length = [];
lengthAcc = [];
lineLength = [];
lineData = [];
var _totlLen = array_length(_vfxs);
lines = array_verify(lines, _totlLen);
length = array_verify(length, _totlLen);
lengthAcc = array_verify(lengthAcc, _totlLen);
lineLength = array_verify(lineLength, _totlLen);
lineData = array_verify(lineData, _totlLen);
for( var i = 0; i < array_length(_vfxs); i++ ) {
var _len = 0;
for( var i = 0; i < _totlLen; i++ ) {
var _vfx = _vfxs[i];
var _posx = _vfx.x_history;
@ -99,14 +104,13 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var _trail_st = max(1, _vfx.trailLife - _life);
var _trail_len = _trail_ed - _trail_st;
//if(_vfx.life_total > 0) print($"{_vfx.active} | {_vfx.seed} : {_vfx.trailLife}")
if(_trail_len <= 0) continue;
var _lngh = 0;
var _ox = _posx[_trail_st], _nx;
var _oy = _posy[_trail_st], _ny;
var _line = array_create(_trail_len);
var _lenA = array_create(_trail_len - 1);
var _line = array_verify(lines[_len], _trail_len);
var _lenA = array_verify(lengthAcc[_len], _trail_len - 1);
_line[0] = [ _ox, _oy ];
for( var j = 0; j <= _trail_len; j++ ) {
@ -127,17 +131,20 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct
_ox = _nx;
}
array_push(lines, _line);
array_push(length, _lngh);
array_push(lengthAcc, _lenA);
array_push(lineLength, array_length(_line));
if(_colr)
array_push(lineData, {
color: _vfx.blend,
});
lines[_len] = _line;
length[_len] = _lngh;
lengthAcc[_len] = _lenA;
lineLength[_len] = _trail_len;
lineData[_len] = { color: _vfx.blend, };
_len++;
}
array_resize(lines, _len);
array_resize(length, _len);
array_resize(lengthAcc, _len);
array_resize(lineLength, _len);
array_resize(lineData, _len);
outputs[| 0].setValue(self);
} #endregion

View file

@ -219,7 +219,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
static getNextNodesInternal = function() { #region //get node inside the group
LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $"→→→→→ Call get next node from group");
LOG_IF(global.FLAG.render == 1, $"→→→→→ Call get next node from group: {INAME}");
var nodes = [];
if(isRenderActive()) {

View file

@ -61,7 +61,7 @@ output.color = surfaceColor;")
input_display_list = [ 2,
["Shader", false], 1,
["Arguments", false], argument_renderer,
["Values", false],
["Values", true],
];
setIsDynamicInput(3, false);
@ -171,6 +171,10 @@ output.color = surfaceColor;")
static onInspector1Update = function() { refreshShader(); }
static step = function() { #region
argument_renderer.showValue = input_display_list[5][1];
} #endregion
static refreshShader = function() { #region
var vs = getInputData(0);
var fs = getInputData(1);

View file

@ -81,10 +81,6 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
if(_prop.type != VALUE_TYPE.trigger)
ds_list_add(values, new valueKey(0, _val, self));
process_cache = {};
process_cache_type = -1;
process_cache_disp = -1;
#endregion
static refreshAnimation = function() { #region
@ -329,18 +325,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
return 0;
} #endregion
static clearProcessCache = function(_val) { process_cache = {}; }
static processType = function(_val) { #region
//if(process_cache_type != prop.type || process_cache_disp != prop.display_type) {
// clearProcessCache();
// process_cache_type = prop.type;
// process_cache_disp = prop.display_type;
//}
//if(struct_has(process_cache, _val))
// return process_cache[$ _val];
var _res = _val;
if(!sep_axis && typeArray(prop.display_type) && is_array(_val)) {
for(var i = 0; i < array_length(_val); i++)
@ -348,7 +333,6 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
} else
_res = processValue(_val);
//process_cache[$ _val] = _res;
return _res;
} #endregion

View file

@ -163,6 +163,8 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(CURRENT_FRAME == 0 || inputs[| 11].is_anim)
ds_map_clear(widthMap);
var __debug_timer = get_timer();
var _rangeMin = min(_ratio[0], _ratio[1]);
var _rangeMax = max(_ratio[0], _ratio[1]);
if(_rangeMax == 1) _rangeMax = 0.99999;
@ -191,8 +193,6 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _ow, _nw, _oa, _na, _oc, _nc, _owg, _nwg;
var _pathData = [];
lines = [];
if(_use_path) { #region
var lineLen = 1;
if(struct_has(_pat, "getLineCount"))
@ -200,14 +200,18 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(struct_has(_pat, "getPathData"))
_pathData = _pat.getPathData();
lines = array_verify(lines, lineLen);
var _lineAmo = 0;
if(_rtMax > 0)
for( var i = 0; i < lineLen; i++ ) {
var _useDistance = _fixL && struct_has(_pat, "getLength");
var _pathLength = _useDistance? _pat.getLength(i) : 1;
if(_pathLength == 0) continue;
var _segLength = struct_has(_pat, "getAccuLength")? _pat.getAccuLength(i) : [];
var _segIndex = 0;
var _segLength = struct_has(_pat, "getAccuLength")? _pat.getAccuLength(i) : [];
var _segLengthAmo = array_length(_segLength);
var _segIndex = 0;
var _pathStr = _rtStr;
var _pathEnd = _rtMax;
@ -223,7 +227,9 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _prog_next = 0;
var _prog = _prog_curr + 1; //Record previous position to delete from _total
var _prog_total = 0; //Record how far the pointer have moved so far
var points = [];
var points = is_array(lines[i])? lines[i] : [];
var pointArrLen = array_length(points);
var pointAmo = 0;
var wght;
var _pathPng;
@ -240,13 +246,13 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
while(_total >= 0) {
if(_useDistance) {
var segmentLength = array_safe_get(_segLength, _segIndex, 99999);
var segmentLength = _segIndex < _segLengthAmo? _segLength[_segIndex] : 99999;
_prog_next = _prog_curr % _pathLength; //Wrap overflow path
_prog_next = min(_prog_curr + _stepLen, _pathLength, segmentLength);
if(_prog_next == segmentLength)
_segIndex = (_segIndex + 1) % array_length(_segLength);
_segIndex = (_segIndex + 1) % _segLengthAmo;
_pathPng = _ratInv? _pathLength - _prog_curr : _prog_curr;
} else {
if(_prog_curr >= 1) //Wrap overflow path
@ -277,14 +283,28 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_ny += lengthdir_y(random1D(_sed + _sedIndex, -_wig, _wig), _d + 90); _sedIndex++;
}
if(_prog_total >= _pathStr) //Do not add point before range start. Do this instead of starting at _rtStr to prevent wiggle.
array_push(points, {
x: _nx,
y: _ny,
prog: _prog_total / _pathEnd,
progCrop: _prog_curr / _pathLength,
weight: wght
});
if(_prog_total >= _pathStr) { //Do not add point before range start. Do this instead of starting at _rtStr to prevent wiggle.
var _pntData;
if(pointAmo < pointArrLen && is_struct(points[pointAmo])) {
_pntData = points[pointAmo];
_pntData.x = _nx;
_pntData.y = _ny;
_pntData.prog = _prog_total / _pathEnd;
_pntData.progCrop = _prog_curr / _pathLength;
_pntData.weight = wght;
} else {
_pntData = {
x: _nx,
y: _ny,
prog: _prog_total / _pathEnd,
progCrop: _prog_curr / _pathLength,
weight: wght
}
points[pointAmo] = _pntData;
}
pointAmo++;
}
if(_prog_next > _prog_curr) {
_prog_total += _prog_next - _prog_curr;
@ -300,8 +320,11 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_total_prev = _total;
}
array_push(lines, points);
array_resize(points, pointAmo);
lines[_lineAmo++] = points;
}
array_resize(lines, _lineAmo);
#endregion
} else { #region
var x0, y0, x1, y1;
@ -354,7 +377,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(_bg) draw_clear_alpha(0, 1);
else DRAW_CLEAR
if(_useTex) {
if(_useTex) { #region
var tex = surface_get_texture(_tex);
shader_set(sh_draw_mapping);
@ -363,7 +386,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
shader_set_f("scale", _texSca);
shader_set_interpolation(_tex);
}
} #endregion
for( var i = 0, n = array_length(lines); i < n; i++ ) {
var points = lines[i];
@ -380,15 +403,11 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
for( var j = 0; j < array_length(points); j++ ) {
var p0 = points[j];
var _nx = p0.x;
var _ny = p0.y;
var _nx = p0.x - 0.5 * _1px;
var _ny = p0.y - 0.5 * _1px;
var prog = p0.prog;
var prgc = p0.progCrop;
if(_1px) {
_nx = _nx - 0.5;
_ny = _ny - 0.5;
}
var _dir = j? point_direction(_ox, _oy, _nx, _ny) : 0;
var widProg = value_snap_real(_widap? prog : prgc, 0.01);
@ -400,11 +419,11 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc));
if(_cap) {
if(_cap) { #region
if(j == 1) {
draw_set_color(_oc);
_d = point_direction(_ox, _oy, _nx, _ny) + 180;
_d = _dir + 180;
draw_circle_angle(_ox, _oy, _ow / 2, _d - 90, _d, _capP);
draw_circle_angle(_ox, _oy, _ow / 2, _d, _d + 90, _capP);
}
@ -412,29 +431,26 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(j == array_length(points) - 1) {
draw_set_color(_nc);
_d = point_direction(_ox, _oy, _nx, _ny);
_d = _dir;
draw_circle_angle(_nx, _ny, _nw / 2, _d - 90, _d, _capP);
draw_circle_angle(_nx, _ny, _nw / 2, _d, _d + 90, _capP);
}
}
} #endregion
if(_1px) {
if(_1px) { #region
if(j) {
var dst = point_distance(_ox, _oy, _nx, _ny);
if(dst <= 1 && i < array_length(points) - 1) continue;
//_nc = make_color_hsv(random(255), 255, 255);
//_oc = _nc;
//line_bresenham(pxs, _ox, _oy, _nx, _ny, _oc, _nc);
draw_line_color(_ox, _oy, _nx, _ny, _oc, _nc);
}
_ox = _nx;
_oy = _ny;
_oc = _nc;
} else {
#endregion
} else { #region
if(j) {
var _nd0 = point_direction(_ox, _oy, _nx, _ny);
var _nd0 = _dir;
var _nd1 = _nd0;
if(j < array_length(points) - 1) {
@ -445,7 +461,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_nd1 = point_direction(_nx, _ny, _nnx, _nny);
_nd = _nd0 + angle_difference(_nd1, _nd0) / 2;
} else
_nd = point_direction(_ox, _oy, _nx, _ny);
_nd = _nd0;
if(_useTex) {
var _len = array_length(points) - 1;
@ -479,6 +495,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_ow = _nw;
_oc = _nc;
}
#endregion
}
draw_primitive_end();
@ -488,6 +505,9 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
surface_reset_target();
#endregion
//print($"Processing line {global.__debug_runner} = {get_timer() - __debug_timer} ms");
//printCallStack();
return _outSurf;
}
}

View file

@ -23,9 +23,9 @@ function __nodeLeafList(_list) { #region
var _node = _list[| i];
if(!_node.active) continue;
if(!_node.isRenderActive()) continue;
if(!_node.isLeaf()) continue;
var _startNode = _node.isRenderable();
if(_startNode) {
if(_node.isRenderable()) {
array_push(nodes, _node);
array_push(nodeNames, _node.internalName);
}
@ -195,7 +195,7 @@ function Render(partial = false, runAction = false) { #region
rendering = RENDER_QUEUE.dequeue();
var renderable = rendering.isRenderable();
LOG_IF(global.FLAG.render == 1, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}");
LOG_IF(global.FLAG.render == 1, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"} ({rendering.rendered})");
if(renderable) {
var _render_pt = get_timer();
@ -204,7 +204,8 @@ function Render(partial = false, runAction = false) { #region
var nextNodes = rendering.getNextNodes();
for( var i = 0, n = array_length(nextNodes); i < n; i++ ) {
RENDER_QUEUE.enqueue(nextNodes[i]);
if(nextNodes[i].isRenderable())
RENDER_QUEUE.enqueue(nextNodes[i]);
}
if(runAction && rendering.hasInspector1Update())

View file

@ -103,12 +103,13 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
} #endregion
static onModified = function() { #region
autocomplete_delay = 0;
o_dialog_textbox_autocomplete.deactivate(self);
o_dialog_textbox_function_guide.deactivate(self);
if(!isCodeFormat()) return;
if(autocomplete_server == noone) return;
if(!use_autocomplete) {
o_dialog_textbox_autocomplete.deactivate(self);
return;
}
if(!use_autocomplete) return;
var crop = string_copy(_input_text, 1, cursor);
var slp = string_splice(crop, [" ", "(", "[", "{", ",", "\n"]);
@ -160,8 +161,7 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
o_dialog_textbox_function_guide.activate(self);
o_dialog_textbox_function_guide.prompt = guide;
o_dialog_textbox_function_guide.index = amo;
} else
o_dialog_textbox_function_guide.deactivate(self);
}
} #endregion
static keyboardEnter = function() { #region
@ -537,7 +537,6 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
undo_delay = 0;
}
onModified();
autocomplete_delay = 0;
}
if(auto_update && keyboard_check_pressed(vk_anykey))
@ -565,6 +564,9 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
}
}
autocomplete_delay = 0;
o_dialog_textbox_autocomplete.deactivate(self);
o_dialog_textbox_function_guide.deactivate(self);
} else if(keyboard_check_pressed(vk_end)) {
if(key_mod_press(SHIFT)) {
if(cursor_select == -1)
@ -576,6 +578,10 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
while(string_char_at(_input_text, cursor + 1) != "\n" && cursor < string_length(_input_text)) {
cursor++;
}
autocomplete_delay = 0;
o_dialog_textbox_autocomplete.deactivate(self);
o_dialog_textbox_function_guide.deactivate(self);
} else if(keyboard_check_pressed(vk_escape) && o_dialog_textbox_autocomplete.textbox != self) {
_input_text = _last_value;
cut_line();