mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- [Preview Panel] Move 3d passes selector into preview settings.
This commit is contained in:
parent
5c03723004
commit
b86f5fe9fd
5 changed files with 80 additions and 65 deletions
|
@ -587,6 +587,23 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
return noone;
|
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 =============
|
/////============= CACHE =============
|
||||||
|
|
||||||
static clearCache = function() { array_foreach(getNodeList(), function(node) /*=>*/ { node.clearCache(); }); }
|
static clearCache = function() { array_foreach(getNodeList(), function(node) /*=>*/ { node.clearCache(); }); }
|
||||||
|
|
|
@ -251,7 +251,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||||
|
|
||||||
graph_preview_alpha = 1;
|
graph_preview_alpha = 1;
|
||||||
|
|
||||||
getPreviewingNode = noone;
|
getPreviewingNode = function() /*=>*/ {return self};
|
||||||
|
|
||||||
preview_value = 0;
|
preview_value = 0;
|
||||||
preview_array = "";
|
preview_array = "";
|
||||||
|
@ -590,11 +590,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||||
return jun_list_arr;
|
return jun_list_arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getOutputJunctionIndex = function(index) {
|
static getOutputJunctionAmount = function() { return output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list); }
|
||||||
if(output_display_list == -1)
|
static getOutputJunctionIndex = function(index) { return output_display_list == -1? index : output_display_list[index]; }
|
||||||
return index;
|
|
||||||
return output_display_list[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
static updateIO = function() {
|
static updateIO = function() {
|
||||||
for( var i = 0, n = ds_list_size(inputs); i < n; i++ )
|
for( var i = 0, n = ds_list_size(inputs); i < n; i++ )
|
||||||
|
|
|
@ -287,14 +287,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
|
|
||||||
/////============= VALUE ============
|
/////============= VALUE ============
|
||||||
|
|
||||||
static setType = function(_type) { #region
|
static setType = function(_type) {
|
||||||
if(type == _type) return false;
|
if(type == _type) return false;
|
||||||
|
|
||||||
type = _type;
|
type = _type;
|
||||||
draw_junction_index = type;
|
draw_junction_index = type;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static setDefault = function(vals) { #region
|
static setDefault = function(vals) { #region
|
||||||
if(LOADING || APPENDING) return self;
|
if(LOADING || APPENDING) return self;
|
||||||
|
@ -1626,6 +1626,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
if(_valueFrom == noone)
|
if(_valueFrom == noone)
|
||||||
return removeFrom();
|
return removeFrom();
|
||||||
|
|
||||||
|
run_in(2, function() /*=>*/ { updateColor(getValue()); });
|
||||||
var conn = isConnectable(_valueFrom, checkRecur, log);
|
var conn = isConnectable(_valueFrom, checkRecur, log);
|
||||||
if(conn < 0) return conn;
|
if(conn < 0) return conn;
|
||||||
|
|
||||||
|
@ -1667,6 +1668,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
}
|
}
|
||||||
|
|
||||||
static removeFrom = function(_remove_list = true) {
|
static removeFrom = function(_remove_list = true) {
|
||||||
|
run_in(2, function() /*=>*/ { updateColor(getValue()); });
|
||||||
|
|
||||||
recordAction(ACTION_TYPE.junction_disconnect, self, value_from);
|
recordAction(ACTION_TYPE.junction_disconnect, self, value_from);
|
||||||
if(_remove_list && value_from != noone)
|
if(_remove_list && value_from != noone)
|
||||||
array_remove(value_from.value_to, self);
|
array_remove(value_from.value_to, self);
|
||||||
|
|
|
@ -142,20 +142,21 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
overlay_hovering = false;
|
overlay_hovering = false;
|
||||||
view_hovering = false;
|
view_hovering = false;
|
||||||
|
|
||||||
sbChannel = new scrollBox([], function(index) { #region
|
sbChannel = new scrollBox([], function(index) {
|
||||||
var node = getNodePreview();
|
var node = __getNodePreview();
|
||||||
if(node == noone) return;
|
if(node == noone) return;
|
||||||
|
|
||||||
|
node.preview_channel = sbChannelIndex[index].index;
|
||||||
|
node.setHeight();
|
||||||
|
});
|
||||||
|
|
||||||
node.preview_channel = array_safe_get_fast(sbChannelIndex, index);
|
|
||||||
}); #endregion
|
|
||||||
sbChannelIndex = [];
|
sbChannelIndex = [];
|
||||||
sbChannel.font = f_p1;
|
sbChannel.font = f_p1;
|
||||||
sbChannel.align = fa_left;
|
sbChannel.align = fa_left;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ---- 3d ----
|
#region ---- 3d ----
|
||||||
d3_active = false;
|
d3_active = NODE_3D.none;
|
||||||
_d3_active = false;
|
|
||||||
d3_active_transition = 0;
|
d3_active_transition = 0;
|
||||||
|
|
||||||
d3_surface = noone;
|
d3_surface = noone;
|
||||||
|
@ -214,12 +215,6 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
d3_tool_snap_position = 1;
|
d3_tool_snap_position = 1;
|
||||||
d3_tool_snap_rotation = 15;
|
d3_tool_snap_rotation = 15;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region view channel
|
|
||||||
d3ChannelNames = [ "Rendered", "Normal", "Depth" ];
|
|
||||||
d3Channel = new scrollBox(d3ChannelNames, function(index) { d3_preview_channel = index; });
|
|
||||||
d3Channel.align = fa_left;
|
|
||||||
#endregion
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
|
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
|
||||||
|
@ -378,17 +373,14 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
|
|
||||||
////============ DATA ============
|
////============ DATA ============
|
||||||
|
|
||||||
function setNodePreview(node) { #region
|
function setNodePreview(node) {
|
||||||
if(locked) return;
|
if(locked) return;
|
||||||
|
|
||||||
if(resetViewOnDoubleClick)
|
if(resetViewOnDoubleClick)
|
||||||
do_fullView = true;
|
do_fullView = true;
|
||||||
|
|
||||||
if(is_instanceof(node, Node) && node.getPreviewingNode != noone)
|
|
||||||
node = node.getPreviewingNode();
|
|
||||||
|
|
||||||
preview_node[splitView? splitSelection : 0] = node;
|
preview_node[splitView? splitSelection : 0] = node;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
function removeNodePreview(node) { #region
|
function removeNodePreview(node) { #region
|
||||||
if(locked) return;
|
if(locked) return;
|
||||||
|
@ -402,7 +394,16 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
locked = false;
|
locked = false;
|
||||||
} #endregion
|
} #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 getNodePreviewSurface() { return preview_surfaces[splitView? splitSelection : 0]; }
|
||||||
function getNodePreviewSequence() { return preview_sequence[splitView? splitSelection : 0]; }
|
function getNodePreviewSequence() { return preview_sequence[splitView? splitSelection : 0]; }
|
||||||
|
|
||||||
|
@ -658,46 +659,37 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
canvas_y = h / 2 - _h * canvas_s / 2 - _y * canvas_s;
|
canvas_y = h / 2 - _h * canvas_s / 2 - _y * canvas_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawNodeChannel(_x, _y) { #region
|
function drawNodeChannel(_node, _x, _y) {
|
||||||
var _node = getNodePreview();
|
if(ds_list_size(_node.outputs) < 2) return 0;
|
||||||
if(_node == noone) return;
|
|
||||||
if(ds_list_size(_node.outputs) < 2) return;
|
|
||||||
|
|
||||||
var chName = [];
|
var chName = [];
|
||||||
sbChannelIndex = [];
|
sbChannelIndex = [];
|
||||||
|
|
||||||
var currName = _node.outputs[| _node.preview_channel].name;
|
var currName = _node.outputs[| _node.preview_channel].name;
|
||||||
draw_set_text(sbChannel.font, fa_center, fa_center);
|
draw_set_text(sbChannel.font, fa_center, fa_center);
|
||||||
var ww = 0;
|
var ww = 0;
|
||||||
var hh = TEXTBOX_HEIGHT - ui(2);
|
var hh = TEXTBOX_HEIGHT - ui(2);
|
||||||
|
var _am = _node.getOutputJunctionAmount();
|
||||||
|
|
||||||
for( var i = 0; i < ds_list_size(_node.outputs); i++ ) {
|
for( var i = 0; i < _am; i++ ) {
|
||||||
if(_node.outputs[| i].type != VALUE_TYPE.surface) continue;
|
var _outi = _node.getOutputJunctionIndex(i);
|
||||||
|
var _outj = _node.outputs[| _outi];
|
||||||
|
|
||||||
array_push(chName, _node.outputs[| i].name);
|
array_push(chName, _outj.name);
|
||||||
array_push(sbChannelIndex, i);
|
array_push(sbChannelIndex, _outj);
|
||||||
ww = max(ww, string_width(_node.outputs[| i].name) + ui(40));
|
ww = max(ww, string_width(_outj.name) + ui(40));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!array_empty(chName)) {
|
if(!array_empty(chName)) {
|
||||||
sbChannel.data_list = chName;
|
sbChannel.data_list = chName;
|
||||||
sbChannel.setFocusHover(pFOCUS, pHOVER);
|
sbChannel.setFocusHover(pFOCUS, pHOVER);
|
||||||
sbChannel.draw(_x - ww, _y - hh / 2, ww, hh, currName, [mx, my], x, y);
|
sbChannel.draw(_x - ww, _y - hh / 2, ww, hh, currName, [mx, my], x, y);
|
||||||
right_menu_y += ui(40);
|
right_menu_y += ui(40);
|
||||||
}
|
}
|
||||||
} #endregion
|
|
||||||
|
|
||||||
function drawNodeChannel3D(_x, _y) { #region
|
|
||||||
var _node = getNodePreview();
|
|
||||||
if(_node == noone) return;
|
|
||||||
|
|
||||||
var ww = ui(128);
|
return ww + ui(4);
|
||||||
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
|
|
||||||
|
|
||||||
static onFullScreen = function() { run_in(1, fullView); }
|
static onFullScreen = function() { run_in(1, fullView); }
|
||||||
|
|
||||||
|
@ -1246,15 +1238,15 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
|
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
function draw3D() { #region
|
function draw3D() {
|
||||||
var _node = getNodePreview();
|
var _node = getNodePreview();
|
||||||
if(_node == noone) return;
|
if(_node == noone) return;
|
||||||
|
|
||||||
switch(_node.is_3D) {
|
switch(d3_active) {
|
||||||
case NODE_3D.polygon : draw3DPolygon(_node); break;
|
case NODE_3D.polygon : draw3DPolygon(_node); break;
|
||||||
case NODE_3D.sdf : draw3DSdf(_node); break;
|
case NODE_3D.sdf : draw3DSdf(_node); break;
|
||||||
}
|
}
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
function drawPreviewOverlay() { #region
|
function drawPreviewOverlay() { #region
|
||||||
right_menu_y = toolbar_height - ui(4);
|
right_menu_y = toolbar_height - ui(4);
|
||||||
|
@ -1291,7 +1283,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
draw_set_color(COLORS._main_text_sub);
|
draw_set_color(COLORS._main_text_sub);
|
||||||
draw_text(right_menu_x, right_menu_y, $"{__txt("Frame")} {CURRENT_FRAME + 1}/{TOTAL_FRAMES}");
|
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;
|
right_menu_y += _lh;
|
||||||
draw_text(right_menu_x, right_menu_y, $"x{canvas_s}");
|
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);
|
mouse_free = _node.drawOverlay(overHover, overActive, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(key_mod_press(CTRL) || d3_tool_snap) {
|
if(key_mod_press(CTRL) || d3_tool_snap) {
|
||||||
_snx = d3_tool_snap_position;
|
_snx = d3_tool_snap_position;
|
||||||
|
@ -1817,7 +1810,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
}
|
}
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
function drawToolBar(_tool, _node) { #region
|
function drawToolBar(_tool, _node) {
|
||||||
var ty = h - toolbar_height;
|
var ty = h - toolbar_height;
|
||||||
var aa = d3_active? 0.8 : 1;
|
var aa = d3_active? 0.8 : 1;
|
||||||
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
|
draw_sprite_stretched_ext(THEME.toolbar, 1, 0, 0, w, topbar_height, c_white, aa);
|
||||||
|
@ -1927,9 +1920,8 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
var tby = ty + toolbar_height / 2;
|
var tby = ty + toolbar_height / 2;
|
||||||
|
|
||||||
var _toolbars = toolbars;
|
var _toolbars = toolbars;
|
||||||
|
|
||||||
if(_node)
|
switch(d3_active) {
|
||||||
switch(_node.is_3D) {
|
|
||||||
case NODE_3D.none : _toolbars = toolbars; break;
|
case NODE_3D.none : _toolbars = toolbars; break;
|
||||||
case NODE_3D.polygon : _toolbars = toolbars_3d; break;
|
case NODE_3D.polygon : _toolbars = toolbars_3d; break;
|
||||||
case NODE_3D.sdf : _toolbars = toolbars_3d_sdf; 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_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);
|
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)
|
var _nodeRaw = __getNodePreview();
|
||||||
drawNodeChannel3D(tbx, tby);
|
if(_nodeRaw) tbx -= drawNodeChannel(_nodeRaw, tbx, tby);
|
||||||
else
|
}
|
||||||
drawNodeChannel(tbx, tby);
|
|
||||||
} #endregion
|
|
||||||
|
|
||||||
function drawSplitView() { #region
|
function drawSplitView() { #region
|
||||||
if(splitView == 0) return;
|
if(splitView == 0) return;
|
||||||
|
@ -2039,8 +2029,9 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
do_fullView = false;
|
do_fullView = false;
|
||||||
|
|
||||||
var _prev_node = getNodePreview();
|
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;
|
||||||
bg_color = lerp_color(bg_color, d3_active? COLORS.panel_3d_bg : COLORS.panel_bg_clear, 0.3);
|
//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);
|
draw_clear(bg_color);
|
||||||
if(canvas_bg == -1) {
|
if(canvas_bg == -1) {
|
||||||
|
@ -2084,7 +2075,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
tool_current = noone;
|
tool_current = noone;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!d3_active) drawSplitView();
|
if(d3_active == NODE_3D.none) drawSplitView();
|
||||||
|
|
||||||
drawToolBar(tool, _prev_node);
|
drawToolBar(tool, _prev_node);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,13 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor {
|
||||||
preview_panel = panel;
|
preview_panel = panel;
|
||||||
|
|
||||||
properties_default = [
|
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(
|
new __Panel_Linear_Setting_Item(
|
||||||
__txt("Preview Light"),
|
__txt("Preview Light"),
|
||||||
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),
|
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),
|
||||||
|
|
Loading…
Reference in a new issue