|
@@ -31,7 +31,6 @@
|
|
|
#include "visual_shader.h"
|
|
|
|
|
|
#include "core/templates/rb_map.h"
|
|
|
-#include "core/templates/vmap.h"
|
|
|
#include "core/variant/variant_utility.h"
|
|
|
#include "servers/rendering/shader_types.h"
|
|
|
#include "visual_shader_nodes.h"
|
|
@@ -1516,16 +1515,9 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port
|
|
|
global_code += global_expressions;
|
|
|
|
|
|
//make it faster to go around through shader
|
|
|
- VMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
|
|
- VMap<ConnectionKey, const List<Connection>::Element *> output_connections;
|
|
|
+ HashMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
|
|
|
|
|
for (const List<Connection>::Element *E = graph[p_type].connections.front(); E; E = E->next()) {
|
|
|
- ConnectionKey from_key;
|
|
|
- from_key.node = E->get().from_node;
|
|
|
- from_key.port = E->get().from_port;
|
|
|
-
|
|
|
- output_connections.insert(from_key, E);
|
|
|
-
|
|
|
ConnectionKey to_key;
|
|
|
to_key.node = E->get().to_node;
|
|
|
to_key.port = E->get().to_port;
|
|
@@ -1536,7 +1528,7 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port
|
|
|
shader_code += "\nvoid fragment() {\n";
|
|
|
|
|
|
HashSet<int> processed;
|
|
|
- Error err = _write_node(p_type, &global_code, &global_code_per_node, &global_code_per_func, shader_code, default_tex_params, input_connections, output_connections, p_node, processed, true, classes);
|
|
|
+ Error err = _write_node(p_type, &global_code, &global_code_per_node, &global_code_per_func, shader_code, default_tex_params, input_connections, p_node, processed, true, classes);
|
|
|
ERR_FAIL_COND_V(err != OK, String());
|
|
|
|
|
|
switch (node->get_output_port_type(p_port)) {
|
|
@@ -1955,7 +1947,7 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<VisualShader::DefaultTextureParam> &r_def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &p_output_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const {
|
|
|
+Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<VisualShader::DefaultTextureParam> &r_def_tex_params, const HashMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const {
|
|
|
const Ref<VisualShaderNode> vsnode = graph[type].nodes[p_node].node;
|
|
|
|
|
|
if (vsnode->is_disabled()) {
|
|
@@ -1977,7 +1969,7 @@ Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringB
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- Error err = _write_node(type, p_global_code, p_global_code_per_node, p_global_code_per_func, r_code, r_def_tex_params, p_input_connections, p_output_connections, from_node, r_processed, p_for_preview, r_classes);
|
|
|
+ Error err = _write_node(type, p_global_code, p_global_code_per_node, p_global_code_per_func, r_code, r_def_tex_params, p_input_connections, from_node, r_processed, p_for_preview, r_classes);
|
|
|
if (err) {
|
|
|
return err;
|
|
|
}
|
|
@@ -2702,8 +2694,7 @@ void VisualShader::_update_shader() const {
|
|
|
}
|
|
|
|
|
|
//make it faster to go around through shader
|
|
|
- VMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
|
|
- VMap<ConnectionKey, const List<Connection>::Element *> output_connections;
|
|
|
+ HashMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
|
|
|
|
|
StringBuilder func_code;
|
|
|
HashSet<int> processed;
|
|
@@ -2764,12 +2755,6 @@ void VisualShader::_update_shader() const {
|
|
|
}
|
|
|
|
|
|
for (const List<Connection>::Element *E = graph[i].connections.front(); E; E = E->next()) {
|
|
|
- ConnectionKey from_key;
|
|
|
- from_key.node = E->get().from_node;
|
|
|
- from_key.port = E->get().from_port;
|
|
|
-
|
|
|
- output_connections.insert(from_key, E);
|
|
|
-
|
|
|
ConnectionKey to_key;
|
|
|
to_key.node = E->get().to_node;
|
|
|
to_key.port = E->get().to_port;
|
|
@@ -2791,19 +2776,19 @@ void VisualShader::_update_shader() const {
|
|
|
}
|
|
|
insertion_pos.insert(i, shader_code.get_string_length() + func_code.get_string_length());
|
|
|
|
|
|
- Error err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, output_connections, NODE_ID_OUTPUT, processed, false, classes);
|
|
|
+ Error err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, NODE_ID_OUTPUT, processed, false, classes);
|
|
|
ERR_FAIL_COND(err != OK);
|
|
|
|
|
|
if (varying_setters.has(i)) {
|
|
|
for (int &E : varying_setters[i]) {
|
|
|
- err = _write_node(Type(i), &global_code, &global_code_per_node, nullptr, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes);
|
|
|
+ err = _write_node(Type(i), &global_code, &global_code_per_node, nullptr, func_code, default_tex_params, input_connections, E, processed, false, classes);
|
|
|
ERR_FAIL_COND(err != OK);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (emitters.has(i)) {
|
|
|
for (int &E : emitters[i]) {
|
|
|
- err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes);
|
|
|
+ err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, E, processed, false, classes);
|
|
|
ERR_FAIL_COND(err != OK);
|
|
|
}
|
|
|
}
|