From 1bf10aac2eed42c859dee78cbd387020e4fd2aa9 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 1 Jun 2024 19:08:24 +0700 Subject: [PATCH] - [CurveBox] Improve view control. --- objects/o_dialog_menubox/Create_0.gml | 3 +- objects/o_dialog_menubox/Draw_64.gml | 16 +- scripts/curveBox/curveBox.gml | 288 ++++++++++++------ .../curve_bezier_function.gml | 51 ++-- scripts/dynaSurf_iso/dynaSurf_iso.gml | 26 +- scripts/nodeValue_drawer/nodeValue_drawer.gml | 30 +- scripts/node_array/node_array.gml | 1 + scripts/node_isosurf/node_isosurf.gml | 53 ++-- scripts/panel_inspector/panel_inspector.gml | 3 +- 9 files changed, 300 insertions(+), 171 deletions(-) diff --git a/objects/o_dialog_menubox/Create_0.gml b/objects/o_dialog_menubox/Create_0.gml index 0550a6b25..98dbf4af4 100644 --- a/objects/o_dialog_menubox/Create_0.gml +++ b/objects/o_dialog_menubox/Create_0.gml @@ -17,7 +17,8 @@ event_inherited(); show_icon = false; context = noone; - _hovering_ch = true; + _hovering_ch = true; + init_pressing = false; setFocus(self.id); diff --git a/objects/o_dialog_menubox/Draw_64.gml b/objects/o_dialog_menubox/Draw_64.gml index 20701420b..64f0a1622 100644 --- a/objects/o_dialog_menubox/Draw_64.gml +++ b/objects/o_dialog_menubox/Draw_64.gml @@ -168,21 +168,7 @@ if(!ready) exit; draw_sprite_stretched(THEME.menu_bg, 1, dialog_x, dialog_y, dialog_w, dialog_h); - //draw_set_color(c_red); - //draw_set_alpha(_hovering_ch * 0.5 + 0.5); - //draw_circle(dialog_x, dialog_y, 6, false); - - //draw_set_color(c_lime); - //draw_set_alpha(sHOVER * 0.5 + 0.5); - //draw_circle(dialog_x + 16, dialog_y, 6, false); - - //draw_set_color(c_yellow); - //draw_set_alpha(sFOCUS * 0.5 + 0.5); - //draw_circle(dialog_x + 32, dialog_y, 6, false); - - //draw_set_alpha(1); - - if(mouse_inside && mouse_release(mb_left)) mouse_inside = false; + if(mouse_inside && (mouse_release(mb_left) || mouse_release(mb_right))) mouse_inside = false; #endregion #region debug diff --git a/scripts/curveBox/curveBox.gml b/scripts/curveBox/curveBox.gml index 3b15a57d0..ebe0c3981 100644 --- a/scripts/curveBox/curveBox.gml +++ b/scripts/curveBox/curveBox.gml @@ -4,17 +4,21 @@ function curveBox(_onModify) : widget() constructor { curve_surface = surface_create(1, 1); node_dragging = -1; node_drag_typ = -1; - zoom_level = 1; - zoom_level_to = 1; - zoom_min = 1; - zoom_max = 3; - zooming = false; + + h = 160; + height_drag = false; + height_my = 0; + height_ss = 0; show_coord = false; - miny = 0; - maxy = 1; + minx = 0; maxx = 1; + miny = 0; maxy = 1; + dragging = 0; + drag_m = 0; + drag_s = 0; + drag_h = 0; progress_draw = -1; display_pos_x = 0; @@ -22,11 +26,14 @@ function curveBox(_onModify) : widget() constructor { display_sel = 0; grid_snap = false; - grid_step = 0.05; - grid_show = false; + grid_step = 0.10; + grid_show = true; - static get_x = function(val, _x, _w) { return _x + _w * val; } - static get_y = function(val, _y, _h) { return _y + _h * (1 - (val - miny) / (maxy - miny)); } + cw = 0; + ch = 0; + + static get_x = function(val) { return cw * (val - minx) / (maxx - minx); } + static get_y = function(val) { return ch * (1 - (val - miny) / (maxy - miny)); } static register = function() {} @@ -34,45 +41,52 @@ function curveBox(_onModify) : widget() constructor { rx = params.rx; ry = params.ry; - return draw(params.x, params.y, params.w, params.h, params.data, params.m); + return draw(params.x, params.y, params.w, params.data, params.m); } - static draw = function(_x, _y, _w, _h, _data, _m) { + static draw = function(_x, _y, _w, _data, _m) { x = _x; y = _y; w = _w; - h = _h; - var drawScale = _w - ui(32) > ui(100); - var cw = drawScale? _w - ui(32) : _w; + var _h = h - ui(4); + + var zoom_size = ui(12); + var zoom_padd = zoom_size + ui(8); + + cw = _w - zoom_padd; + ch = _h - zoom_padd; + hovering = false; if(!is_array(_data) || array_length(_data) == 0) return 0; if(is_array(_data[0])) return 0; - var points = array_length(_data) / 6; + var points = array_length(_data) / 6; #region display - zoom_level = lerp_float(zoom_level, zoom_level_to, 2); - miny = 0.5 - 0.5 * zoom_level; - maxy = 0.5 + 0.5 * zoom_level; - - display_pos_x = clamp((_m[0] - _x) / cw, 0, 1); - display_pos_y = lerp(miny, maxy, 1 - (_m[1] - _y) / _h); + display_pos_x = lerp(minx, maxx, (_m[0] - _x) / cw); + display_pos_y = lerp(miny, maxy, 1 - (_m[1] - _y) / ch); display_sel = false; #endregion - curve_surface = surface_verify(curve_surface, cw, _h); + curve_surface = surface_verify(curve_surface, cw, ch); if(node_dragging != -1) { #region editing show_coord = true; _data = array_clone(_data); if(node_drag_typ == 0) { + + var _mx = (_m[0] - _x) / cw; + _mx = clamp(_mx * (maxx - minx) + minx, 0, 1); + + var _my = 1 - (_m[1] - _y) / ch; + _my = clamp(_my * (maxy - miny) + miny, 0, 1); + var node_point = (node_dragging - 2) / 6; if(node_point > 0 && node_point < points - 1) { - var _mx = (_m[0] - _x) / cw; - _mx = clamp(_mx, 0, 1); + if(key_mod_press(CTRL) || grid_snap) _mx = value_snap(_mx, grid_step); @@ -84,9 +98,8 @@ function curveBox(_onModify) : widget() constructor { else _data[node_dragging + 0] = _mx; } - var _my = 1 - (_m[1] - _y) / _h; - _my = clamp(_my * (maxy - miny) + miny, 0, 1); - if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step); + if(key_mod_press(CTRL) || grid_snap) + _my = value_snap(_my, grid_step); _data[node_dragging + 1] = _my; display_pos_x = _data[node_dragging + 0]; @@ -127,13 +140,15 @@ function curveBox(_onModify) : widget() constructor { var _py = _data[node_dragging + 1]; var _mx = (_m[0] - _x) / cw; - _mx = clamp(_mx, 0, 1); + _mx = clamp(lerp(minx, maxx, _mx), 0, 1); + + var _my = 1 - (_m[1] - _y) / ch; + _my = lerp(miny, maxy, _my); + if(key_mod_press(CTRL) || grid_snap) _mx = value_snap(_mx, grid_step); _data[node_dragging - 2] = (_px - _mx) * node_drag_typ; _data[node_dragging + 2] = (_mx - _px) * node_drag_typ; - var _my = 1 - (_m[1] - _y) / _h; - _my = lerp(miny, maxy, _my); if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step); _data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ; _data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ; @@ -162,9 +177,10 @@ function curveBox(_onModify) : widget() constructor { var msx = _m[0] - _x; var msy = _m[1] - _y; - #region ==== draw ==== + #region ==== draw curve ==== surface_set_target(curve_surface); - DRAW_CLEAR + DRAW_CLEAR + draw_set_color(COLORS.widget_curve_line); draw_set_alpha(0.75); @@ -172,27 +188,28 @@ function curveBox(_onModify) : widget() constructor { var st = max(grid_step, 0.02); for( var i = st; i < 1; i += st ) { - var y0 = _h - _h * (i - miny) / (maxy - miny); + var y0 = ch * (1 - (i - miny) / (maxy - miny)); draw_line(0, y0, cw, y0); - var x0 = cw * i; - draw_line(x0, 0, x0, _h); + var x0 = cw * (i - minx) / (maxx - minx); + draw_line(x0, get_y(0), x0, get_y(1)); } } + var y0 = ch - ch * (0 - miny) / (maxy - miny); + var y1 = ch - ch * (1 - miny) / (maxy - miny); + draw_set_alpha(0.9); - var y0 = _h - _h * (0 - miny) / (maxy - miny); draw_line(0, y0, cw, y0); - var y1 = _h - _h * (1 - miny) / (maxy - miny); draw_line(0, y1, cw, y1); draw_set_alpha(1); if(progress_draw > -1) { var _prg = clamp(progress_draw, 0, 1); + var _px = get_x(cw * _prg); - var _px = cw * _prg; draw_set_color(COLORS.widget_curve_line); - draw_line(_px, 0, _px, _h); + draw_line(_px, 0, _px, ch); } for( var i = 0; i < points; i++ ) { @@ -204,17 +221,17 @@ function curveBox(_onModify) : widget() constructor { var ax0 = _x0 + _data[ind + 4]; var ay0 = _y0 + _data[ind + 5]; - bx0 = get_x(bx0, 0, cw); - by0 = get_y(by0, 0, _h); - _x0 = get_x(_x0, 0, cw); - _y0 = get_y(_y0, 0, _h); - ax0 = get_x(ax0, 0, cw); - ay0 = get_y(ay0, 0, _h); + bx0 = get_x(bx0); + by0 = get_y(by0); + _x0 = get_x(_x0); + _y0 = get_y(_y0); + ax0 = get_x(ax0); + ay0 = get_y(ay0); draw_set_color(COLORS.widget_curve_line); if(i > 0) { //draw pre line draw_line(bx0, by0, _x0, _y0); - + draw_circle_prec(bx0, by0, 3, false); if(hover && point_in_circle(msx, msy, bx0, by0, 10)) { draw_circle_prec(bx0, by0, 5, false); @@ -260,62 +277,151 @@ function curveBox(_onModify) : widget() constructor { } draw_set_color(COLORS._main_accent); - draw_curve(0, 0, cw, -_h, _data, miny, maxy); + draw_curve(0, 0, cw, ch, _data, minx, maxx, miny, maxy); surface_reset_target(); #endregion - #region ==== buttons ==== - if(drawScale) { - var bs = ui(20); + #region ==== view controls ==== - var bxF = _x + cw + ui(8); - var bx = bxF + ui(0); + var hov = 0; + var bs = zoom_size; - var by0 = _y; - var by1 = _y + _h - bs + ui(2); + var zminy = 0 - 1; + var zmaxy = 1 + 1; - var byF = _y + (bs + ui(6)); - var byH = _h + ui(2) - (bs + ui(6)) * 2; + var byH = _h - zoom_padd; - draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, bxF, byF, bs, byH, COLORS.assetbox_current_bg, 1); + var bx = _x + w - bs; + var by = _y; + var zy0 = by + bs / 2 + (byH - bs) * (1 - (miny - zminy) / (zmaxy - zminy)); + var zy1 = by + bs / 2 + (byH - bs) * (1 - (maxy - zminy) / (zmaxy - zminy)); - var zH = ui(16); - var zy = byF + zH / 2 + (byH - zH) * (zoom_level_to - zoom_min) / (zoom_max - zoom_min); - - if(zooming) { - zoom_level_to = lerp(zoom_min, zoom_max, clamp((_m[1] - byF - zH / 2) / (byH - zH), 0, 1)); + if(dragging) { + var _mdy = (drag_m[1] - _m[1]) / (byH - bs) * 2; - if(mouse_release(mb_left)) - zooming = false; - } - - var cc = merge_color(COLORS._main_icon, COLORS._main_icon_dark, 0.5); - if(point_in_rectangle(_m[0], _m[1], bxF, byF, _x + _w, byF + byH)) { - cc = COLORS._main_icon; - if(mouse_press(mb_left, active)) - zooming = true; - } - - draw_sprite_stretched_ext(THEME.timeline_dopesheet_bg, 0, bxF, zy - zH / 2, bs, zH, cc, 1); - - if(buttonInstant(THEME.button_hide, bx, by0, bs, bs, _m, active, hover,, THEME.add_16) == 2) - zoom_level_to = clamp(zoom_level_to - 1, zoom_min, zoom_max); + if(dragging == 1 || dragging == 3) miny = clamp(drag_s[0] + _mdy, zminy, min(maxy - 0.1, zmaxy)); + if(dragging == 2 || dragging == 3) maxy = clamp(drag_s[1] + _mdy, max(miny + 0.1, zminy), zmaxy); - if(buttonInstant(THEME.button_hide, bx, by1, bs, bs, _m, active, hover,, THEME.minus_16) == 2) - zoom_level_to = clamp(zoom_level_to + 1, zoom_min, zoom_max); + if(mouse_release(mb_left)) + dragging = false; + } + + if(point_in_rectangle(_m[0], _m[1], bx, zy0 - bs / 2, bx + bs, zy0 + bs / 2)) + hov = 1; + else if(point_in_rectangle(_m[0], _m[1], bx, zy1 - bs / 2, bx + bs, zy1 + bs / 2)) + hov = 2; + else if(point_in_rectangle(_m[0], _m[1], bx, zy1 - bs / 2, bx + bs, zy0 + bs / 2)) + hov = 3; + + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, bx, by, bs, byH, CDEF.main_black, 1); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, bx, zy1, bs, zy0 - zy1, drag_h == 3? merge_color(CDEF.main_dkgrey, CDEF.main_grey, 0.4) : CDEF.main_dkgrey, 1); + + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, bx, zy0 - bs / 2, bs, bs, drag_h == 1? COLORS._main_icon_light : COLORS._main_icon, 1); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, bx, zy1 - bs / 2, bs, bs, drag_h == 2? COLORS._main_icon_light : COLORS._main_icon, 1); + + var zminx = 0; + var zmaxx = 1; + + var bxW = _w - zoom_padd; + var bx = _x; + var by = _y + _h - bs; + + var zx0 = bx + bs / 2 + (bxW - bs) * (minx - zminx) / (zmaxx - zminx); + var zx1 = bx + bs / 2 + (bxW - bs) * (maxx - zminx) / (zmaxx - zminx); + + if(dragging) { + var _mdx = (_m[0] - drag_m[0]) / (bxW - bs); + + if(dragging == 4 || dragging == 6) minx = clamp(drag_s[2] + _mdx, zminx, min(maxx - 0.1, zmaxx)); + if(dragging == 5 || dragging == 6) maxx = clamp(drag_s[3] + _mdx, max(minx + 0.1, zminx), zmaxx); + + if(mouse_release(mb_left)) + dragging = false; + } + + if(point_in_rectangle(_m[0], _m[1], zx0 - bs / 2, by, zx0 + bs / 2, by + bs)) + hov = 4; + else if(point_in_rectangle(_m[0], _m[1], zx1 - bs / 2, by, zx1 + bs / 2, by + bs)) + hov = 5; + else if(point_in_rectangle(_m[0], _m[1], zx0 - bs / 2, by, zx1 + bs / 2, by + bs)) + hov = 6; + + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, bx, by, bxW, bs, CDEF.main_black, 1); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, zx0, by, zx1 - zx0, bs, drag_h == 6? merge_color(CDEF.main_dkgrey, CDEF.main_grey, 0.4) : CDEF.main_dkgrey, 1); + + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, zx0 - bs / 2, by, bs, bs, drag_h == 4? COLORS._main_icon_light : COLORS._main_icon, 1); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, zx1 - bs / 2, by, bs, bs, drag_h == 5? COLORS._main_icon_light : COLORS._main_icon, 1); + + drag_h = hov; + if(mouse_press(mb_left, hov && active)) { + dragging = hov; + drag_m = [ _m[0], _m[1] ]; + drag_s = [ miny, maxy, minx, maxx ]; + } + + if(dragging == 10) { + var _mdx = (_m[0] - drag_m[0]) / (bxW - bs); + var _mdy = (drag_m[1] - _m[1]) / (byH - bs) * 2; + + var zw = drag_s[3] - drag_s[2]; + var zh = drag_s[1] - drag_s[0]; + + var cx = clamp((drag_s[3] + drag_s[2]) / 2 - _mdx, zminx + zw / 2, zmaxx - zw / 2); + var cy = clamp((drag_s[1] + drag_s[0]) / 2 - _mdy, zminy + zh / 2, zmaxy - zh / 2); + + minx = cx - zw / 2; + maxx = cx + zw / 2; + + miny = cy - zh / 2; + maxy = cy + zh / 2; + + if(mouse_release(mb_middle)) + dragging = false; + } + + if(point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + ch) && mouse_press(mb_middle, active)) { + dragging = 10; + drag_m = [ _m[0], _m[1] ]; + drag_s = [ miny, maxy, minx, maxx ]; + } + + var _bhx = _x + _w - bs; + var _bhy = _y + _h - bs; + var _hov = false; + + if(point_in_rectangle(_m[0], _m[1], _bhx, _bhy, _bhx + bs, _bhy + bs)) { + _hov = true; + if(mouse_press(mb_left, active)) { + dragging = hov; + + height_drag = true; + height_my = _m[1]; + height_ss = h; + } + + } + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _bhx, _bhy, bs, bs, _hov? COLORS._main_icon : CDEF.main_dkgrey, 1); + // draw_sprite_ext(THEME.circle, 0, _bhx + bs / 2, _bhy + bs / 2, 1, 1, 0, COLORS._main_icon_light, 1); + + if(height_drag) { + h = height_ss + _m[1] - height_my; + h = max(100, h); + + if(mouse_release(mb_left)) + height_drag = false; } #endregion - if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + _h)) { #region + if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + ch)) { #region show_coord = true; hovering = true; if(mouse_press(mb_left, active)) { if(node_hovering == -1) { var _ind = point_insert * 6; - var _px = (_m[0] - _x) / cw; - var _py = 1 - (_m[1] - _y) / _h; + var _px = (_m[0] - _x) / cw; + var _py = 1 - (_m[1] - _y) / ch; array_insert(_data, _ind + 0, -0.1); array_insert(_data, _ind + 1, 0); @@ -325,7 +431,7 @@ function curveBox(_onModify) : widget() constructor { array_insert(_data, _ind + 5, 0); if(onModify(_data)) UNDO_HOLDING = true; - + node_dragging = _ind + 2; node_drag_typ = 0; } else { @@ -350,6 +456,10 @@ function curveBox(_onModify) : widget() constructor { [ [THEME.curve_presets, 3], function() { onModify(CURVE_DEF_10); } ], ]), -1, + menuItem(__txt("Reset View"), function() { + minx = 0; maxx = 1; + miny = 0; maxy = 1; + }), menuItem(grid_show? __txt("Hide grid") : __txt("Show grid"), function() { grid_show = !grid_show; }), menuItem(__txt("Snap to grid"), function() { grid_snap = !grid_snap; },,, function() { return grid_snap } ), menuItemGroup(__txt("Grid size"), [ @@ -361,14 +471,15 @@ function curveBox(_onModify) : widget() constructor { ]); } } #endregion - + draw_surface(curve_surface, _x, _y); + draw_set_color(COLORS.widget_curve_outline); - draw_rectangle(_x, _y, _x + cw, _y + _h, true); + draw_rectangle(_x, _y, _x + cw, _y + ch, true); if(show_coord) { var tx = _x + cw - ui(6); - var ty = _y + _h - ui(6); + var ty = _y + ch - ui(6); draw_set_text(f_p2, fa_right, fa_bottom, display_sel? COLORS._main_text: COLORS._main_text_sub); draw_text_add(tx, ty, $"{display_sel == 2? "dy" : "y"}: {string_format(display_pos_y * 100, -1, 2)}%"); @@ -385,7 +496,6 @@ function curveBox(_onModify) : widget() constructor { static clone = function() { #region var cln = new curveBox(onModify); - return cln; } #endregion } \ No newline at end of file diff --git a/scripts/curve_bezier_function/curve_bezier_function.gml b/scripts/curve_bezier_function/curve_bezier_function.gml index 63d2c83e3..d05c0cb2e 100644 --- a/scripts/curve_bezier_function/curve_bezier_function.gml +++ b/scripts/curve_bezier_function/curve_bezier_function.gml @@ -6,15 +6,15 @@ #macro CURVE_DEF_10 [0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0] #macro CURVE_DEF_11 [0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0] -function draw_curve(x0, y0, _w, _h, _bz, miny = 0, maxy = 1) { #region +function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1) { #region var segments = array_length(_bz) / 6 - 1; + var _ox, _oy; for( var i = 0; i < segments; i++ ) { var ind = i * 6; + var _x0 = _bz[ind + 2]; var _y0 = _bz[ind + 3]; - //var bx0 = _x0 + _bz[ind + 0]; - //var by0 = _y0 + _bz[ind + 1]; var ax0 = _x0 + _bz[ind + 4]; var ay0 = _y0 + _bz[ind + 5]; @@ -22,35 +22,28 @@ function draw_curve(x0, y0, _w, _h, _bz, miny = 0, maxy = 1) { #region var _y1 = _bz[ind + 6 + 3]; var bx1 = _x1 + _bz[ind + 6 + 0]; var by1 = _y1 + _bz[ind + 6 + 1]; - //var ax1 = _x1 + _bz[ind + 6 + 4]; - //var ay1 = _y1 + _bz[ind + 6 + 5]; - var dx0 = x0 + _w * _x0; - var dx1 = x0 + _w * _x1; - var dw = dx1 - dx0; - var smp = ceil((_x1 - _x0) * 32); + var smp = ceil((_x1 - _x0) / (maxx - minx) * 32); + var bbz = [ _y0, ax0, ay0, bx1, by1, _y1 ]; - draw_curve_segment(dx0, y0, dw, _h, [_y0, ax0, ay0, bx1, by1, _y1], smp, miny, maxy); - } -} #endregion - -function draw_curve_segment(x0, y0, _w, _h, _bz, SAMPLE = 32, miny = 0, maxy = 1) { #region - var _ox, _oy; - - for(var i = 0; i <= SAMPLE; i++) { - var t = i / SAMPLE; - var _r = eval_curve_segment_t_position(t, _bz); - var _rx = _r[0], _ry = _r[1]; - _ry = (_ry - miny) / (maxy - miny); + if(_x1 < minx) continue; - var _nx = _rx * _w + x0; - var _ny = (_h? _ry : 1 - _ry) * abs(_h) + y0; - - if(i) - draw_line(_ox, _oy, _nx, _ny); - - _ox = _nx; - _oy = _ny; + for(var j = 0; j <= smp; j++) { + var t = j / smp; + var _r = eval_curve_segment_t_position(t, bbz); + var _rx = ((_x0 + _r[0] * (_x1 - _x0)) - minx) / (maxx - minx); + var _ry = (_r[1] - miny) / (maxy - miny); + + var _nx = x0 + _w * _rx; + var _ny = y0 + _h * (1 - _ry); + + if(j) draw_line(_ox, _oy, _nx, _ny); + + _ox = _nx; + _oy = _ny; + + if(_nx > x0 + _w) return; + } } } #endregion diff --git a/scripts/dynaSurf_iso/dynaSurf_iso.gml b/scripts/dynaSurf_iso/dynaSurf_iso.gml index 24fcbe8dd..950dac398 100644 --- a/scripts/dynaSurf_iso/dynaSurf_iso.gml +++ b/scripts/dynaSurf_iso/dynaSurf_iso.gml @@ -1,8 +1,10 @@ function dynaSurf_iso() : dynaSurf() constructor { - angles = []; + angles = []; + offsetx = []; + offsety = []; angle_shift = 0; - static getSurface = function(_rot) { + static getIndex = function(_rot) { _rot += angle_shift; var _ind = 0; var _minA = 360; @@ -15,14 +17,18 @@ function dynaSurf_iso() : dynaSurf() constructor { } } - return array_safe_get_fast(surfaces, _ind); + return _ind; } static draw = function(_x = 0, _y = 0, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alp = 1) { - var _surf = getSurface(_rot); + var _ind = getIndex(_rot); + var _surf = array_get(surfaces, _ind); + var _offx = array_get(offsetx, _ind); + var _offy = array_get(offsety, _ind); + var _pos = getAbsolutePos(_x, _y, _xs, _ys, _rot); - draw_surface_ext_safe(_surf, _pos[0], _pos[1], _xs, _ys, 0, _col, _alp); + draw_surface_ext_safe(_surf, _pos[0] + _offx, _pos[1] + _offy, _xs, _ys, 0, _col, _alp); } static drawTile = function(_x = 0, _y = 0, _xs = 1, _ys = 1, _col = c_white, _alp = 1) { @@ -31,14 +37,20 @@ function dynaSurf_iso() : dynaSurf() constructor { } static drawPart = function(_l, _t, _w, _h, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alp = 1) { - var _surf = getSurface(_rot); - draw_surface_part_ext_safe(_surf, _l, _t, _w, _h, _x, _y, _xs, _ys, 0, _col, _alp); + var _ind = getIndex(_rot); + var _surf = array_get(surfaces, _ind); + var _offx = array_get(offsetx, _ind); + var _offy = array_get(offsety, _ind); + + draw_surface_part_ext_safe(_surf, _l, _t, _w, _h, _x + _offx, _y + _offy, _xs, _ys, 0, _col, _alp); } static clone = function() { var _new = new dynaSurf_iso(); _new.surfaces = surface_array_clone(surfaces); _new.angles = array_clone(angles); + _new.offsetx = array_clone(offsetx); + _new.offsety = array_clone(offsety); _new.angle_shift = angle_shift; return _new; diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index 314a82807..63cf74bd0 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -263,13 +263,21 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc var padd = ui(8); var labelWidth = max(lb_w, min(ww * 0.4, ui(200))); - var editBoxX = xx + !breakLine * labelWidth; - var editBoxY = breakLine? _hsy : yy; + var widExtend = breakLine; + + switch(jun.type) { + case VALUE_TYPE.curve : + widExtend = true; + break; + } + + var editBoxX = xx + !widExtend * labelWidth; + var editBoxY = widExtend? _hsy : yy; var editBoxW = (xx + ww) - editBoxX; - var editBoxH = breakLine? TEXTBOX_HEIGHT : lb_h; + var editBoxH = widExtend? TEXTBOX_HEIGHT : lb_h; - var widH = breakLine? editBoxH : 0; + var widH = widExtend? editBoxH : 0; var mbRight = true; if(jun.expUse) { #region expression editor @@ -282,8 +290,9 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc if(_focus) jun.express_edit.register(_scrollPane); var wd_h = jun.express_edit.draw(editBoxX, editBoxY, editBoxW, editBoxH, jun.expression, _m); - widH = wd_h - (TEXTBOX_HEIGHT * !breakLine); + widH = wd_h - (TEXTBOX_HEIGHT * !widExtend); #endregion + } else if(wid && jun.display_type != VALUE_DISPLAY.none) { #region edit widget wid.setFocusHover(_focus, _hover); @@ -319,10 +328,10 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc case VALUE_TYPE.boolean : if(is_instanceof(wid, checkBoxActive)) break; - param.halign = breakLine? fa_left : fa_center; + param.halign = widExtend? fa_left : fa_center; param.s = editBoxH; - if(!breakLine) { + if(!widExtend) { param.w = ww - min(ui(80) + ww * 0.2, ui(200)); param.x = editBoxX + editBoxW - param.w; } @@ -330,18 +339,17 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc case VALUE_TYPE.d3Material : case VALUE_TYPE.surface : - param.h = breakLine? ui(96) : ui(48); + param.h = widExtend? ui(96) : ui(48); break; case VALUE_TYPE.curve : - param.h = breakLine? ui(160) : ui(100); - if(point_in_rectangle(_m[0], _m[1], ui(32), _hsy, ui(32) + ww - ui(16), _hsy + param.h)) + if(point_in_rectangle(_m[0], _m[1], ui(32), _hsy, ui(32) + ww - ui(16), _hsy + wid.h)) mbRight = false; break; } var _widH = wid.drawParam(param) ?? 0; - widH = _widH - (TEXTBOX_HEIGHT * !breakLine); + widH = _widH - (TEXTBOX_HEIGHT * !widExtend); mbRight &= wid.right_click_block; #endregion diff --git a/scripts/node_array/node_array.gml b/scripts/node_array/node_array.gml index c9500142e..06bffd068 100644 --- a/scripts/node_array/node_array.gml +++ b/scripts/node_array/node_array.gml @@ -91,6 +91,7 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { static updateType = function(resetVal = false) { #region var _typ = getType(); + if(getInputAmount() <= 0) return; if(_typ == VALUE_TYPE.any && inputs[| input_fix_len].value_from) outputs[| 0].setType(inputs[| input_fix_len].value_from.type); diff --git a/scripts/node_isosurf/node_isosurf.gml b/scripts/node_isosurf/node_isosurf.gml index c1dd5c191..861db6cea 100644 --- a/scripts/node_isosurf/node_isosurf.gml +++ b/scripts/node_isosurf/node_isosurf.gml @@ -14,12 +14,16 @@ function Node_IsoSurf(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c .setArrayDynamic() .setArrayDepth(1); + inputs[| 4] = nodeValue("Offsets", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, []) + .setDisplay(VALUE_DISPLAY.vector) + .setArrayDepth(1); + outputs[| 0] = nodeValue("IsoSurf", self, JUNCTION_CONNECT.output, VALUE_TYPE.dynaSurface, noone); knob_hover = noone; knob_dragging = noone; - drag_sv = 0; - drag_sa = 0; + drag_sv = 0; + drag_sa = 0; angle_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region var hh = ui(240); @@ -89,30 +93,45 @@ function Node_IsoSurf(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c }); #endregion input_display_list = [ - ["Iso", false], 0, 2, angle_renderer, - ["Surfaces", false], 1, + ["Iso", false], 0, 2, angle_renderer, + ["Data", false], 1, 4, ]; static onValueUpdate = function(index) { - if(index == 0) { - var _amo = getInputData(0); - var _ang = array_create(_amo); - - for( var i = 0, n = _amo; i < n; i++ ) - _ang[i] = 360 * (i / _amo); - inputs[| 3].setValue(_ang); + if(index != 0) return; + + var _amo = getInputData(0); + var _ang = array_create(_amo); + var _off = array_create(_amo); + + for( var i = 0, n = _amo; i < n; i++ ) { + _ang[i] = 360 * (i / _amo); + _off[i] = [ 0, 0 ]; } + + inputs[| 3].setValue(_ang); + inputs[| 4].setValue(_off); } static processData = function(_outSurf, _data, _output_index, _array_index) { - var _amo = _data[0]; - var _surf = _data[1]; - var _ashft = _data[2]; - var _angle = _data[3]; - var _iso = new dynaSurf_iso(); + var _amo = _data[0]; + var _surf = _data[1]; + var _ashft = _data[2]; + var _angle = _data[3]; + var _offset = _data[4]; + var _iso = new dynaSurf_iso(); - for( var i = 0; i < _amo; i++ ) + _iso.offsetx = array_create(_amo); + _iso.offsety = array_create(_amo); + + for( var i = 0; i < _amo; i++ ) { _iso.surfaces[i] = array_safe_get_fast(_surf, i, noone); + + var _off = array_safe_get_fast(_offset, i); + _iso.offsetx[i] = array_safe_get_fast(_off, 0); + _iso.offsety[i] = array_safe_get_fast(_off, 1); + } + _iso.angles = _angle; _iso.angle_shift = _ashft; diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 672eb7fb3..6414c1422 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -559,7 +559,6 @@ function Panel_Inspector() : PanelContent() constructor { return hh; } #endregion - var color_picker_selecting = noone; var color_picker_index = 0; var pickers = []; var _colsp = false; @@ -834,7 +833,7 @@ function Panel_Inspector() : PanelContent() constructor { prop_highlight = noone; } - return hh; + return hh + ui(64); } #endregion contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region