summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaosus <chaosus89@gmail.com>2019-04-24 08:44:48 +0300
committerChaosus <chaosus89@gmail.com>2019-04-24 09:14:45 +0300
commit21ca9f6c7c1bc2f8ae7b53da97d2ad8037573781 (patch)
tree048eebf05985bdb543a45c13ce70e19e11d82f50
parent80f91c9d3664ab8dd226a3708e36886381e4508b (diff)
Disallow loopback connection in visual scripts and visual shaders
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp1
-rw-r--r--scene/resources/visual_shader.cpp3
2 files changed, 3 insertions, 1 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index c619b5d224..2705e9adda 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -757,7 +757,6 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in
int to = p_to.to_int();
if (!visual_shader->can_connect_nodes(type, from, p_from_index, to, p_to_index)) {
- EditorNode::get_singleton()->show_warning(TTR("Unable to connect, port may be in use or connection may be invalid."));
return;
}
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 4229147ba2..b8f21948c3 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -240,6 +240,9 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po
if (!g->nodes.has(p_from_node))
return false;
+ if (p_from_node == p_to_node)
+ return false;
+
if (p_from_port < 0 || p_from_port >= g->nodes[p_from_node].node->get_output_port_count())
return false;