diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-07-18 10:17:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-18 10:17:35 +0300 |
commit | 35dc0db2968a3502822d7bebedbafbee39a4794b (patch) | |
tree | 667cbad5a81a932f52954c514e2eb54ff9058fb5 /scene/resources | |
parent | 5ee0d16565590add101047a518bf24b375be5b48 (diff) | |
parent | d63a284dff2c592a290eccd12cd5d121b6689b15 (diff) |
Merge pull request #50562 from Chaosus/vs_fix_funcs
Prevents function generation in visual shader if no connections to output are provided
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/visual_shader.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 36a1c206c8..b4a95f2592 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1752,6 +1752,11 @@ void VisualShader::_update_shader() const { StringBuilder func_code; + bool is_empty_func = false; + if (shader_mode != Shader::MODE_PARTICLES && shader_mode != Shader::MODE_SKY) { + is_empty_func = true; + } + for (const List<Connection>::Element *E = graph[i].connections.front(); E; E = E->next()) { ConnectionKey from_key; from_key.node = E->get().from_node; @@ -1764,7 +1769,16 @@ void VisualShader::_update_shader() const { to_key.port = E->get().to_port; input_connections.insert(to_key, E); + + if (is_empty_func && to_key.node == NODE_ID_OUTPUT) { + is_empty_func = false; + } } + + if (is_empty_func) { + continue; + } + if (shader_mode != Shader::MODE_PARTICLES) { func_code += "\nvoid " + String(func_name[i]) + "() {\n"; } |