- [Preview Panel] Move 3d passes selector into preview settings.

This commit is contained in:
Tanasart 2024-07-27 14:07:04 +07:00
parent 5c03723004
commit b86f5fe9fd
5 changed files with 80 additions and 65 deletions

View file

@ -587,6 +587,23 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
return noone;
}
function getPreviewingNode() {
var _outJ = outputs[| preview_channel];
switch(_outJ.type) {
case VALUE_TYPE.d3Mesh :
case VALUE_TYPE.d3Camera :
case VALUE_TYPE.d3Light :
case VALUE_TYPE.d3Scene :
case VALUE_TYPE.d3object :
case VALUE_TYPE.sdf :
var _fr = _outJ.from.inputs[| 0];
return _fr.value_from == noone? self : _fr.value_from.node;
}
return self;
}
/////============= CACHE =============
static clearCache = function() { array_foreach(getNodeList(), function(node) /*=>*/ { node.clearCache(); }); }

View file

@ -251,7 +251,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
graph_preview_alpha = 1;
getPreviewingNode = noone;
getPreviewingNode = function() /*=>*/ {return self};
preview_value = 0;
preview_array = "";
@ -590,11 +590,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return jun_list_arr;
}
static getOutputJunctionIndex = function(index) {
if(output_display_list == -1)
return index;
return output_display_list[index];
}
static getOutputJunctionAmount = function() { return output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list); }
static getOutputJunctionIndex = function(index) { return output_display_list == -1? index : output_display_list[index]; }
static updateIO = function() {
for( var i = 0, n = ds_list_size(inputs); i < n; i++ )

View file

@ -287,14 +287,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
/////============= VALUE ============
static setType = function(_type) { #region
static setType = function(_type) {
if(type == _type) return false;
type = _type;
draw_junction_index = type;
return true;
} #endregion
}
static setDefault = function(vals) { #region
if(LOADING || APPENDING) return self;
@ -1626,6 +1626,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(_valueFrom == noone)
return removeFrom();
run_in(2, function() /*=>*/ { updateColor(getValue()); });
var conn = isConnectable(_valueFrom, checkRecur, log);
if(conn < 0) return conn;
@ -1667,6 +1668,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
}
static removeFrom = function(_remove_list = true) {
run_in(2, function() /*=>*/ { updateColor(getValue()); });
recordAction(ACTION_TYPE.junction_disconnect, self, value_from);
if(_remove_list && value_from != noone)
array_remove(value_from.value_to, self);

View file

@ -142,20 +142,21 @@ function Panel_Preview() : PanelContent() constructor {
overlay_hovering = false;
view_hovering = false;
sbChannel = new scrollBox([], function(index) { #region
var node = getNodePreview();
sbChannel = new scrollBox([], function(index) {
var node = __getNodePreview();
if(node == noone) return;
node.preview_channel = array_safe_get_fast(sbChannelIndex, index);
}); #endregion
node.preview_channel = sbChannelIndex[index].index;
node.setHeight();
});
sbChannelIndex = [];
sbChannel.font = f_p1;
sbChannel.align = fa_left;
#endregion
#region ---- 3d ----
d3_active = false;
_d3_active = false;
d3_active = NODE_3D.none;
d3_active_transition = 0;
d3_surface = noone;
@ -214,12 +215,6 @@ function Panel_Preview() : PanelContent() constructor {
d3_tool_snap_position = 1;
d3_tool_snap_rotation = 15;
#endregion
#region view channel
d3ChannelNames = [ "Rendered", "Normal", "Depth" ];
d3Channel = new scrollBox(d3ChannelNames, function(index) { d3_preview_channel = index; });
d3Channel.align = fa_left;
#endregion
#endregion
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
@ -378,17 +373,14 @@ function Panel_Preview() : PanelContent() constructor {
////============ DATA ============
function setNodePreview(node) { #region
function setNodePreview(node) {
if(locked) return;
if(resetViewOnDoubleClick)
do_fullView = true;
if(is_instanceof(node, Node) && node.getPreviewingNode != noone)
node = node.getPreviewingNode();
preview_node[splitView? splitSelection : 0] = node;
} #endregion
}
function removeNodePreview(node) { #region
if(locked) return;
@ -402,7 +394,16 @@ function Panel_Preview() : PanelContent() constructor {
locked = false;
} #endregion
function getNodePreview() { return preview_node[splitView? splitSelection : 0]; }
function __getNodePreview() { return preview_node[splitView? splitSelection : 0]; }
function getNodePreview() {
var _node = __getNodePreview();
if(is_instanceof(_node, Node))
_node = _node.getPreviewingNode();
return _node;
}
function getNodePreviewSurface() { return preview_surfaces[splitView? splitSelection : 0]; }
function getNodePreviewSequence() { return preview_sequence[splitView? splitSelection : 0]; }
@ -658,10 +659,8 @@ function Panel_Preview() : PanelContent() constructor {
canvas_y = h / 2 - _h * canvas_s / 2 - _y * canvas_s;
}
function drawNodeChannel(_x, _y) { #region
var _node = getNodePreview();
if(_node == noone) return;
if(ds_list_size(_node.outputs) < 2) return;
function drawNodeChannel(_node, _x, _y) {
if(ds_list_size(_node.outputs) < 2) return 0;
var chName = [];
sbChannelIndex = [];
@ -670,34 +669,27 @@ function Panel_Preview() : PanelContent() constructor {
draw_set_text(sbChannel.font, fa_center, fa_center);
var ww = 0;
var hh = TEXTBOX_HEIGHT - ui(2);
var _am = _node.getOutputJunctionAmount();
for( var i = 0; i < ds_list_size(_node.outputs); i++ ) {
if(_node.outputs[| i].type != VALUE_TYPE.surface) continue;
for( var i = 0; i < _am; i++ ) {
var _outi = _node.getOutputJunctionIndex(i);
var _outj = _node.outputs[| _outi];
array_push(chName, _node.outputs[| i].name);
array_push(sbChannelIndex, i);
ww = max(ww, string_width(_node.outputs[| i].name) + ui(40));
array_push(chName, _outj.name);
array_push(sbChannelIndex, _outj);
ww = max(ww, string_width(_outj.name) + ui(40));
}
if(!array_empty(chName)) {
sbChannel.data_list = chName;
sbChannel.setFocusHover(pFOCUS, pHOVER);
sbChannel.draw(_x - ww, _y - hh / 2, ww, hh, currName, [mx, my], x, y);
right_menu_y += ui(40);
}
} #endregion
function drawNodeChannel3D(_x, _y) { #region
var _node = getNodePreview();
if(_node == noone) return;
var ww = ui(128);
var hh = toolbar_height - ui(12);
d3Channel.setFocusHover(pFOCUS, pHOVER);
d3Channel.draw(_x - ww, _y - hh / 2, ww, hh, d3ChannelNames[d3_preview_channel], [mx, my], x, y);
right_menu_y += ui(40);
} #endregion
return ww + ui(4);
}
static onFullScreen = function() { run_in(1, fullView); }
@ -1246,15 +1238,15 @@ function Panel_Preview() : PanelContent() constructor {
} #endregion
function draw3D() { #region
function draw3D() {
var _node = getNodePreview();
if(_node == noone) return;
switch(_node.is_3D) {
switch(d3_active) {
case NODE_3D.polygon : draw3DPolygon(_node); break;
case NODE_3D.sdf : draw3DSdf(_node); break;
}
} #endregion
}
function drawPreviewOverlay() { #region
right_menu_y = toolbar_height - ui(4);
@ -1291,7 +1283,7 @@ function Panel_Preview() : PanelContent() constructor {
draw_set_color(COLORS._main_text_sub);
draw_text(right_menu_x, right_menu_y, $"{__txt("Frame")} {CURRENT_FRAME + 1}/{TOTAL_FRAMES}");
if(!d3_active) {
if(d3_active == NODE_3D.none) {
right_menu_y += _lh;
draw_text(right_menu_x, right_menu_y, $"x{canvas_s}");
@ -1568,6 +1560,7 @@ function Panel_Preview() : PanelContent() constructor {
}
mouse_free = _node.drawOverlay(overHover, overActive, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
} else {
if(key_mod_press(CTRL) || d3_tool_snap) {
_snx = d3_tool_snap_position;
@ -1817,7 +1810,7 @@ function Panel_Preview() : PanelContent() constructor {
}
} #endregion
function drawToolBar(_tool, _node) { #region
function drawToolBar(_tool, _node) {
var ty = h - toolbar_height;
var aa = d3_active? 0.8 : 1;
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
@ -1928,8 +1921,7 @@ function Panel_Preview() : PanelContent() constructor {
var _toolbars = toolbars;
if(_node)
switch(_node.is_3D) {
switch(d3_active) {
case NODE_3D.none : _toolbars = toolbars; break;
case NODE_3D.polygon : _toolbars = toolbars_3d; break;
case NODE_3D.sdf : _toolbars = toolbars_3d_sdf; break;
@ -1964,11 +1956,9 @@ function Panel_Preview() : PanelContent() constructor {
draw_set_color(COLORS.panel_toolbar_separator);
draw_line_width(tbx + ui(12), tby - toolbar_height / 2 + ui(8), tbx + ui(12), tby + toolbar_height / 2 - ui(8), 2);
if(d3_active && _node && _node.is_3D == NODE_3D.polygon)
drawNodeChannel3D(tbx, tby);
else
drawNodeChannel(tbx, tby);
} #endregion
var _nodeRaw = __getNodePreview();
if(_nodeRaw) tbx -= drawNodeChannel(_nodeRaw, tbx, tby);
}
function drawSplitView() { #region
if(splitView == 0) return;
@ -2039,7 +2029,8 @@ function Panel_Preview() : PanelContent() constructor {
do_fullView = false;
var _prev_node = getNodePreview();
d3_active = _prev_node != noone && _prev_node.is_3D != NODE_3D.none;
d3_active = _prev_node == noone? NODE_3D.none : _prev_node.is_3D;
//print($"{_prev_node} : {d3_active}")
bg_color = lerp_color(bg_color, d3_active? COLORS.panel_3d_bg : COLORS.panel_bg_clear, 0.3);
draw_clear(bg_color);
@ -2084,7 +2075,7 @@ function Panel_Preview() : PanelContent() constructor {
tool_current = noone;
}
if(!d3_active) drawSplitView();
if(d3_active == NODE_3D.none) drawSplitView();
drawToolBar(tool, _prev_node);

View file

@ -5,6 +5,13 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor {
preview_panel = panel;
properties_default = [
new __Panel_Linear_Setting_Item(
__txt("Preview Pass"),
new scrollBox([ "Rendered", "Normal", "Depth" ], function(index) { preview_panel.d3_preview_channel = index; }),
function() { return preview_panel.d3_preview_channel },
function(val) { preview_panel.d3_preview_channel = val; },
0,
),
new __Panel_Linear_Setting_Item(
__txt("Preview Light"),
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),