From 1c5376ae5951a4e47b972244cd2ec47760469b0c Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 12 Sep 2017 07:58:18 -0300 Subject: [PATCH] Many fixes to visual script, changed virtuals override for a proper selector. --- drivers/gles3/shaders/scene.glsl | 23 ++- editor/property_selector.cpp | 33 +++- editor/property_selector.h | 3 +- .../visual_script/visual_script_editor.cpp | 177 +++++++----------- modules/visual_script/visual_script_editor.h | 7 +- modules/visual_script/visual_script_nodes.cpp | 20 +- scene/animation/animation_tree_player.cpp | 1 + 7 files changed, 130 insertions(+), 134 deletions(-) diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 73268c19146d..5f83033293e9 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -935,17 +935,26 @@ LIGHT_SHADER_CODE #elif defined(DIFFUSE_BURLEY) { - float NdotL = dot(L, N); - float NdotV = dot(N, V); - float VdotH = dot(N, normalize(L+V)); + + + vec3 H = normalize(V + L); + float NoL = max(0.0,dot(N, L)); + float VoH = max(0.0,dot(L, H)); + float NoV = max(0.0,dot(N, V)); + + float FD90 = 0.5 + 2.0 * VoH * VoH * roughness; + float FdV = 1.0 + (FD90 - 1.0) * pow( 1.0 - NoV, 5.0 ); + float FdL = 1.0 + (FD90 - 1.0) * pow( 1.0 - NoL, 5.0 ); + light_amount = ( (1.0 / M_PI) * FdV * FdL ); +/* float energyBias = mix(roughness, 0.0, 0.5); float energyFactor = mix(roughness, 1.0, 1.0 / 1.51); - float fd90 = energyBias + 2.0 * VdotH * VdotH * roughness; + float fd90 = energyBias + 2.0 * VoH * VoH * roughness; float f0 = 1.0; - float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NdotL, 5.0); - float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NdotV, 5.0); + float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NoL, 5.0); + float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NoV, 5.0); - light_amount = lightScatter * viewScatter * energyFactor; + light_amount = lightScatter * viewScatter * energyFactor;*/ } #else //lambert diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 6bbb35ceab1e..86de7c56e178 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -75,6 +75,8 @@ void PropertySelector::_update_search() { if (properties) set_title(TTR("Select Property")); + else if (virtuals_only) + set_title(TTR("Select Virtual Method")); else set_title(TTR("Select Method")); @@ -209,7 +211,7 @@ void PropertySelector::_update_search() { StringName base = base_type; while (base) { methods.push_back(MethodInfo("*" + String(base))); - ClassDB::get_method_list(base, &methods, true); + ClassDB::get_method_list(base, &methods, true, true); base = ClassDB::get_parent_class(base); } } @@ -230,11 +232,13 @@ void PropertySelector::_update_search() { Ref icon; script_methods = false; + print_line("name: " + E->get().name); + String rep = E->get().name.replace("*", ""); if (E->get().name == "*Script Methods") { icon = get_icon("Script", "EditorIcons"); script_methods = true; - } else if (has_icon(E->get().name, "EditorIcons")) { - icon = get_icon(E->get().name, "EditorIcons"); + } else if (has_icon(rep, "EditorIcons")) { + icon = get_icon(rep, "EditorIcons"); } else { icon = get_icon("Object", "EditorIcons"); } @@ -247,6 +251,12 @@ void PropertySelector::_update_search() { if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL)) continue; + if (virtuals_only && !(E->get().flags & METHOD_FLAG_VIRTUAL)) + continue; + + if (!virtuals_only && (E->get().flags & METHOD_FLAG_VIRTUAL)) + continue; + if (search_box->get_text() != String() && name.find(search_box->get_text()) == -1) continue; @@ -283,6 +293,12 @@ void PropertySelector::_update_search() { desc += " )"; + if (E->get().flags & METHOD_FLAG_CONST) + desc += " const"; + + if (E->get().flags & METHOD_FLAG_VIRTUAL) + desc += " virtual"; + item->set_text(0, desc); item->set_metadata(0, name); item->set_selectable(0, true); @@ -397,7 +413,7 @@ void PropertySelector::_notification(int p_what) { } } -void PropertySelector::select_method_from_base_type(const String &p_base, const String &p_current) { +void PropertySelector::select_method_from_base_type(const String &p_base, const String &p_current, bool p_virtuals_only) { base_type = p_base; selected = p_current; @@ -405,6 +421,7 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const script = 0; properties = false; instance = NULL; + virtuals_only = p_virtuals_only; popup_centered_ratio(0.6); search_box->set_text(""); @@ -421,6 +438,7 @@ void PropertySelector::select_method_from_script(const Ref