Fix VisualShaderNode::set_output_port_connected

This commit is contained in:
Yuri Roubinsky 2020-10-02 09:06:13 +03:00
parent 5e726d8d20
commit dc713e149f
2 changed files with 4 additions and 9 deletions

View file

@ -65,20 +65,16 @@ bool VisualShaderNode::is_port_separator(int p_index) const {
bool VisualShaderNode::is_output_port_connected(int p_port) const { bool VisualShaderNode::is_output_port_connected(int p_port) const {
if (connected_output_ports.has(p_port)) { if (connected_output_ports.has(p_port)) {
return connected_output_ports[p_port]; return connected_output_ports[p_port] > 0;
} }
return false; return false;
} }
void VisualShaderNode::set_output_port_connected(int p_port, bool p_connected) { void VisualShaderNode::set_output_port_connected(int p_port, bool p_connected) {
if (p_connected) { if (p_connected) {
connected_output_ports[p_port] = true; connected_output_ports[p_port]++;
++connected_output_count;
} else { } else {
--connected_output_count; connected_output_ports[p_port]--;
if (connected_output_count == 0) {
connected_output_ports[p_port] = false;
}
} }
} }

View file

@ -193,8 +193,7 @@ class VisualShaderNode : public Resource {
Map<int, Variant> default_input_values; Map<int, Variant> default_input_values;
Map<int, bool> connected_input_ports; Map<int, bool> connected_input_ports;
Map<int, bool> connected_output_ports; Map<int, int> connected_output_ports;
int connected_output_count = 0;
protected: protected:
bool simple_decl = true; bool simple_decl = true;