From c3f1ffa58e2f505928bd597c004548ee859c0a28 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 23 Jun 2024 14:36:51 +0700 Subject: [PATCH] - [Preview Panel] Hovering on gradient map anchor now show mapped surface. --- scripts/node_value/node_value.gml | 13 +++++-------- .../preview_overlay_gradient_range.gml | 14 ++++++++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 5d1aaa770..981c3ba37 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -369,15 +369,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru mapButton = button(function() { attributes.mapped = !attributes.mapped; - var val = getValue(); - if( attributes.mapped) - setValue(mapped_vec4? [ 0, 0, 0, 0 ] : [ 0, 0 ]); - - if(!attributes.mapped) - setValue(def_val); - - setArrayDepth(attributes.mapped); + if(type == VALUE_TYPE.integer || type == VALUE_TYPE.float) { + if(attributes.mapped) setValue(mapped_vec4? [ 0, 0, 0, 0 ] : [ 0, 0 ]); + else setValue(def_val); + setArrayDepth(attributes.mapped); + } node.triggerRender(); }) diff --git a/scripts/preview_overlay_gradient_range/preview_overlay_gradient_range.gml b/scripts/preview_overlay_gradient_range/preview_overlay_gradient_range.gml index 18ae9c3fc..3afd8cd5b 100644 --- a/scripts/preview_overlay_gradient_range/preview_overlay_gradient_range.gml +++ b/scripts/preview_overlay_gradient_range/preview_overlay_gradient_range.gml @@ -1,6 +1,9 @@ function preview_overlay_gradient_range(interact, active, _x, _y, _s, _mx, _my, _snx, _sny, _dim) { - var _val = array_clone(getValue()); - var hover = -1; + var _val = array_clone(getValue()); + var _targI = node.inputs[| mappedJunc.attributes.map_index]; + var _surf = _targI.getValue(); + + var hover = -1; if(!is_array(_val) || array_empty(_val)) return hover; if(is_array(_val[0])) return hover; @@ -20,6 +23,10 @@ function preview_overlay_gradient_range(interact, active, _x, _y, _s, _mx, _my, var cc = COLORS.labels[2]; var _r = 10; + __overlay_hover = array_verify(__overlay_hover, 2); + if(surface_exists(_surf) && (__overlay_hover[0] > 0 || __overlay_hover[1] > 0)) + draw_surface_stretched_ext(_surf, _x, _y, _sw * _s, _sh * _s, c_white, 0.25); + draw_set_text(f_p1, fa_left, fa_bottom, cc); draw_text_add(_ax0 + ui(4), _ay0 - ui(4), "1"); draw_text_add(_ax1 + ui(4), _ay1 - ui(4), "2"); @@ -99,12 +106,11 @@ function preview_overlay_gradient_range(interact, active, _x, _y, _s, _mx, _my, } } - __overlay_hover = array_verify(__overlay_hover, 2); __overlay_hover[0] = lerp_float(__overlay_hover[0], d0, 4); __overlay_hover[1] = lerp_float(__overlay_hover[1], d1, 4); draw_anchor(__overlay_hover[0], _ax0, _ay0, _r); - draw_anchor(__overlay_hover[0], _ax1, _ay1, _r); + draw_anchor(__overlay_hover[1], _ax1, _ay1, _r); return hover; } \ No newline at end of file