Skip to content

Commit de00cfb

Browse files
committed
Merge pull request godotengine#90892 from Chaosus/vs_fix_expression_port_expand
Prevent expanding output port in visual shader expression
2 parents 645be5c + 56d8437 commit de00cfb

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

editor/plugins/visual_shader_editor_plugin.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
10021002
button->hide();
10031003
}
10041004

1005-
if (i == 0 && custom_editor) {
1005+
if (j == 0 && custom_editor) {
10061006
hb->add_child(custom_editor);
10071007
custom_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
10081008
} else {
@@ -1019,22 +1019,22 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
10191019
type_box->add_item(TTR("Boolean"));
10201020
type_box->add_item(TTR("Transform"));
10211021
type_box->add_item(TTR("Sampler"));
1022-
type_box->select(group_node->get_input_port_type(i));
1022+
type_box->select(group_node->get_input_port_type(j));
10231023
type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
1024-
type_box->connect("item_selected", callable_mp(editor, &VisualShaderEditor::_change_input_port_type).bind(p_id, i), CONNECT_DEFERRED);
1024+
type_box->connect("item_selected", callable_mp(editor, &VisualShaderEditor::_change_input_port_type).bind(p_id, j), CONNECT_DEFERRED);
10251025

10261026
LineEdit *name_box = memnew(LineEdit);
10271027
hb->add_child(name_box);
10281028
name_box->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
10291029
name_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
10301030
name_box->set_text(name_left);
1031-
name_box->connect("text_submitted", callable_mp(editor, &VisualShaderEditor::_change_input_port_name).bind(name_box, p_id, i), CONNECT_DEFERRED);
1032-
name_box->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_port_name_focus_out).bind(name_box, p_id, i, false), CONNECT_DEFERRED);
1031+
name_box->connect("text_submitted", callable_mp(editor, &VisualShaderEditor::_change_input_port_name).bind(name_box, p_id, j), CONNECT_DEFERRED);
1032+
name_box->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_port_name_focus_out).bind(name_box, p_id, j, false), CONNECT_DEFERRED);
10331033

10341034
Button *remove_btn = memnew(Button);
10351035
remove_btn->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Remove"), EditorStringName(EditorIcons)));
10361036
remove_btn->set_tooltip_text(TTR("Remove") + " " + name_left);
1037-
remove_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_remove_input_port).bind(p_id, i), CONNECT_DEFERRED);
1037+
remove_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_remove_input_port).bind(p_id, j), CONNECT_DEFERRED);
10381038
hb->add_child(remove_btn);
10391039
} else {
10401040
Label *label = memnew(Label);
@@ -1043,7 +1043,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
10431043
label->add_theme_style_override("normal", editor->get_theme_stylebox(SNAME("label_style"), SNAME("VShaderEditor"))); //more compact
10441044
hb->add_child(label);
10451045

1046-
if (vsnode->is_input_port_default(i, mode) && !port_left_used) {
1046+
if (vsnode->is_input_port_default(j, mode) && !port_left_used) {
10471047
Label *hint_label = memnew(Label);
10481048
hint_label->set_text(TTR("[default]"));
10491049
hint_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("font_readonly_color"), SNAME("TextEdit")));

scene/resources/visual_shader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4928,6 +4928,10 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
49284928
return code;
49294929
}
49304930

4931+
bool VisualShaderNodeExpression::is_output_port_expandable(int p_port) const {
4932+
return false;
4933+
}
4934+
49314935
void VisualShaderNodeExpression::_bind_methods() {
49324936
ClassDB::bind_method(D_METHOD("set_expression", "expression"), &VisualShaderNodeExpression::set_expression);
49334937
ClassDB::bind_method(D_METHOD("get_expression"), &VisualShaderNodeExpression::get_expression);

scene/resources/visual_shader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ class VisualShaderNodeExpression : public VisualShaderNodeGroupBase {
878878
String get_expression() const;
879879

880880
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
881+
virtual bool is_output_port_expandable(int p_port) const override;
881882

882883
VisualShaderNodeExpression();
883884
};

0 commit comments

Comments
 (0)