diff --git a/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml b/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml index f02f8b414..46b52148b 100644 --- a/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml +++ b/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml @@ -668,6 +668,7 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor }; } +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function quarternionArraySlerp(_q0, _q1, _s) { INLINE @@ -739,4 +740,70 @@ function quarternionArraySlerp(_q0, _q1, _s) { (_q12 * _s1) + (_q22 * _s2), (_q13 * _s1) + (_q23 * _s2) ]; -}; \ No newline at end of file +}; + +function quarternionFromEuler(_x, _y, _z) { + INLINE + + _x = -_x * 0.5; + _y = -_y * 0.5; + _z = -_z * 0.5; + + var _q1Sin, _q1Cos, _temp; + var _qX, _qY, _qZ, _qW; + + _q1Sin = dsin(_z); + _q1Cos = dcos(_z); + + _temp = dsin(_x); + + _qX = _q1Cos * _temp; + _qY = _q1Sin * _temp; + + _temp = dcos(_x); + + _qZ = _q1Sin * _temp; + _qW = _q1Cos * _temp; + + _q1Sin = dsin(_y); + _q1Cos = dcos(_y); + + var X = _qX * _q1Cos - _qZ * _q1Sin; + var Y = _qW * _q1Sin + _qY * _q1Cos; + var Z = _qZ * _q1Cos + _qX * _q1Sin; + var W = _qW * _q1Cos - _qY * _q1Sin; + + return [ X, Y, Z, W ]; +} + +function quarternionToEuler(X, Y, Z, W) { + INLINE + + var ysqr = Y * Y; + + // roll (x-axis rotation) + var t0 = +2.0 * (W * X + Y * Z); + var t1 = +1.0 - 2.0 * (X * X + ysqr); + var roll = arctan2(t0, t1); + + // pitch (y-axis rotation) + var t2 = +2.0 * (W * Y - Z * X); + t2 = clamp(t2, -1.0, 1.0); // Prevent numerical instability + var pitch = arcsin(t2); + + // yaw (z-axis rotation) + var t3 = +2.0 * (W * Z + X * Y); + var t4 = +1.0 - 2.0 * (ysqr + Z * Z); + var yaw = arctan2(t3, t4); + + // Convert radians to degrees + var _dx = roll * 180.0 / pi; + var _dy = pitch * 180.0 / pi; + var _dz = yaw * 180.0 / pi; + + var _dx = round(_dx * 1000) / 1000; + var _dy = round(_dy * 1000) / 1000; + var _dz = round(_dz * 1000) / 1000; + + return [ _dx, _dy, _dz ]; +} \ No newline at end of file diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index ccee578b0..e6fcc82b8 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -569,9 +569,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(attributes.show_update_trigger) { if(updatedInTrigger.getValue()) { + getInputs(); update(); - + updatedInTrigger.setValue(false); } updatedOutTrigger.setValue(false); @@ -824,6 +825,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static getPreviousNodes = function() { #region var prev = []; + if(attributes.show_update_trigger && updatedInTrigger.value_from) + array_push(prev, updatedInTrigger.value_from.node); + for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) { var _in = inputs[| i]; @@ -943,7 +947,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static refreshNodeDisplay = function() { #region INLINE - if(IS_PLAYING) return; updateIO(); setHeight(); diff --git a/scripts/node_trigger/node_trigger.gml b/scripts/node_trigger/node_trigger.gml index 180fad9c1..85e2a8dba 100644 --- a/scripts/node_trigger/node_trigger.gml +++ b/scripts/node_trigger/node_trigger.gml @@ -1,7 +1,6 @@ function Node_Trigger(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Trigger"; - update_on_frame = true; - setDimension(96, 32 + 24 * 1); + setDimension(96, 56); inputs[| 0] = nodeValue("Trigger", self, JUNCTION_CONNECT.input, VALUE_TYPE.trigger, false ) .setDisplay(VALUE_DISPLAY.button, { name: "Trigger" }); @@ -16,8 +15,6 @@ function Node_Trigger(_x, _y, _group = noone) : Node(_x, _y, _group) constructor static update = function() { var _val = inputs[| 0].getValue(); - //print($"{CURRENT_FRAME}: {ds_list_to_array(inputs[| 0].animator.values)} | {inputs[| 0].animator.getValue(CURRENT_FRAME)}"); - outputs[| 0].setValue(_val); } diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index a153f4166..778d7e671 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1650,7 +1650,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cache_value[2] = val; cache_value[3] = applyUnit; - if(!IS_PLAYING) updateColor(val); + updateColor(val); return val; } #endregion @@ -1714,6 +1714,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru val = arrayBalance(val); + if(value_from != noone && display_type == VALUE_DISPLAY.d3quarternion && display_data.angle_display == QUARTERNION_DISPLAY.euler) + val = quarternionFromEuler(val[0], val[1], val[2]); + if(isArray(val) && array_length(val) < 1024) { #region Process data var _val = array_create(array_length(val)); for( var i = 0, n = array_length(val); i < n; i++ ) @@ -1900,7 +1903,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(display_type == VALUE_DISPLAY.d3quarternion) { switch(display_data.angle_display) { case QUARTERNION_DISPLAY.quarterion : return val; - case QUARTERNION_DISPLAY.euler : return new BBMOD_Quaternion(val[0], val[1], val[2], val[3]).ToEuler(true); + case QUARTERNION_DISPLAY.euler : return quarternionToEuler(val[0], val[1], val[2], val[3]); } } @@ -2009,8 +2012,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru static setValueInspectorDirect = function(val = 0, index = noone) { if(display_type == VALUE_DISPLAY.d3quarternion && display_data.angle_display == QUARTERNION_DISPLAY.euler) { - var _qval = new BBMOD_Quaternion().FromEuler(-val[0], -val[1], -val[2]).ToArray(); - var _eval = new BBMOD_Quaternion(_qval[0], _qval[1], _qval[2], _qval[3]).ToEuler(true); + var _qval = quarternionFromEuler(-val[0], -val[1], -val[2]); return setValueDirect(_qval); } return setValueDirect(val, index); @@ -2063,12 +2065,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(connect_type == JUNCTION_CONNECT.output) { if(self.index == 0) { node.preview_value = getValue(); - node.preview_array = "[" + array_shape(node.preview_value) + "]"; + node.preview_array = $"[{array_shape(node.preview_value)}]"; } return; } - if(is_instanceof(node, Node)) + if(is_instanceof(node, Node) && self.index >= 0) node.setInputData(self.index, animator.getValue(time)); if(tags == VALUE_TAG.updateInTrigger || tags == VALUE_TAG.updateOutTrigger) return true; @@ -2720,8 +2722,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(log) log_warning("LOAD", $"[Connect] Reconnecting {node.name} to {_nd.name}", node); - if(con_index == VALUE_TAG.updateInTrigger) setFrom(_nd.updatedInTrigger); - else if(con_index == VALUE_TAG.updateOutTrigger) setFrom(_nd.updatedOutTrigger); + if(con_index == VALUE_TAG.updateInTrigger) return setFrom(_nd.updatedInTrigger); + else if(con_index == VALUE_TAG.updateOutTrigger) return setFrom(_nd.updatedOutTrigger); else if(con_index < _ol) { var _set = setFrom(_nd.outputs[| con_index], false, true); if(_set) return true; diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index fad497d43..97161598a 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -287,9 +287,13 @@ function Panel_Inspector() : PanelContent() constructor { continue; } + var _font = viewMode == INSP_VIEW_MODE.spacious? f_p0 : f_p2; + switch(i) { case 0 : var _edt = PROJECT.attributeEditor; + var _lh; + for( var j = 0; j < array_length(_edt); j++ ) { var title = _edt[j][0]; var param = _edt[j][1]; @@ -299,70 +303,109 @@ function Panel_Inspector() : PanelContent() constructor { var widx = ui(8); var widy = yy; - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); - draw_text_add(ui(16), yy, __txt(title)); - yy += line_get_height() + ui(6); - hh += line_get_height() + ui(6); - + draw_set_text(_font, fa_left, fa_top, COLORS._main_text_inner); + draw_text_over(ui(16), viewMode == INSP_VIEW_MODE.spacious? yy : yy + ui(3), __txt(title)); + + if(viewMode == INSP_VIEW_MODE.spacious) { + _lh = line_get_height(); + yy += _lh + ui(6); + hh += _lh + ui(6); + + } else if(viewMode == INSP_VIEW_MODE.compact) { + _lh = line_get_height() + ui(6); + } + editW.setFocusHover(pFOCUS, _hover); if(pFOCUS) editW.register(contentPane); var wh = 0; - var _data = PROJECT.attributes[$ param]; - var _param = new widgetParam(ui(16), yy, w - ui(16 + 48), TEXTBOX_HEIGHT, _data, {}, _m, rx, ry); + var _data = PROJECT.attributes[$ param]; + var _wdx = viewMode == INSP_VIEW_MODE.spacious? ui(16) : ui(140); + var _wdy = yy; + var _wdw = w - ui(48) - _wdx; + var _wdh = viewMode == INSP_VIEW_MODE.spacious? TEXTBOX_HEIGHT : _lh; + + var _param = new widgetParam(_wdx, _wdy, _wdw, _wdh, _data, {}, _m, rx, ry); + _param.font = _font; wh = editW.drawParam(_param); var jun = PANEL_GRAPH.value_dragging; var widw = con_w - ui(16); - var widh = line_get_height() + ui(6) + wh + ui(4); + var widh = viewMode == INSP_VIEW_MODE.spacious? _lh + ui(6) + wh + ui(4) : max(wh, _lh); if(jun != noone && _hover && point_in_rectangle(_m[0], _m[1], widx, widy, widx + widw, widy + widh)) { draw_sprite_stretched_ext(THEME.ui_panel_active, 0, widx, widy, widw, widh, COLORS._main_value_positive, 1); attribute_hovering = drpFn; } - yy += wh + ui(8); - hh += wh + ui(8); + if(viewMode == INSP_VIEW_MODE.spacious) { + yy += wh + ui(8); + hh += wh + ui(8); + + } else if(viewMode == INSP_VIEW_MODE.compact) { + yy += max(wh, _lh) + ui(6); + hh += max(wh, _lh) + ui(6); + } } + break; + case 1 : for( var j = 0; j < array_length(meta.displays); j++ ) { var display = meta.displays[j]; - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); - draw_text_add(ui(16), yy, __txt(display[0])); - yy += line_get_height() + ui(6); - hh += line_get_height() + ui(6); - + draw_set_text(_font, fa_left, fa_top, COLORS._main_text_inner); + draw_text_over(ui(16), viewMode == INSP_VIEW_MODE.spacious? yy : yy + ui(3), __txt(display[0])); + + if(viewMode == INSP_VIEW_MODE.spacious) { + _lh = line_get_height(); + yy += _lh + ui(6); + hh += _lh + ui(6); + + } else if(viewMode == INSP_VIEW_MODE.compact) { + _lh = line_get_height() + ui(6); + } + meta_tb[j].setFocusHover(pFOCUS, _hover); if(pFOCUS) meta_tb[j].register(contentPane); - + var wh = 0; var _dataFunc = display[1]; - var _data = _dataFunc(meta); + var _data = _dataFunc(meta); + var _wdx = viewMode == INSP_VIEW_MODE.spacious? ui(16) : ui(140); + var _wdy = yy; + var _wdw = w - ui(48) - _wdx; + var _wdh = display[2]; + + var _param = new widgetParam(_wdx, _wdy, _wdw, _wdh, _data, {}, _m, rx, ry); + _param.font = _font; switch(instanceof(meta_tb[j])) { - case "textArea" : - wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _data, _m); - break; - case "textArrayBox" : - meta_tb[j].arraySet = current_meta.tags; - wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _m, rx, ry); - break; + case "textArrayBox" : meta_tb[j].arraySet = current_meta.tags; break; + } + + wh = meta_tb[j].drawParam(_param); + + if(viewMode == INSP_VIEW_MODE.spacious) { + yy += wh + ui(8); + hh += wh + ui(8); + + } else if(viewMode == INSP_VIEW_MODE.compact) { + yy += max(wh, _lh) + ui(6); + hh += max(wh, _lh) + ui(6); } - - yy += wh + ui(8); - hh += wh + ui(8); } + break; + case 2 : if(findPanel("Panel_Globalvar")) { yy += ui(4); hh += ui(4); continue; } - + var gvh = globalvar_viewer_draw(ui(16), yy, contentPane.surface_w - ui(24), _m, pFOCUS, _hover, contentPane, ui(16) + x, top_bar_h + y); yy += gvh + ui(8); hh += gvh + ui(8); @@ -386,7 +429,7 @@ function Panel_Inspector() : PanelContent() constructor { var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; var byc = by + bh / 2; draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); - draw_text_add(bxc + ui(48), byc, txt); + draw_text_over(bxc + ui(48), byc, txt); bx += bw + ui(4); @@ -400,7 +443,7 @@ function Panel_Inspector() : PanelContent() constructor { var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; var byc = by + bh / 2; draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); - draw_text_add(bxc + ui(48), byc, txt); + draw_text_over(bxc + ui(48), byc, txt); } else { var bw = bbw; @@ -415,9 +458,11 @@ function Panel_Inspector() : PanelContent() constructor { var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; var byc = by + bh / 2; draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); - draw_text_add(bxc + ui(48), byc, txt); + draw_text_over(bxc + ui(48), byc, txt); } + break; + case 3 : var context = PANEL_GRAPH.getCurrentContext(); var _h = drawNodeProperties(yy, _m, context); @@ -427,8 +472,8 @@ function Panel_Inspector() : PanelContent() constructor { break; } - yy += ui(8); - hh += ui(8); + yy += viewMode == INSP_VIEW_MODE.spacious? ui(8) : ui(4); + hh += viewMode == INSP_VIEW_MODE.spacious? ui(8) : ui(4); } return hh; @@ -885,13 +930,6 @@ function Panel_Inspector() : PanelContent() constructor { draw_sprite_ui_uniform(THEME.preset, 1, bx + ui(32) / 2, by + ui(32) / 2, 1, COLORS._main_icon_dark); } - by += ui(36); - view_mode_tooltip.index = viewMode; - if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, view_mode_tooltip, THEME.inspector_view, viewMode) == 2) { - viewMode = !viewMode; - PREFERENCES.inspector_view_default = viewMode; - } - //////////////////////////////////////////////////////////////////// INSPECTOR ACTIONS //////////////////////////////////////////////////////////////////// var bx = w - ui(44); @@ -937,6 +975,12 @@ function Panel_Inspector() : PanelContent() constructor { if(inspecting && !inspecting.active) inspecting = noone; + view_mode_tooltip.index = viewMode; + if(buttonInstant(THEME.button_hide, ui(8), ui(48), ui(32), ui(32), [mx, my], pFOCUS, pHOVER, view_mode_tooltip, THEME.inspector_view, viewMode) == 2) { + viewMode = !viewMode; + PREFERENCES.inspector_view_default = viewMode; + } + if(inspecting) { var _nodes = PANEL_GRAPH.nodes_selecting; diff --git a/scripts/render_data/render_data.gml b/scripts/render_data/render_data.gml index 14157f0ac..a66f37cb7 100644 --- a/scripts/render_data/render_data.gml +++ b/scripts/render_data/render_data.gml @@ -33,7 +33,7 @@ function ResetAllNodesRender() { #region } #endregion function NodeTopoSort() { #region - //print($"======================= RESET TOPO =======================") + LOG_IF(global.FLAG.render == 1, $"======================= RESET TOPO =======================") var _key = ds_map_find_first(PROJECT.nodeMap); var amo = ds_map_size(PROJECT.nodeMap); @@ -48,7 +48,7 @@ function NodeTopoSort() { #region ds_list_clear(PROJECT.nodeTopo); __topoSort(PROJECT.nodeTopo, PROJECT.nodes); - LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++"); + LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)}/{amo} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++"); } #endregion function NodeListSort(_list, _nodeList) { #region @@ -93,6 +93,7 @@ function __sortNode(_list, _node) { #region function __topoSort(_list, _nodeList) { #region var _root = []; var _leftOver = []; + var _global = _nodeList == PROJECT.nodes; for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ ) { var _node = _nodeList[| i]; @@ -103,17 +104,18 @@ function __topoSort(_list, _nodeList) { #region continue; } - for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) { - var _to = _node.outputs[| j].getJunctionTo(); + if(_node.attributes.show_update_trigger && !array_empty(_node.updatedOutTrigger.getJunctionTo())) { + _isRoot = false; - for( var k = 0, p = array_length(_to); k < p; k++ ) { - if(ds_list_exist(_nodeList, _to[k].node)) { - _isRoot = false; - break; - } + } else { + for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) { + var _to = _node.outputs[| j].getJunctionTo(); + + if(_global) _isRoot &= array_empty(_to); + else _isRoot &= !array_any(_to, function(_val) { return ds_list_exist(_nodeList, _val.node); } ); + + if(!_isRoot) break; } - - if(!_isRoot) break; } if(_isRoot) array_push(_root, _node);