diff options
31 files changed, 414 insertions, 117 deletions
diff --git a/DONORS.md b/DONORS.md new file mode 100644 index 0000000000..09049ede48 --- /dev/null +++ b/DONORS.md @@ -0,0 +1,141 @@ +# Donors to the Godot Engine project + +Godot Engine is a non-profit project developed by a community of voluntary +contributors, as well as occasional paid contributors thanks to the financial +support of generous donors. + +The ways to donate to the project, as well as details on how the funds are +used, are described on [Godot's website](https://godotengine.org/donate). + +The following is a list of the current monthly donors, to be have their +generous deed immortalized in the next stable release of Godot Engine. + +## Platinum sponsors + +None so far, but your company could be the first! :) + +## Gold sponsors + + Gamblify <https://www.gamblify.com> + +## Mini sponsors + + Arron Washington + Chrisartguy + Christian Uldall Pedersen + Hein-Pieter van Braam + Matthieu Huvé + Neal Gompa (Conan Kudo) + Olimpiu Metiu + Ruslan Mustakov + +## Gold donors + + Alexander Otto + Jake Bo + Javier + Nathan Warden + Ranoller + Rémi Verschelde + Stephan Lanfermann + + Andreas Schüle + Bernhard Liebl + Jordan M Lucas + + BanjoNode2D + Chris Serino + Conrad Curry + Craig Smith + David Churchill + Dean Harmon + Guilherme Felipe de C. G. da Silva + Henrique Alves + Laurence Bannister + Leo + Przemysław Gołąb (n-pigeon) + Robert Willes + Robin Arys + summerblind + Testus Maximus + Thomas Bjarnelöf + + Amanda Haldy + Andreas Haas + Bryanna M + Cody Parker + D + Ezra Theunissen + flesk + François Cantin + Hendrik Mans + Jeppe Zapp + Johannes Wuensch + Justin Arnold + Justo Delgado Baudí + Leandro Voltolino + Myles + Robert Podgorski + Scott Beacon + x1212 + +## Silver donors + + Alex Barsukov + Avencherus + Bastian Böhm + Ben Vercammen + Bryan Stevenson + Collin Shooltz + Fabian Becker + fengjiongmax + Geequlim + Gerrit Großkopf + Guldoman + hatniX + HeartBeast + Heribert Hirth + Hunter Jones + imekon + Jacob McKenney + Jonathon + Josh 'Cheeseness' Bush + Julian Murgia + Juraj Móza + Kevin Boyer + Klavdij Voncina + Lisandro Lorea + magodev + Martin Novák + Matthew Fitzpatrick + Matthew Valancy + Matthias Hölzl + Max R.R. Collada + Michael Gringauz + Mikael Olsson + Moritz Laass + nee + nvgrod + Pablo Seibelt + Pan Ip + Paul Mason + Paweł Kowal + Pietro Vertechi + rayos + Richman Stewart + Roger Smith + Sam Van Campenhout + Sam Vila + Sasori Olkof + Sootstone + Tavo Tell + Tom Larrow + Trent McPheron + Troy Bonneau + UltyX + Xananax & karroffel + +## Bronze donors + +There are even more donors that support the project with a small monthly donation. +Every bit counts and we thank every one of them for their amazing support! diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index c308e9eddb..bdd54543d2 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -751,8 +751,9 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss"; actions[VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy"; actions[VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow"; - actions[VS::SHADER_SPATIAL].renames["SSS_SPREAD"] = "sss_spread"; + //actions[VS::SHADER_SPATIAL].renames["SSS_SPREAD"] = "sss_spread"; actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; + actions[VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission"; actions[VS::SHADER_SPATIAL].renames["AO"] = "ao"; actions[VS::SHADER_SPATIAL].renames["EMISSION"] = "emission"; //actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2; @@ -782,6 +783,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n"; + actions[VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; @@ -792,7 +794,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_half_lambert"] = "#define DIFFUSE_HALF_LAMBERT\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n"; diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index ef4925895c..7c60a8ee97 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -887,7 +887,7 @@ float GTR1(float NdotH, float a) -void light_compute(vec3 N, vec3 L,vec3 V,vec3 B, vec3 T,vec3 light_color,vec3 diffuse_color, float specular_blob_intensity, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse, inout vec3 specular) { +void light_compute(vec3 N, vec3 L,vec3 V,vec3 B, vec3 T,vec3 light_color,vec3 diffuse_color, vec3 transmission, float specular_blob_intensity, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse, inout vec3 specular) { #if defined(USE_LIGHT_SHADER_CODE) //light is written by the light shader @@ -900,10 +900,16 @@ LIGHT_SHADER_CODE float dotNL = max(dot(N,L), 0.0 ); -#if defined(DIFFUSE_HALF_LAMBERT) +#if defined(DIFFUSE_OREN_NAYAR) + vec3 light_amount; +#else + float light_amount; +#endif + - float hl = dot(N,L) * 0.5 + 0.5; - diffuse += hl * light_color * diffuse_color; +#if defined(DIFFUSE_LAMBERT_WRAP) + //energy conserving lambert wrap shader + light_amount = max(0.0,(dot(N,L) + roughness) / ((1.0 + roughness) * (1.0 + roughness))); #elif defined(DIFFUSE_OREN_NAYAR) @@ -919,12 +925,12 @@ LIGHT_SHADER_CODE vec3 A = 1.0 + sigma2 * (diffuse_color / (sigma2 + 0.13) + 0.5 / (sigma2 + 0.33)); float B = 0.45 * sigma2 / (sigma2 + 0.09); - diffuse += diffuse_color * max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI; + light_amount = max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI; } #elif defined(DIFFUSE_TOON) - diffuse += smoothstep(-roughness,max(roughness,0.01),dot(N,L)) * light_color * diffuse_color; + light_amount = smoothstep(-roughness,max(roughness,0.01),dot(N,L)); #elif defined(DIFFUSE_BURLEY) @@ -939,11 +945,17 @@ LIGHT_SHADER_CODE float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NdotL, 5.0); float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NdotV, 5.0); - diffuse+= light_color * diffuse_color * lightScatter * viewScatter * energyFactor; + light_amount = lightScatter * viewScatter * energyFactor; } #else //lambert - diffuse += dotNL * light_color * diffuse_color; + light_amount = dotNL; +#endif + +#if defined(TRANSMISSION_USED) + diffuse += light_color * diffuse_color * mix(vec3(light_amount),vec3(1.0),transmission); +#else + diffuse += light_color * diffuse_color * light_amount; #endif @@ -1116,7 +1128,7 @@ vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 po } #endif -void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) { +void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, vec3 transmission, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) { vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex; float light_length = length( light_rel_vec ); @@ -1170,11 +1182,11 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino light_attenuation*=mix(omni_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow); } - light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,omni_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,transmission,omni_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); } -void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) { +void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, vec3 transmission,float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) { vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex; float light_length = length( light_rel_vec ); @@ -1204,7 +1216,7 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi light_attenuation*=mix(spot_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow); } - light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,spot_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,transmission,spot_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); } @@ -1499,6 +1511,7 @@ void main() { //lay out everything, whathever is unused is optimized away anyway highp vec3 vertex = vertex_interp; vec3 albedo = vec3(0.8,0.8,0.8); + vec3 transmission = vec3(0.0); float metallic = 0.0; float specular = 0.5; vec3 emission = vec3(0.0,0.0,0.0); @@ -1822,7 +1835,7 @@ FRAGMENT_SHADER_CODE specular_light*=mix(vec3(1.0),light_attenuation,specular_light_interp.a); #else - light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,transmission,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); #endif @@ -1860,11 +1873,11 @@ FRAGMENT_SHADER_CODE #else for(int i=0;i<omni_light_count;i++) { - light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light); + light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,transmission,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light); } for(int i=0;i<spot_light_count;i++) { - light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light); + light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,transmission,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light); } #endif //USE_VERTEX_LIGHTING diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 0e22f0d386..c9d1548bfb 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1711,12 +1711,6 @@ void EditorHelp::_notification(int p_what) { _update_doc(); } break; - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); - style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color")); - background_panel->add_style_override("panel", style); - } break; - default: break; } } @@ -1786,14 +1780,11 @@ EditorHelp::EditorHelp() { { background_panel = memnew(Panel); - Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); - style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color")); background_panel->set_v_size_flags(SIZE_EXPAND_FILL); - background_panel->add_style_override("panel", style); //get_stylebox("normal","TextEdit")); vbc->add_child(background_panel); class_desc = memnew(RichTextLabel); background_panel->add_child(class_desc); - class_desc->set_area_as_parent_rect(8); + class_desc->set_area_as_parent_rect(); class_desc->connect("meta_clicked", this, "_class_desc_select"); class_desc->connect("gui_input", this, "_class_desc_input"); } @@ -1881,10 +1872,6 @@ void EditorHelpBit::_bind_methods() { } void EditorHelpBit::_notification(int p_what) { - - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - add_style_override("panel", get_stylebox("ScriptPanel", "EditorStyles")); - } } void EditorHelpBit::set_text(const String &p_text) { @@ -1897,8 +1884,7 @@ EditorHelpBit::EditorHelpBit() { rich_text = memnew(RichTextLabel); add_child(rich_text); - rich_text->set_area_as_parent_rect(8 * EDSCALE); + rich_text->set_area_as_parent_rect(); rich_text->connect("meta_clicked", this, "_meta_clicked"); set_custom_minimum_size(Size2(0, 70 * EDSCALE)); - add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles")); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9c9eef848a..db76a27f5f 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -603,7 +603,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Default"); set("text_editor/theme/line_spacing", 4); - set("text_editor/theme/adapted_code_editor_background_color", true); _load_default_text_editor_theme(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 8943d5f0dc..bef9f78854 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -198,6 +198,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { bool highlight_tabs = EDITOR_DEF("interface/theme/highlight_tabs", false); int border_size = EDITOR_DEF("interface/theme/border_size", 1); + Color script_bg_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); + switch (preset) { case 0: { // Default highlight_color = Color::html("#699ce8"); @@ -279,8 +281,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { editor_register_fonts(theme); // Editor background - Ref<StyleBoxFlat> style_panel = make_flat_stylebox(dark_color_2, 4, 4, 4, 4); - theme->set_stylebox("Background", "EditorStyles", style_panel); + theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(dark_color_2, 4, 4, 4, 4)); // Focus Ref<StyleBoxFlat> focus_sbt = make_flat_stylebox(contrast_color_1, 4, 4, 4, 4); @@ -424,12 +425,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_tree_bg->set_border_color_all(dark_color_3); theme->set_stylebox("bg", "Tree", style_tree_bg); - // Script background - Ref<StyleBoxFlat> style_script_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); - style_script_bg->set_border_width_all(border_width); - style_script_bg->set_border_color_all(dark_color_3); - theme->set_stylebox("ScriptPanel", "EditorStyles", style_script_bg); - // Tree theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons")); theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons")); @@ -614,11 +609,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); //RichTextLabel - theme->set_color("font_color", "RichTextLabel", font_color); + Color rtl_combined_bg_color = dark_color_1.linear_interpolate(script_bg_color, script_bg_color.a); + Color rtl_font_color = (rtl_combined_bg_color.r + rtl_combined_bg_color.g + rtl_combined_bg_color.b > 0.5 * 3) ? Color(0, 0, 0) : Color(1, 1, 1); + theme->set_color("default_color", "RichTextLabel", rtl_font_color); theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox()); + theme->set_stylebox("normal", "RichTextLabel", make_flat_stylebox(script_bg_color, 6, 6, 6, 6)); // Panel - theme->set_stylebox("panel", "Panel", style_panel); + theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4)); // Label theme->set_color("font_color", "Label", font_color); diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/cube_grid_theme_editor_plugin.cpp index 08b38c2ca2..decf8b2bb4 100644 --- a/editor/plugins/cube_grid_theme_editor_plugin.cpp +++ b/editor/plugins/cube_grid_theme_editor_plugin.cpp @@ -88,7 +88,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, if (mesh.is_null()) continue; - int id = p_library->find_item_name(mi->get_name()); + int id = p_library->find_item_by_name(mi->get_name()); if (id < 0) { id = p_library->get_last_unused_item_id(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a529f152dc..dbc3bff873 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -972,6 +972,14 @@ void ScriptEditor::_menu_option(int p_option) { EditorNode::get_singleton()->show_warning("Can't obtain the script for running"); break; } + + current->apply_code(); + Error err = scr->reload(false); //hard reload script before running always + + if (err != OK) { + EditorNode::get_singleton()->show_warning("Script failed reloading, check console for errors."); + return; + } if (!scr->is_tool()) { EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run"); @@ -1149,8 +1157,6 @@ void ScriptEditor::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles")); - help_search->set_icon(get_icon("HelpSearch", "EditorIcons")); site_search->set_icon(get_icon("Instance", "EditorIcons")); class_search->set_icon(get_icon("ClassList", "EditorIcons")); @@ -2210,7 +2216,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { members_overview->set_v_size_flags(SIZE_EXPAND_FILL); tab_container = memnew(TabContainer); - tab_container->add_style_override("panel", p_editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles")); tab_container->set_tabs_visible(false); script_split->add_child(tab_container); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 33890d890d..fae57eb5d2 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -75,14 +75,9 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->clear_colors(); - /* color from color_theme or from editor color */ - - Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); - if (EDITOR_DEF("text_editor/theme/adapted_code_editor_background_color", false)) - background_color = get_color("dark_color_1", "Editor"); - /* keyword color */ - text_edit->add_color_override("background_color", background_color); + + text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0))); text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0))); text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"))); text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"))); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index c2c26bfe6c..7b40f69082 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -244,8 +244,22 @@ void SpriteFramesEditor::_down_pressed() { void SpriteFramesEditor::_delete_pressed() { + ERR_FAIL_COND(!frames->has_animation(edited_anim)); + if (tree->get_current() < 0) return; + + int to_delete = tree->get_current(); + if (to_delete < 0 || to_delete >= frames->get_frame_count(edited_anim)) { + return; + } + + undo_redo->create_action(TTR("Delete Resource")); + undo_redo->add_do_method(frames, "remove_frame", edited_anim, to_delete); + undo_redo->add_undo_method(frames, "add_frame", edited_anim, frames->get_frame(edited_anim, to_delete), to_delete); + undo_redo->add_do_method(this, "_update_library"); + undo_redo->add_undo_method(this, "_update_library"); + undo_redo->commit_action(); } void SpriteFramesEditor::_animation_select() { diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 2cd0221ab6..9fd31f818e 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1321,6 +1321,11 @@ void ProjectSettingsEditor::set_plugins_page() { tab_container->set_current_tab(plugin_settings->get_index()); } +TabContainer *ProjectSettingsEditor::get_tabs() { + + return tab_container; +} + void ProjectSettingsEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected); @@ -1361,6 +1366,8 @@ void ProjectSettingsEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar); ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show); + + ClassDB::bind_method(D_METHOD("get_tabs"), &ProjectSettingsEditor::get_tabs); } ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index ceec089953..e58ba9b1c0 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -159,6 +159,8 @@ public: void popup_project_settings(); void set_plugins_page(); + TabContainer *get_tabs(); + void queue_save(); ProjectSettingsEditor(EditorData *p_data); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index c71cc5af3f..b92ebed167 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -171,33 +171,50 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str Pair<String, Ref<Texture> > pair; pair.first = file; pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); + list.push_back(pair); + } + } + + if (add_directories) { + for (int i = 0; i < efsd->get_subdir_count(); i++) { - if (search_text != String() && list.size() > 0) { + _parse_fs(efsd->get_subdir(i), list); + } + } +} - float this_sim = _path_cmp(search_text, file); - float other_sim = _path_cmp(list[0].first, file); - int pos = 1; +Vector<Pair<String, Ref<Texture> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture> > > &list) { - while (pos < list.size() && this_sim <= other_sim) { - other_sim = _path_cmp(list[pos++].first, file); - } + String search_text = search_box->get_text(); + Vector<Pair<String, Ref<Texture> > > sorted_list; - pos = this_sim >= other_sim ? pos - 1 : pos; - list.insert(pos, pair); + if (search_text == String() || list.size() == 0) + return sorted_list; - } else { + Vector<float> scores; + scores.resize(list.size()); + for (int i = 0; i < list.size(); i++) + scores[i] = _path_cmp(search_text, list[i].first); - list.push_back(pair); - } - } - } + while (list.size() > 0) { - if (add_directories) { - for (int i = 0; i < efsd->get_subdir_count(); i++) { + float best_score = 0.0f; + int best_idx = 0; - _parse_fs(efsd->get_subdir(i), list); + for (int i = 0; i < list.size(); i++) { + float current_score = scores[i]; + if (current_score > best_score) { + best_score = current_score; + best_idx = i; + } } + + sorted_list.push_back(list[best_idx]); + list.remove(best_idx); + scores.remove(best_idx); } + + return sorted_list; } void EditorQuickOpen::_update_search() { @@ -208,6 +225,7 @@ void EditorQuickOpen::_update_search() { Vector<Pair<String, Ref<Texture> > > list; _parse_fs(efsd, list); + list = _sort_fs(list); for (int i = 0; i < list.size(); i++) { TreeItem *ti = search_options->create_item(root); diff --git a/editor/quick_open.h b/editor/quick_open.h index 3f64dd8cf0..5b91965920 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -49,6 +49,7 @@ class EditorQuickOpen : public ConfirmationDialog { void _sbox_input(const Ref<InputEvent> &p_ie); void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list); + Vector<Pair<String, Ref<Texture> > > _sort_fs(Vector<Pair<String, Ref<Texture> > > &list); float _path_cmp(String search, String path) const; void _confirmed(); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 1b932f040e..ced1c3ca12 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -396,8 +396,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) { Map<int, List<Pair<Transform, IndexKey> > > multimesh_items; - print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size())); - for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) { ERR_CONTINUE(!cell_map.has(E->get())); @@ -464,7 +462,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) { //update multimeshes for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) { - print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size())); Octant::MultimeshInstance mmi; RID mm = VS::get_singleton()->multimesh_create(); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 8386687c9f..37bd730d08 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -523,7 +523,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { if (Object::cast_to<VisualScriptExpression>(*node)) { Ref<VisualScriptComment> vsc = node; gnode->set_comment(true); - gnode->set_resizeable(true); + gnode->set_resizable(true); gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE); gnode->connect("resize_request", this, "_comment_node_resized", varray(E->get())); } diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 8730be0c06..bef0808fd0 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -270,7 +270,7 @@ void GraphNode::_notification(int p_what) { } } - if (resizeable) { + if (resizable) { draw_texture(resizer, get_size() - resizer->get_size()); } } @@ -594,7 +594,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Ref<Texture> resizer = get_icon("resizer"); - if (resizeable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) { + if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) { resizing = true; resizing_from = mpos; @@ -645,15 +645,15 @@ bool GraphNode::is_comment() const { return comment; } -void GraphNode::set_resizeable(bool p_enable) { +void GraphNode::set_resizable(bool p_enable) { - resizeable = p_enable; + resizable = p_enable; update(); } -bool GraphNode::is_resizeable() const { +bool GraphNode::is_resizable() const { - return resizeable; + return resizable; } void GraphNode::_bind_methods() { @@ -678,8 +678,8 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("set_comment", "comment"), &GraphNode::set_comment); ClassDB::bind_method(D_METHOD("is_comment"), &GraphNode::is_comment); - ClassDB::bind_method(D_METHOD("set_resizeable", "resizeable"), &GraphNode::set_resizeable); - ClassDB::bind_method(D_METHOD("is_resizeable"), &GraphNode::is_resizeable); + ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &GraphNode::set_resizable); + ClassDB::bind_method(D_METHOD("is_resizable"), &GraphNode::is_resizable); ClassDB::bind_method(D_METHOD("set_selected", "selected"), &GraphNode::set_selected); ClassDB::bind_method(D_METHOD("is_selected"), &GraphNode::is_selected); @@ -702,7 +702,7 @@ void GraphNode::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), "set_show_close_button", "is_close_button_visible"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizeable"), "set_resizeable", "is_resizeable"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable"), "set_resizable", "is_resizable"); ADD_SIGNAL(MethodInfo("offset_changed")); ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to"))); @@ -722,7 +722,7 @@ GraphNode::GraphNode() { connpos_dirty = true; set_mouse_filter(MOUSE_FILTER_STOP); comment = false; - resizeable = false; + resizable = false; resizing = false; selected = false; } diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index 416d711aab..a606e47acd 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -68,7 +68,7 @@ private: bool show_close; Vector2 offset; bool comment; - bool resizeable; + bool resizable; bool resizing; Vector2 resizing_from; @@ -151,8 +151,8 @@ public: void set_comment(bool p_enable); bool is_comment() const; - void set_resizeable(bool p_enable); - bool is_resizeable() const; + void set_resizable(bool p_enable); + bool is_resizable() const; virtual Size2 get_minimum_size() const; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index a3f116c883..e51955ed66 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -80,6 +80,10 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return NULL; } +Rect2 RichTextLabel::_get_text_rect() { + Ref<StyleBox> style = get_stylebox("normal"); + return Rect2(style->get_offset(), get_size() - style->get_minimum_size()); +} void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) { RID ci; @@ -583,7 +587,7 @@ void RichTextLabel::_update_scroll() { int total_height = 0; if (main->lines.size()) - total_height = main->lines[main->lines.size() - 1].height_accum_cache; + total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height; bool exceeds = total_height > get_size().height && scroll_active; @@ -641,7 +645,11 @@ void RichTextLabel::_notification(int p_what) { _update_scroll(); RID ci = get_canvas_item(); + Size2 size = get_size(); + Rect2 text_rect = _get_text_rect(); + + draw_style_box(get_stylebox("normal"), Rect2(Point2(), size)); if (has_focus()) { VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); @@ -657,10 +665,10 @@ void RichTextLabel::_notification(int p_what) { int total_chars = 0; while (from_line < main->lines.size()) { - if (main->lines[from_line].height_accum_cache >= ofs) + if (main->lines[from_line].height_accum_cache + _get_text_rect().get_position().y >= ofs) break; - from_line++; total_chars += main->lines[from_line].char_count; + from_line++; } if (from_line >= main->lines.size()) @@ -672,7 +680,7 @@ void RichTextLabel::_notification(int p_what) { while (y < size.height && from_line < main->lines.size()) { - _process_line(main, Point2(), y, size.width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars); + _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars); total_chars += main->lines[from_line].char_count; from_line++; } @@ -686,7 +694,7 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item *r_click_item = NULL; Size2 size = get_size(); - + Rect2 text_rect = _get_text_rect(); int ofs = vscroll->get_value(); //todo, change to binary search @@ -706,9 +714,9 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item Ref<Font> base_font = get_font("normal_font"); Color base_color = get_color("default_color"); - while (y < size.height && from_line < p_frame->lines.size()) { + while (y < text_rect.get_size().height && from_line < p_frame->lines.size()) { - _process_line(p_frame, Point2(), y, size.width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside); + _process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside); if (r_click_item && *r_click_item) return; from_line++; @@ -1015,13 +1023,14 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) { //validate invalid lines!s Size2 size = get_size(); + Rect2 text_rect = _get_text_rect(); Ref<Font> base_font = get_font("normal_font"); for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) { int y = 0; - _process_line(p_frame, Point2(), y, size.width - scroll_w, i, PROCESS_CACHE, base_font, Color()); + _process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, i, PROCESS_CACHE, base_font, Color()); p_frame->lines[i].height_cache = y; p_frame->lines[i].height_accum_cache = y; @@ -1031,7 +1040,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) { int total_height = 0; if (p_frame->lines.size()) - total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache; + total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height; main->first_invalid_line = p_frame->lines.size(); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 74bf180b5d..4db2c3a8e9 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -276,6 +276,8 @@ private: void _gui_input(Ref<InputEvent> p_event); Item *_get_next_item(Item *p_item, bool p_free = false); + Rect2 _get_text_rect(); + bool use_bbcode; String bbcode; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index ade665b418..1738e303aa 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2136,15 +2136,25 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { break; } } - if (auto_indent) { - // indent once again if previous line will end with ':' - // (i.e. colon precedes current cursor position) - if (cursor.column > 0 && text[cursor.line][cursor.column - 1] == ':') { + + bool brace_indent = false; + + // no need to indent if we are going upwards. + if (auto_indent && !(k->get_command() && k->get_shift())) { + // indent once again if previous line will end with ':' or '{' + // (i.e. colon/brace precedes current cursor position) + if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{')) { if (indent_using_spaces) { ins += space_indent; } else { ins += "\t"; } + + // no need to move the brace below if we are not taking the text with us. + if (text[cursor.line][cursor.column] == '}' && !k->get_command()) { + brace_indent = true; + ins += "\n" + ins.substr(1, ins.length() - 2); + } } } @@ -2168,6 +2178,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (first_line) { cursor_set_line(0); + } else if (brace_indent) { + cursor_set_line(cursor.line - 1); + cursor_set_column(text[cursor.line].length()); } } break; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 4ff635edeb..fdea5960e5 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -794,6 +794,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const // RichTextLabel theme->set_stylebox("focus", "RichTextLabel", focus); + theme->set_stylebox("normal", "RichTextLabel", make_stylebox(tree_bg_png, 3, 3, 3, 3)); theme->set_font("normal_font", "RichTextLabel", default_font); theme->set_font("bold_font", "RichTextLabel", default_font); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index f3d790eef5..3d6a10ffc7 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -239,6 +239,7 @@ void SpatialMaterial::init_shaders() { shader_names->anisotropy = "anisotropy_ratio"; shader_names->depth_scale = "depth_scale"; shader_names->subsurface_scattering_strength = "subsurface_scattering_strength"; + shader_names->transmission = "transmission"; shader_names->refraction = "refraction"; shader_names->point_size = "point_size"; shader_names->uv1_scale = "uv1_scale"; @@ -276,6 +277,7 @@ void SpatialMaterial::init_shaders() { shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION] = "texture_ambient_occlusion"; shader_names->texture_names[TEXTURE_DEPTH] = "texture_depth"; shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING] = "texture_subsurface_scattering"; + shader_names->texture_names[TEXTURE_TRANSMISSION] = "texture_transmission"; shader_names->texture_names[TEXTURE_REFRACTION] = "texture_refraction"; shader_names->texture_names[TEXTURE_DETAIL_MASK] = "texture_detail_mask"; shader_names->texture_names[TEXTURE_DETAIL_ALBEDO] = "texture_detail_albedo"; @@ -352,7 +354,7 @@ void SpatialMaterial::_update_shader() { } switch (diffuse_mode) { case DIFFUSE_LAMBERT: code += ",diffuse_lambert"; break; - case DIFFUSE_HALF_LAMBERT: code += ",diffuse_half_lambert"; break; + case DIFFUSE_LAMBERT_WRAP: code += ",diffuse_lambert_wrap"; break; case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break; case DIFFUSE_BURLEY: code += ",diffuse_burley"; break; case DIFFUSE_TOON: code += ",diffuse_toon"; break; @@ -451,6 +453,12 @@ void SpatialMaterial::_update_shader() { code += "uniform sampler2D texture_subsurface_scattering : hint_white;\n"; } + if (features[FEATURE_TRANSMISSION]) { + + code += "uniform vec4 transmission : hint_color;\n"; + code += "uniform sampler2D texture_transmission : hint_black;\n"; + } + if (features[FEATURE_DEPTH_MAPPING]) { code += "uniform sampler2D texture_depth : hint_black;\n"; code += "uniform float depth_scale;\n"; @@ -766,6 +774,15 @@ void SpatialMaterial::_update_shader() { code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n"; } + if (features[FEATURE_TRANSMISSION]) { + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec3 transmission_tex = triplanar_texture(texture_transmission,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; + } else { + code += "\tvec3 transmission_tex = texture(texture_transmission,base_uv).rgb;\n"; + } + code += "\tTRANSMISSION = (transmission.rgb+transmission_tex);\n"; + } + if (features[FEATURE_DETAIL]) { bool triplanar = (flags[FLAG_UV1_USE_TRIPLANAR] && detail_uv == DETAIL_UV_1) || (flags[FLAG_UV2_USE_TRIPLANAR] && detail_uv == DETAIL_UV_2); @@ -1015,6 +1032,17 @@ float SpatialMaterial::get_subsurface_scattering_strength() const { return subsurface_scattering_strength; } +void SpatialMaterial::set_transmission(const Color &p_transmission) { + + transmission = p_transmission; + VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission); +} + +Color SpatialMaterial::get_transmission() const { + + return transmission; +} + void SpatialMaterial::set_refraction(float p_refraction) { refraction = p_refraction; @@ -1180,6 +1208,7 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { _validate_feature("ao", FEATURE_AMBIENT_OCCLUSION, property); _validate_feature("depth", FEATURE_DEPTH_MAPPING, property); _validate_feature("subsurf_scatter", FEATURE_SUBSURACE_SCATTERING, property); + _validate_feature("transmission", FEATURE_TRANSMISSION, property); _validate_feature("refraction", FEATURE_REFRACTION, property); _validate_feature("detail", FEATURE_DETAIL, property); @@ -1530,6 +1559,9 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &SpatialMaterial::set_subsurface_scattering_strength); ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &SpatialMaterial::get_subsurface_scattering_strength); + ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &SpatialMaterial::set_transmission); + ClassDB::bind_method(D_METHOD("get_transmission"), &SpatialMaterial::get_transmission); + ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &SpatialMaterial::set_refraction); ClassDB::bind_method(D_METHOD("get_refraction"), &SpatialMaterial::get_refraction); @@ -1721,6 +1753,11 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING); + ADD_GROUP("Transmission", "transmission_"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transmission_enabled"), "set_feature", "get_feature", FEATURE_TRANSMISSION); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "transmission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_transmission", "get_transmission"); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_TRANSMISSION); + ADD_GROUP("Refraction", "refraction_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION); ADD_PROPERTY(PropertyInfo(Variant::REAL, "refraction_scale", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_refraction", "get_refraction"); @@ -1758,6 +1795,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(TEXTURE_AMBIENT_OCCLUSION); BIND_ENUM_CONSTANT(TEXTURE_DEPTH); BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING); + BIND_ENUM_CONSTANT(TEXTURE_TRANSMISSION); BIND_ENUM_CONSTANT(TEXTURE_REFRACTION); BIND_ENUM_CONSTANT(TEXTURE_DETAIL_MASK); BIND_ENUM_CONSTANT(TEXTURE_DETAIL_ALBEDO); @@ -1776,6 +1814,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(FEATURE_AMBIENT_OCCLUSION); BIND_ENUM_CONSTANT(FEATURE_DEPTH_MAPPING); BIND_ENUM_CONSTANT(FEATURE_SUBSURACE_SCATTERING); + BIND_ENUM_CONSTANT(FEATURE_TRANSMISSION); BIND_ENUM_CONSTANT(FEATURE_REFRACTION); BIND_ENUM_CONSTANT(FEATURE_DETAIL); BIND_ENUM_CONSTANT(FEATURE_MAX); @@ -1809,7 +1848,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT); - BIND_ENUM_CONSTANT(DIFFUSE_HALF_LAMBERT); + BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT_WRAP); BIND_ENUM_CONSTANT(DIFFUSE_OREN_NAYAR); BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); BIND_ENUM_CONSTANT(DIFFUSE_TOON); @@ -1850,6 +1889,7 @@ SpatialMaterial::SpatialMaterial() set_anisotropy(0); set_depth_scale(0.05); set_subsurface_scattering_strength(0); + set_transmission(Color(0, 0, 0)); set_refraction(0.05); set_line_width(1); set_point_size(1); diff --git a/scene/resources/material.h b/scene/resources/material.h index d560d7af55..4e77ab1ed6 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -112,6 +112,7 @@ public: TEXTURE_AMBIENT_OCCLUSION, TEXTURE_DEPTH, TEXTURE_SUBSURFACE_SCATTERING, + TEXTURE_TRANSMISSION, TEXTURE_REFRACTION, TEXTURE_DETAIL_MASK, TEXTURE_DETAIL_ALBEDO, @@ -135,6 +136,7 @@ public: FEATURE_AMBIENT_OCCLUSION, FEATURE_DEPTH_MAPPING, FEATURE_SUBSURACE_SCATTERING, + FEATURE_TRANSMISSION, FEATURE_REFRACTION, FEATURE_DETAIL, FEATURE_MAX @@ -179,7 +181,7 @@ public: enum DiffuseMode { DIFFUSE_LAMBERT, - DIFFUSE_HALF_LAMBERT, + DIFFUSE_LAMBERT_WRAP, DIFFUSE_OREN_NAYAR, DIFFUSE_BURLEY, DIFFUSE_TOON, @@ -212,7 +214,7 @@ private: union MaterialKey { struct { - uint64_t feature_mask : 11; + uint64_t feature_mask : 12; uint64_t detail_uv : 1; uint64_t blend_mode : 2; uint64_t depth_draw_mode : 2; @@ -286,6 +288,7 @@ private: StringName anisotropy; StringName depth_scale; StringName subsurface_scattering_strength; + StringName transmission; StringName refraction; StringName point_size; StringName uv1_scale; @@ -337,6 +340,7 @@ private: float anisotropy; float depth_scale; float subsurface_scattering_strength; + Color transmission; float refraction; float line_width; float point_size; @@ -443,6 +447,9 @@ public: void set_subsurface_scattering_strength(float p_subsurface_scattering_strength); float get_subsurface_scattering_strength() const; + void set_transmission(const Color &p_transmission); + Color get_transmission() const; + void set_refraction(float p_refraction); float get_refraction() const; diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index 4e1ffd2ab3..e1131e7e3e 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -214,7 +214,7 @@ Vector<int> MeshLibrary::get_item_list() const { return ret; } -int MeshLibrary::find_item_name(const String &p_name) const { +int MeshLibrary::find_item_by_name(const String &p_name) const { for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) { @@ -275,6 +275,9 @@ void MeshLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes); ClassDB::bind_method(D_METHOD("get_item_preview", "id"), &MeshLibrary::get_item_preview); ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item); + ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item); + ClassDB::bind_method(D_METHOD("find_item_by_name", "name"), &MeshLibrary::find_item_by_name); + ClassDB::bind_method(D_METHOD("clear"), &MeshLibrary::clear); ClassDB::bind_method(D_METHOD("get_item_list"), &MeshLibrary::get_item_list); ClassDB::bind_method(D_METHOD("get_last_unused_item_id"), &MeshLibrary::get_last_unused_item_id); diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h index 99b6b48d61..c5d23ce50f 100644 --- a/scene/resources/mesh_library.h +++ b/scene/resources/mesh_library.h @@ -84,7 +84,7 @@ public: void clear(); - int find_item_name(const String &p_name) const; + int find_item_by_name(const String &p_name) const; Vector<int> get_item_list() const; int get_last_unused_item_id() const; diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp index ab716a8f6e..3af8b542fa 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics/collision_object_sw.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_object_sw.h" +#include "servers/physics/physics_server_sw.h" #include "space_sw.h" void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform) { @@ -39,8 +40,12 @@ void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform s.bpid = 0; //needs update shapes.push_back(s); p_shape->add_owner(this); - _update_shapes(); - _shapes_changed(); + + if (!pending_shape_update_list.in_list()) { + PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + } + //_update_shapes(); + //_shapes_changed(); } void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) { @@ -50,8 +55,11 @@ void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) { shapes[p_index].shape = p_shape; p_shape->add_owner(this); - _update_shapes(); - _shapes_changed(); + if (!pending_shape_update_list.in_list()) { + PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + } + //_update_shapes(); + //_shapes_changed(); } void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_transform) { @@ -59,8 +67,11 @@ void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_tran shapes[p_index].xform = p_transform; shapes[p_index].xform_inv = p_transform.affine_inverse(); - _update_shapes(); - _shapes_changed(); + if (!pending_shape_update_list.in_list()) { + PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + } + //_update_shapes(); + //_shapes_changed(); } void CollisionObjectSW::remove_shape(ShapeSW *p_shape) { @@ -90,7 +101,11 @@ void CollisionObjectSW::remove_shape(int p_index) { shapes[p_index].shape->remove_owner(this); shapes.remove(p_index); - _shapes_changed(); + if (!pending_shape_update_list.in_list()) { + PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + } + //_update_shapes(); + //_shapes_changed(); } void CollisionObjectSW::_set_static(bool p_static) { @@ -202,7 +217,8 @@ void CollisionObjectSW::_shape_changed() { _shapes_changed(); } -CollisionObjectSW::CollisionObjectSW(Type p_type) { +CollisionObjectSW::CollisionObjectSW(Type p_type) + : pending_shape_update_list(this) { _static = true; type = p_type; diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index dc988aae86..67a8a44944 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -75,6 +75,8 @@ private: Transform inv_transform; bool _static; + SelfList<CollisionObjectSW> pending_shape_update_list; + void _update_shapes(); protected: diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 8d6f7b3fd8..2d46770924 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -763,6 +763,8 @@ void PhysicsServerSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); + _update_shapes(); + body->apply_impulse(p_pos, p_impulse); body->wakeup(); }; @@ -772,6 +774,8 @@ void PhysicsServerSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_imp BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); + _update_shapes(); + body->apply_torque_impulse(p_impulse); body->wakeup(); }; @@ -781,6 +785,8 @@ void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_v BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); + _update_shapes(); + Vector3 v = body->get_linear_velocity(); Vector3 axis = p_axis_velocity.normalized(); v -= axis * axis.dot(v); @@ -793,6 +799,7 @@ void PhysicsServerSW::body_set_axis_lock(RID p_body, BodyAxisLock p_lock) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); + body->set_axis_lock(p_lock); body->wakeup(); } @@ -902,6 +909,8 @@ bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, cons ERR_FAIL_COND_V(!body->get_space(), false); ERR_FAIL_COND_V(body->get_space()->is_locked(), false); + _update_shapes(); + return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result); } @@ -1209,6 +1218,8 @@ bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_a void PhysicsServerSW::free(RID p_rid) { + _update_shapes(); //just in case + if (shape_owner.owns(p_rid)) { ShapeSW *shape = shape_owner.get(p_rid); @@ -1312,6 +1323,8 @@ void PhysicsServerSW::step(real_t p_step) { if (!active) return; + _update_shapes(); + doing_sync = false; last_step = p_step; @@ -1409,6 +1422,14 @@ int PhysicsServerSW::get_process_info(ProcessInfo p_info) { return 0; } +void PhysicsServerSW::_update_shapes() { + + while (pending_shape_update_list.first()) { + pending_shape_update_list.first()->self()->_shape_changed(); + pending_shape_update_list.remove(pending_shape_update_list.first()); + } +} + void PhysicsServerSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) { CollCbkData *cbk = (CollCbkData *)p_userdata; diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h index 2e1fa7065a..99ba302acd 100644 --- a/servers/physics/physics_server_sw.h +++ b/servers/physics/physics_server_sw.h @@ -62,6 +62,10 @@ class PhysicsServerSW : public PhysicsServer { mutable RID_Owner<JointSW> joint_owner; //void _clear_query(QuerySW *p_query); + friend class CollisionObjectSW; + SelfList<CollisionObjectSW>::List pending_shape_update_list; + void _update_shapes(); + public: static PhysicsServerSW *singleton; diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index ef0d063f83..91c5d430f5 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -102,6 +102,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; @@ -137,7 +138,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].modes.insert("unshaded"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert_wrap"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_oren_nayar"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_burley"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_toon"); |