diff options
-rw-r--r-- | SConstruct | 7 | ||||
-rw-r--r-- | main/SCsub | 3 | ||||
-rw-r--r-- | main/main.cpp | 2 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 71 | ||||
-rw-r--r-- | scene/resources/visual_shader.h | 6 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 4 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.h | 2 | ||||
-rw-r--r-- | tests/SCsub (renamed from main/tests/SCsub) | 0 | ||||
-rw-r--r-- | tests/test_astar.cpp (renamed from main/tests/test_astar.cpp) | 0 | ||||
-rw-r--r-- | tests/test_astar.h (renamed from main/tests/test_astar.h) | 0 | ||||
-rw-r--r-- | tests/test_basis.cpp (renamed from main/tests/test_basis.cpp) | 0 | ||||
-rw-r--r-- | tests/test_basis.h (renamed from main/tests/test_basis.h) | 0 | ||||
-rw-r--r-- | tests/test_class_db.cpp (renamed from main/tests/test_class_db.cpp) | 0 | ||||
-rw-r--r-- | tests/test_class_db.h (renamed from main/tests/test_class_db.h) | 0 | ||||
-rw-r--r-- | tests/test_gdscript.cpp (renamed from main/tests/test_gdscript.cpp) | 0 | ||||
-rw-r--r-- | tests/test_gdscript.h (renamed from main/tests/test_gdscript.h) | 0 | ||||
-rw-r--r-- | tests/test_gui.cpp (renamed from main/tests/test_gui.cpp) | 0 | ||||
-rw-r--r-- | tests/test_gui.h (renamed from main/tests/test_gui.h) | 0 | ||||
-rw-r--r-- | tests/test_main.cpp (renamed from main/tests/test_main.cpp) | 0 | ||||
-rw-r--r-- | tests/test_main.h (renamed from main/tests/test_main.h) | 0 | ||||
-rw-r--r-- | tests/test_math.cpp (renamed from main/tests/test_math.cpp) | 0 | ||||
-rw-r--r-- | tests/test_math.h (renamed from main/tests/test_math.h) | 0 | ||||
-rw-r--r-- | tests/test_oa_hash_map.cpp (renamed from main/tests/test_oa_hash_map.cpp) | 0 | ||||
-rw-r--r-- | tests/test_oa_hash_map.h (renamed from main/tests/test_oa_hash_map.h) | 0 | ||||
-rw-r--r-- | tests/test_ordered_hash_map.cpp (renamed from main/tests/test_ordered_hash_map.cpp) | 0 | ||||
-rw-r--r-- | tests/test_ordered_hash_map.h (renamed from main/tests/test_ordered_hash_map.h) | 0 | ||||
-rw-r--r-- | tests/test_physics_2d.cpp (renamed from main/tests/test_physics_2d.cpp) | 0 | ||||
-rw-r--r-- | tests/test_physics_2d.h (renamed from main/tests/test_physics_2d.h) | 0 | ||||
-rw-r--r-- | tests/test_physics_3d.cpp (renamed from main/tests/test_physics_3d.cpp) | 0 | ||||
-rw-r--r-- | tests/test_physics_3d.h (renamed from main/tests/test_physics_3d.h) | 0 | ||||
-rw-r--r-- | tests/test_render.cpp (renamed from main/tests/test_render.cpp) | 0 | ||||
-rw-r--r-- | tests/test_render.h (renamed from main/tests/test_render.h) | 0 | ||||
-rw-r--r-- | tests/test_shader_lang.cpp (renamed from main/tests/test_shader_lang.cpp) | 0 | ||||
-rw-r--r-- | tests/test_shader_lang.h (renamed from main/tests/test_shader_lang.h) | 0 | ||||
-rw-r--r-- | tests/test_string.h (renamed from main/tests/test_string.h) | 0 | ||||
-rw-r--r-- | tests/test_validate_testing.h (renamed from main/tests/test_validate_testing.h) | 0 |
36 files changed, 64 insertions, 31 deletions
diff --git a/SConstruct b/SConstruct index debae3c9df..98438d2c60 100644 --- a/SConstruct +++ b/SConstruct @@ -661,8 +661,7 @@ if selected_platform in platform_list: Export("env") - # build subdirs, the build order is dependent on link order. - + # Build subdirs, the build order is dependent on link order. SConscript("core/SCsub") SConscript("servers/SCsub") SConscript("scene/SCsub") @@ -671,9 +670,11 @@ if selected_platform in platform_list: SConscript("platform/SCsub") SConscript("modules/SCsub") + if env["tests"]: + SConscript("tests/SCsub") SConscript("main/SCsub") - SConscript("platform/" + selected_platform + "/SCsub") # build selected platform + SConscript("platform/" + selected_platform + "/SCsub") # Build selected platform. # Microsoft Visual Studio Project Generation if env["vsproj"]: diff --git a/main/SCsub b/main/SCsub index 793e5ed827..152d0c4d03 100644 --- a/main/SCsub +++ b/main/SCsub @@ -20,8 +20,5 @@ env.CommandNoCache( env.Depends("#main/app_icon.gen.h", "#main/app_icon.png") env.CommandNoCache("#main/app_icon.gen.h", "#main/app_icon.png", run_in_subprocess(main_builders.make_app_icon)) -if env["tests"]: - SConscript("tests/SCsub") - lib = env.add_library("main", env.main_sources) env.Prepend(LIBS=[lib]) diff --git a/main/main.cpp b/main/main.cpp index fad85ddf51..6965e5415a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -75,7 +75,7 @@ #include "servers/xr_server.h" #ifdef TESTS_ENABLED -#include "main/tests/test_main.h" +#include "tests/test_main.h" #endif #ifdef TOOLS_ENABLED diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 8236f9a9e3..792e1ac2d7 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -63,6 +63,21 @@ bool VisualShaderNode::is_port_separator(int p_index) const { return false; } +bool VisualShaderNode::is_output_port_connected(int p_port) const { + if (connected_output_ports.has(p_port)) { + return connected_output_ports[p_port]; + } + return false; +} + +void VisualShaderNode::set_output_port_connected(int p_port, bool p_connected) { + connected_output_ports[p_port] = p_connected; +} + +bool VisualShaderNode::is_code_generated() const { + return true; +} + Vector<VisualShader::DefaultTextureParam> VisualShaderNode::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const { return Vector<VisualShader::DefaultTextureParam>(); } @@ -526,6 +541,7 @@ void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from c.to_port = p_to_port; g->connections.push_back(c); g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node); + g->nodes[p_from_node].node->set_output_port_connected(p_from_port, true); _queue_update(); } @@ -557,6 +573,7 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port, c.to_port = p_to_port; g->connections.push_back(c); g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node); + g->nodes[p_from_node].node->set_output_port_connected(p_from_port, true); _queue_update(); return OK; @@ -570,6 +587,7 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { g->connections.erase(E); g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node); + g->nodes[p_from_node].node->set_output_port_connected(p_from_port, false); _queue_update(); return; } @@ -1105,6 +1123,35 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui // then this node + Vector<VisualShader::DefaultTextureParam> params = vsnode->get_default_texture_parameters(type, node); + for (int i = 0; i < params.size(); i++) { + def_tex_params.push_back(params[i]); + } + + Ref<VisualShaderNodeInput> input = vsnode; + bool skip_global = input.is_valid() && for_preview; + + if (!skip_global) { + global_code += vsnode->generate_global(get_mode(), type, node); + + String class_name = vsnode->get_class_name(); + if (class_name == "VisualShaderNodeCustom") { + class_name = vsnode->get_script_instance()->get_script()->get_path(); + } + if (!r_classes.has(class_name)) { + global_code_per_node += vsnode->generate_global_per_node(get_mode(), type, node); + for (int i = 0; i < TYPE_MAX; i++) { + global_code_per_func[Type(i)] += vsnode->generate_global_per_func(get_mode(), Type(i), node); + } + r_classes.insert(class_name); + } + } + + if (!vsnode->is_code_generated()) { // just generate globals and ignore locals + processed.insert(node); + return OK; + } + code += "// " + vsnode->get_caption() + ":" + itos(node) + "\n"; Vector<String> input_vars; @@ -1255,30 +1302,6 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui } } - Vector<VisualShader::DefaultTextureParam> params = vsnode->get_default_texture_parameters(type, node); - for (int i = 0; i < params.size(); i++) { - def_tex_params.push_back(params[i]); - } - - Ref<VisualShaderNodeInput> input = vsnode; - bool skip_global = input.is_valid() && for_preview; - - if (!skip_global) { - global_code += vsnode->generate_global(get_mode(), type, node); - - String class_name = vsnode->get_class_name(); - if (class_name == "VisualShaderNodeCustom") { - class_name = vsnode->get_script_instance()->get_script()->get_path(); - } - if (!r_classes.has(class_name)) { - global_code_per_node += vsnode->generate_global_per_node(get_mode(), type, node); - for (int i = 0; i < TYPE_MAX; i++) { - global_code_per_func[Type(i)] += vsnode->generate_global_per_func(get_mode(), Type(i), node); - } - r_classes.insert(class_name); - } - } - code += vsnode->generate_code(get_mode(), type, node, inputs, outputs, for_preview); code += "\n"; // diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index dbb8d1d28c..cad567d32f 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -182,6 +182,7 @@ class VisualShaderNode : public Resource { int port_preview; Map<int, Variant> default_input_values; + Map<int, bool> connected_output_ports; protected: bool simple_decl; @@ -222,6 +223,11 @@ public: virtual bool is_port_separator(int p_index) const; + bool is_output_port_connected(int p_port) const; + void set_output_port_connected(int p_port, bool p_connected); + + virtual bool is_code_generated() const; + virtual Vector<StringName> get_editable_properties() const; virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const; diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 88f5287831..4cf382a933 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -3915,6 +3915,10 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu return code; } +bool VisualShaderNodeTextureUniform::is_code_generated() const { + return is_output_port_connected(0) || is_output_port_connected(1); // rgb or alpha +} + String VisualShaderNodeTextureUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String id = get_uniform_name(); String code = "\t{\n"; diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 13a132c60e..b82d5c65c9 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -1715,6 +1715,8 @@ public: virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override; virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty + virtual bool is_code_generated() const override; + Vector<StringName> get_editable_properties() const override; void set_texture_type(TextureType p_type); diff --git a/main/tests/SCsub b/tests/SCsub index cb1d35b12f..cb1d35b12f 100644 --- a/main/tests/SCsub +++ b/tests/SCsub diff --git a/main/tests/test_astar.cpp b/tests/test_astar.cpp index cb5fcfe37b..cb5fcfe37b 100644 --- a/main/tests/test_astar.cpp +++ b/tests/test_astar.cpp diff --git a/main/tests/test_astar.h b/tests/test_astar.h index 0992812c18..0992812c18 100644 --- a/main/tests/test_astar.h +++ b/tests/test_astar.h diff --git a/main/tests/test_basis.cpp b/tests/test_basis.cpp index 5904fc386a..5904fc386a 100644 --- a/main/tests/test_basis.cpp +++ b/tests/test_basis.cpp diff --git a/main/tests/test_basis.h b/tests/test_basis.h index 63297bd3b8..63297bd3b8 100644 --- a/main/tests/test_basis.h +++ b/tests/test_basis.h diff --git a/main/tests/test_class_db.cpp b/tests/test_class_db.cpp index 3171091402..3171091402 100644 --- a/main/tests/test_class_db.cpp +++ b/tests/test_class_db.cpp diff --git a/main/tests/test_class_db.h b/tests/test_class_db.h index 1a31cfb01b..1a31cfb01b 100644 --- a/main/tests/test_class_db.h +++ b/tests/test_class_db.h diff --git a/main/tests/test_gdscript.cpp b/tests/test_gdscript.cpp index a50311972f..a50311972f 100644 --- a/main/tests/test_gdscript.cpp +++ b/tests/test_gdscript.cpp diff --git a/main/tests/test_gdscript.h b/tests/test_gdscript.h index 6595da1430..6595da1430 100644 --- a/main/tests/test_gdscript.h +++ b/tests/test_gdscript.h diff --git a/main/tests/test_gui.cpp b/tests/test_gui.cpp index d46a13d2c0..d46a13d2c0 100644 --- a/main/tests/test_gui.cpp +++ b/tests/test_gui.cpp diff --git a/main/tests/test_gui.h b/tests/test_gui.h index 5a23179eee..5a23179eee 100644 --- a/main/tests/test_gui.h +++ b/tests/test_gui.h diff --git a/main/tests/test_main.cpp b/tests/test_main.cpp index 91eff28f86..91eff28f86 100644 --- a/main/tests/test_main.cpp +++ b/tests/test_main.cpp diff --git a/main/tests/test_main.h b/tests/test_main.h index 8273b74eac..8273b74eac 100644 --- a/main/tests/test_main.h +++ b/tests/test_main.h diff --git a/main/tests/test_math.cpp b/tests/test_math.cpp index 5f84bad4e9..5f84bad4e9 100644 --- a/main/tests/test_math.cpp +++ b/tests/test_math.cpp diff --git a/main/tests/test_math.h b/tests/test_math.h index 77bce8dd66..77bce8dd66 100644 --- a/main/tests/test_math.h +++ b/tests/test_math.h diff --git a/main/tests/test_oa_hash_map.cpp b/tests/test_oa_hash_map.cpp index 9182f66b61..9182f66b61 100644 --- a/main/tests/test_oa_hash_map.cpp +++ b/tests/test_oa_hash_map.cpp diff --git a/main/tests/test_oa_hash_map.h b/tests/test_oa_hash_map.h index eb2b3d1e99..eb2b3d1e99 100644 --- a/main/tests/test_oa_hash_map.h +++ b/tests/test_oa_hash_map.h diff --git a/main/tests/test_ordered_hash_map.cpp b/tests/test_ordered_hash_map.cpp index d18a3784be..d18a3784be 100644 --- a/main/tests/test_ordered_hash_map.cpp +++ b/tests/test_ordered_hash_map.cpp diff --git a/main/tests/test_ordered_hash_map.h b/tests/test_ordered_hash_map.h index f251da0ba2..f251da0ba2 100644 --- a/main/tests/test_ordered_hash_map.h +++ b/tests/test_ordered_hash_map.h diff --git a/main/tests/test_physics_2d.cpp b/tests/test_physics_2d.cpp index c82ae920bc..c82ae920bc 100644 --- a/main/tests/test_physics_2d.cpp +++ b/tests/test_physics_2d.cpp diff --git a/main/tests/test_physics_2d.h b/tests/test_physics_2d.h index 517d324f3b..517d324f3b 100644 --- a/main/tests/test_physics_2d.h +++ b/tests/test_physics_2d.h diff --git a/main/tests/test_physics_3d.cpp b/tests/test_physics_3d.cpp index 72de2041e4..72de2041e4 100644 --- a/main/tests/test_physics_3d.cpp +++ b/tests/test_physics_3d.cpp diff --git a/main/tests/test_physics_3d.h b/tests/test_physics_3d.h index d03f2c6573..d03f2c6573 100644 --- a/main/tests/test_physics_3d.h +++ b/tests/test_physics_3d.h diff --git a/main/tests/test_render.cpp b/tests/test_render.cpp index d936dd72e7..d936dd72e7 100644 --- a/main/tests/test_render.cpp +++ b/tests/test_render.cpp diff --git a/main/tests/test_render.h b/tests/test_render.h index 4a6340c443..4a6340c443 100644 --- a/main/tests/test_render.h +++ b/tests/test_render.h diff --git a/main/tests/test_shader_lang.cpp b/tests/test_shader_lang.cpp index 34ee3e3210..34ee3e3210 100644 --- a/main/tests/test_shader_lang.cpp +++ b/tests/test_shader_lang.cpp diff --git a/main/tests/test_shader_lang.h b/tests/test_shader_lang.h index 2811c5f46e..2811c5f46e 100644 --- a/main/tests/test_shader_lang.h +++ b/tests/test_shader_lang.h diff --git a/main/tests/test_string.h b/tests/test_string.h index 25fd513a1a..25fd513a1a 100644 --- a/main/tests/test_string.h +++ b/tests/test_string.h diff --git a/main/tests/test_validate_testing.h b/tests/test_validate_testing.h index 5be7d45185..5be7d45185 100644 --- a/main/tests/test_validate_testing.h +++ b/tests/test_validate_testing.h |