From 0f1a717c643f3353ed75051e2f432aacdefe0ed0 Mon Sep 17 00:00:00 2001 From: MarianoGNU Date: Mon, 20 Jun 2016 00:50:33 -0300 Subject: [PATCH] Remove unused connection. ShaderEditor should'nt handle ShaderGraphs. Fixes #4678 && #4745 --- scene/2d/canvas_item.cpp | 17 ---------- scene/2d/canvas_item.h | 1 - tools/editor/plugins/shader_editor_plugin.cpp | 32 +++++++++++-------- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 8864459dfb2..fa9b040d926 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -112,21 +112,9 @@ void CanvasItemMaterial::_get_property_list( List *p_list) const { void CanvasItemMaterial::set_shader(const Ref& p_shader) { ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_CANVAS_ITEM); -#ifdef TOOLS_ENABLED - if (shader.is_valid()) { - shader->disconnect("changed",this,"_shader_changed"); - } -#endif shader=p_shader; -#ifdef TOOLS_ENABLED - - if (shader.is_valid()) { - shader->connect("changed",this,"_shader_changed"); - } -#endif - RID rid; if (shader.is_valid()) rid=shader->get_rid(); @@ -151,11 +139,6 @@ Variant CanvasItemMaterial::get_shader_param(const StringName& p_param) const{ return VS::get_singleton()->canvas_item_material_get_shader_param(material,p_param); } -void CanvasItemMaterial::_shader_changed() { - - -} - RID CanvasItemMaterial::get_rid() const { return material; diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index d915f742ec5..8b44e098575 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -60,7 +60,6 @@ protected: bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list( List *p_list) const; - void _shader_changed(); static void _bind_methods(); void get_argument_options(const StringName& p_function,int p_idx,List*r_options) const; diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index f4b294daa55..83db6509529 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -30,6 +30,7 @@ #include "tools/editor/editor_settings.h" #include "spatial_editor_plugin.h" +#include "scene/resources/shader_graph.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/keyboard.h" @@ -144,8 +145,6 @@ void ShaderTextEditor::_validate_script() { //List params; //shader->get_param_list(¶ms); - print_line("compile: type: "+itos(type)+" code:\n"+code); - Error err = ShaderLanguage::compile(code,type,NULL,NULL,&errortxt,&line,&col); if (err!=OK) { @@ -557,34 +556,41 @@ ShaderEditor::ShaderEditor() { void ShaderEditorPlugin::edit(Object *p_object) { - if (!p_object->cast_to()) + Shader* s = p_object->cast_to(); + if (!s || s->cast_to()) { + shader_editor->hide(); //Dont edit ShaderGraph return; + } - shader_editor->edit(p_object->cast_to()); + if (_2d && s->get_mode()==Shader::MODE_CANVAS_ITEM) + shader_editor->edit(s); + else if (!_2d && s->get_mode()==Shader::MODE_MATERIAL) + shader_editor->edit(s); } bool ShaderEditorPlugin::handles(Object *p_object) const { + bool handles = true; Shader *shader=p_object->cast_to(); - if (!shader) - return false; - if (_2d) - return shader->get_mode()==Shader::MODE_CANVAS_ITEM; - else + if (!shader || shader->cast_to()) // Dont handle ShaderGraph's + handles = false; + if (handles && _2d) + handles = shader->get_mode()==Shader::MODE_CANVAS_ITEM; + else if (handles && !_2d) return shader->get_mode()==Shader::MODE_MATERIAL; + + if (!handles) + shader_editor->hide(); + return handles; } void ShaderEditorPlugin::make_visible(bool p_visible) { if (p_visible) { shader_editor->show(); - //shader_editor->set_process(true); } else { - shader_editor->apply_shaders(); - //shader_editor->hide(); - //shader_editor->set_process(false); } }