Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Shaders: Make output-ports for vector types expandable by default #82088

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,11 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
}

if (valid_right) {
if (vsnode->is_output_port_expandable(i)) {
if (expanded_port_counter == 0 && vsnode->is_output_port_expandable(i)) {
TextureButton *expand = memnew(TextureButton);
expand->set_toggle_mode(true);
expand->set_texture_normal(editor->get_editor_theme_icon(SNAME("GuiTreeArrowDown")));
expand->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiTreeArrowRight")));
expand->set_texture_normal(editor->get_editor_theme_icon(SNAME("GuiTreeArrowRight")));
expand->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiTreeArrowDown")));
expand->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
expand->set_pressed(vsnode->_is_output_port_expanded(i));
expand->connect("pressed", callable_mp(editor, &VisualShaderEditor::_expand_output_port).bind(p_id, i, !vsnode->_is_output_port_expanded(i)), CONNECT_DEFERRED);
Expand Down Expand Up @@ -892,6 +892,9 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool

if (!is_first_hbox) {
node->add_child(hb);
if (curve_xyz.is_valid()) {
node->move_child(hb, 1 + expanded_port_counter);
}
}

if (expanded_type != VisualShaderNode::PORT_TYPE_SCALAR) {
Expand Down
4 changes: 4 additions & 0 deletions scene/resources/visual_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ bool VisualShaderNode::is_generate_input_var(int p_port) const {
}

bool VisualShaderNode::is_output_port_expandable(int p_port) const {
VisualShaderNode::PortType port = get_output_port_type(p_port);
if (get_output_port_count() == 1 && (port == PORT_TYPE_VECTOR_2D || port == PORT_TYPE_VECTOR_3D || port == PORT_TYPE_VECTOR_4D)) {
return true;
}
return false;
}

Expand Down
Loading
Loading