Little fix: don't create an empty undo/redo command when trying to add a second Input GraphNode
This commit is contained in:
parent
5ffd818fb1
commit
add0105c4e
@ -142,6 +142,15 @@ ShaderGraph::GraphError ShaderGraph::get_graph_error(ShaderType p_type) const {
|
|||||||
return shader[p_type].error;
|
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() {
|
void ShaderGraph::_bind_methods() {
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
|
ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
|
||||||
|
@ -365,6 +365,8 @@ public:
|
|||||||
|
|
||||||
GraphError get_graph_error(ShaderType p_type) const;
|
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_input_count(NodeType p_type);
|
||||||
static int get_type_output_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);
|
static SlotType get_type_input_type(NodeType p_type,int p_idx);
|
||||||
|
@ -2162,6 +2162,9 @@ void ShaderGraphView::_notification(int p_what) {
|
|||||||
|
|
||||||
void ShaderGraphView::add_node(int p_type, const Vector2 &location) {
|
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;
|
List<int> existing;
|
||||||
graph->get_node_list(type,&existing);
|
graph->get_node_list(type,&existing);
|
||||||
existing.sort();
|
existing.sort();
|
||||||
|
Loading…
Reference in New Issue
Block a user