summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/resources/shader_graph.cpp9
-rw-r--r--scene/resources/shader_graph.h2
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp3
3 files changed, 14 insertions, 0 deletions
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 108aad3c56..9522667698 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -142,6 +142,15 @@ ShaderGraph::GraphError ShaderGraph::get_graph_error(ShaderType p_type) const {
return shader[p_type].error;
}
+int ShaderGraph::node_count(ShaderType p_which, int p_type)
+{
+ int count=0;
+ for (Map<int,Node>::Element *E=shader[p_which].node_map.front();E;E=E->next())
+ if (E->get().type==p_type)
+ count++;
+ return count;
+}
+
void ShaderGraph::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h
index d3a297cd6c..b93567538d 100644
--- a/scene/resources/shader_graph.h
+++ b/scene/resources/shader_graph.h
@@ -365,6 +365,8 @@ public:
GraphError get_graph_error(ShaderType p_type) const;
+ int node_count(ShaderType p_which, int p_type);
+
static int get_type_input_count(NodeType p_type);
static int get_type_output_count(NodeType p_type);
static SlotType get_type_input_type(NodeType p_type,int p_idx);
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index 3ab536ab6e..370688d6f5 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -2162,6 +2162,9 @@ void ShaderGraphView::_notification(int p_what) {
void ShaderGraphView::add_node(int p_type, const Vector2 &location) {
+ if ((p_type==ShaderGraph::NODE_INPUT||p_type==ShaderGraph::NODE_INPUT) && graph->node_count(type, p_type)>0)
+ return;
+
List<int> existing;
graph->get_node_list(type,&existing);
existing.sort();