diff options
| author | Chaosus <chaosus89@gmail.com> | 2019-06-26 21:50:38 +0300 |
|---|---|---|
| committer | Chaosus <chaosus89@gmail.com> | 2019-06-27 10:48:18 +0300 |
| commit | 0aec3c3113ce8319ffdc795ee2d06a7ec04036fc (patch) | |
| tree | b571630a184d43b028d767f11ec61babd5e08738 /scene/resources/visual_shader.cpp | |
| parent | 2c96942df9318ea8a4f3ad06d007e46e3108fa48 (diff) | |
| download | redot-engine-0aec3c3113ce8319ffdc795ee2d06a7ec04036fc.tar.gz | |
Shows menu when dragging connection on empty space in visual shader graph
Diffstat (limited to 'scene/resources/visual_shader.cpp')
| -rw-r--r-- | scene/resources/visual_shader.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index a3813f8fc6..7265c9b457 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -257,7 +257,7 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po VisualShaderNode::PortType from_port_type = g->nodes[p_from_node].node->get_output_port_type(p_from_port); VisualShaderNode::PortType to_port_type = g->nodes[p_to_node].node->get_input_port_type(p_to_port); - if (MAX(0, from_port_type - 2) != (MAX(0, to_port_type - 2))) { + if (!is_port_types_compatible(from_port_type, to_port_type)) { return false; } @@ -271,6 +271,10 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po return true; } +bool VisualShader::is_port_types_compatible(int p_a, int p_b) const { + return MAX(0, p_a - 2) == (MAX(0, p_b - 2)); +} + void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { ERR_FAIL_INDEX(p_type, TYPE_MAX); Graph *g = &graph[p_type]; @@ -295,8 +299,8 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port, VisualShaderNode::PortType from_port_type = g->nodes[p_from_node].node->get_output_port_type(p_from_port); VisualShaderNode::PortType to_port_type = g->nodes[p_to_node].node->get_input_port_type(p_to_port); - if (MAX(0, from_port_type - 2) != (MAX(0, to_port_type - 2))) { - ERR_EXPLAIN("Incompatible port types (scalar/vec/bool with transform"); + if (!is_port_types_compatible(from_port_type, to_port_type)) { + ERR_EXPLAIN("Incompatible port types (scalar/vec/bool) with transform"); ERR_FAIL_V(ERR_INVALID_PARAMETER); return ERR_INVALID_PARAMETER; } |
