diff options
372 files changed, 13476 insertions, 11368 deletions
@@ -40,6 +40,7 @@ Gilles Roudiere <gilles.roudiere@gmail.com> <gilles.roudiere@laas.fr> Gordon MacPherson <gordon@gordonite.tech> Guilherme Felipe <guilhermefelipecgs@gmail.com> Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com> +HaSa1002 <johawitt@outlook.de> Hein-Pieter van Braam-Stewart <hp@tmm.cx> Hubert Jarosz <marqin.pl@gmail.com> Hubert Jarosz <marqin.pl@gmail.com> <marqin.pl+git@gmail.com> diff --git a/AUTHORS.md b/AUTHORS.md index 2faaf2d2c0..8c26d2892b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -163,6 +163,7 @@ name is available. Ray Koopa (RayKoopa) Rémi Verschelde (akien-mga) Rhody Lugo (rraallvv) + Ricardo Subtil (Ev1lbl0w) Roberto F. Arroyo (robfram) Robin Hübner (profan) romulox-x diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4387750f28..d7a4f976bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -241,25 +241,21 @@ discussions and support, others more for development discussions. To communicate with developers (e.g. to discuss a feature you want to implement or a bug you want to fix), the following channels can be used: -- [GitHub issues](https://github.com/godotengine/godot/issues): If there is an - existing issue about a topic you want to discuss, just add a comment to it - - all developers watch the repository and will get an email notification. You - can also create a new issue - please keep in mind to create issues only to - discuss quite specific points about the development, and not general user - feedback or support requests. -- [#godotengine-devel IRC channel on - Freenode](https://webchat.freenode.net/?channels=godotengine-devel): You will - find most core developers there, so it's the go-to channel for direct chat +- [Godot Contributors Chat](https://chat.godotengine.org): You will + find most core developers there, so it's the go-to platform for direct chat about Godot Engine development. Feel free to start discussing something there to get some early feedback before writing up a detailed proposal in a GitHub issue. -- [devel@godotengine.org mailing - list](https://listengine.tuxfamily.org/godotengine.org/devel/): Mailing list - for Godot developers, used primarily to announce developer meetings on IRC - and other important discussions that need to reach people directly in their - mailbox. See the [index - page](https://listengine.tuxfamily.org/godotengine.org/devel/) for - subscription instructions. +- [Bug tracker](https://github.com/godotengine/godot/issues): If there is an + existing issue about a topic you want to discuss, just add a comment to it - + many developers watch the repository and will get a notification. You can + also create a new issue - please keep in mind to create issues only to + discuss quite specific points about the development, and not general user + feedback or support requests. +- [Feature proposals](https://github.com/godotengine/godot-proposals/issues): + To propose a new feature, we have a dedicated issue tracker for that. Don't + hesitate to start by talking about your idea on the Godot Contributors Chat + to make sure that it makes sense in Godot's context. Thanks for your interest in contributing! @@ -32,6 +32,7 @@ generous deed immortalized in the next stable release of Godot Engine. Garry Newman Gordon MacPherson Hunter Dickson + Kyle Szklenski ## Mini sponsors @@ -39,6 +40,8 @@ generous deed immortalized in the next stable release of Godot Engine. Alejandro Saucedo alex brown Andrew Dunai + Ben Nolan + blurp CD Christian Baune Christoffer Sundbom @@ -58,6 +61,7 @@ generous deed immortalized in the next stable release of Godot Engine. John G Gentzel Jonah Stich Justin Arnold + Kamil Brzezinski Marcel Kräml Matthieu Huvé Maxim Karsten @@ -67,6 +71,7 @@ generous deed immortalized in the next stable release of Godot Engine. Patrick Horn Patrick Schmidt Péter Magyar + Rami Ronnie Cheng Slobodan Milnovic Stephan Lanfermann @@ -75,6 +80,7 @@ generous deed immortalized in the next stable release of Godot Engine. Tristan Pemble VilliHaukka Violin Iliev + Xwdit ## Gold donors @@ -82,7 +88,7 @@ generous deed immortalized in the next stable release of Godot Engine. albinaask Alvaro A Baena R Asher Glick - Bernhard Werner + Barugon Carlo Cabanilla Chris Goddard Christopher Case @@ -96,11 +102,9 @@ generous deed immortalized in the next stable release of Godot Engine. Florian Rämisch Forge Gamejunkey - Grady Hoojib Jakub Grzesik Javier Roman - Jeff Nyte Joan Fons Johnny IV Young Jon Woodward @@ -115,13 +119,9 @@ generous deed immortalized in the next stable release of Godot Engine. Matthew Hillier Michael m kaersten - Mohamed Ikbel Boulabiar Monster Vial Officine Pixel S.n.c. - Pixel Booty - Rami Rene - Rene Tailleur Retro Village Rob Messick Roland Fredenhagen @@ -142,7 +142,6 @@ generous deed immortalized in the next stable release of Godot Engine. Xeno Coliseum Zaven Muradyan - Aaron Winter Adam Nakonieczny Adrian Adamiak Aleksey Korotkevich @@ -154,14 +153,12 @@ generous deed immortalized in the next stable release of Godot Engine. Andreas Funke André Frélicot Andrew Cunningham - Anm Antanas Paskauskas Antoni Batchelli Arisaka Mayuki Arthur S. Muszynski - Aubin Detrez - Barugon Ben Botwin + Brandon Hawkinson Caleb Sizemore Can Eris Charlie Whitfield @@ -170,8 +167,6 @@ generous deed immortalized in the next stable release of Godot Engine. Chris Petrich Chris Serino Christian Leth Jeppesen - Cody Brooks - Conrad Curry Craig Ostrin Craig Smith Cristopher @@ -191,15 +186,13 @@ generous deed immortalized in the next stable release of Godot Engine. Gabrielius Vaiškūnas Gary Hulst gavlig + General Chicken GGGames.org - GiulianoB - Green Fox Guilherme Felipe de C. G. da Silva Harvey Fong Heath Hayes Horváth Péter Hu Hund - Idilio Alfaro Jake Burga James Couzens Jared @@ -209,6 +202,7 @@ generous deed immortalized in the next stable release of Godot Engine. Joel Höglund Johnathan Kupferer Jose Malheiro + Jose Manuel Muñoz Perez Joseph Crane Joshie Sparks Joshua Flores @@ -223,9 +217,11 @@ generous deed immortalized in the next stable release of Godot Engine. kickmaniac kinfox Kos + kuku Lachie Lain Ballard Laszlo Kiss + leetNightshade Leo Fidel R Liban Liam Smyth Luc-Frédéric Langis @@ -234,10 +230,8 @@ generous deed immortalized in the next stable release of Godot Engine. Marcelo Dornbusch Lopes Marcus Dobler Marcus Richter - Marisa Clardy + Marek Belski Mark Barrett - Mark Diaz - Markus Fehr Martin Eigel Martin Kotz Martin Soucek @@ -249,16 +243,17 @@ generous deed immortalized in the next stable release of Godot Engine. Michael Dürwald Michael Noll Michael Policastro + MightyPossum MikadoSC MuffinManKen Nick Abousselam Nick Barovic Oliver Dick Oscar Campos - Patrick Brock Patrick Ting Paul Hocker Paul Von Zimmerman + Pavel Kotlyar Pedro Silva Pete Goodwin Petr Malac @@ -266,6 +261,7 @@ generous deed immortalized in the next stable release of Godot Engine. pl Raymond Harris Raz A + Rene Tailleur Ricardo Alcantara Robert Larnach Robert Willes @@ -277,11 +273,11 @@ generous deed immortalized in the next stable release of Godot Engine. Ryan Scott Ryszard Sommefeldt Samuel Judd - Scott Pilet Sean Morgan Sebastian Hutter Sébastien Serban Serafimescu + Sergey Fonaryov Sergey Minakov Shishir Tandale SKison @@ -290,12 +286,11 @@ generous deed immortalized in the next stable release of Godot Engine. Stephan Hennion Steven Landow Stoned Xander - TheLevelOfDetail Thomas Bjarnelöf Thomas Kurz Tim Howard - tinyBigGAMES LLC Tobias Bocanegra + Todd Smith Turntsnaco tweaklab Valryia @@ -303,7 +298,6 @@ generous deed immortalized in the next stable release of Godot Engine. Vlad Ceru Opran VoidPointer voxelv - William Foster Wojciech Chojnacki xzibiting Yuancheng Zhang @@ -341,9 +335,9 @@ generous deed immortalized in the next stable release of Godot Engine. Alexander Walter (SilvanuZ) Alexandre Beaudoin alex clavelle + Alex Schmidt Allan Davis Allen Schade - Ancient Phoenix Anders Marstein Kruke Andreas Krampitz Andre Stackhouse @@ -352,11 +346,11 @@ generous deed immortalized in the next stable release of Godot Engine. Andrew Thomas Ano Nim Anthony Avina + Anton Bouwer aomimezura11 AP Condomines Arch Toasty Arda Erol - Aria Armin Preiml Arseniy M Ashley Claymore @@ -365,10 +359,10 @@ generous deed immortalized in the next stable release of Godot Engine. AzulCrescent Balázs Batári Bartosz Bielecki - Bekhoucha Danyl Benedikt Ben Vercammen Bernd Jänichen + Bernhard Werner Bjarne Voigtländer Black Block blackjacksike @@ -383,6 +377,7 @@ generous deed immortalized in the next stable release of Godot Engine. Bronson Zgeb Bùi Việt Thành Burney Waring + bwhirt Caleb Gartner Cameron Meyer Carlos Cejudo @@ -401,8 +396,8 @@ generous deed immortalized in the next stable release of Godot Engine. Christian Winter Christoffer Dahlblom Christophe Gagnier + Christopher Chin Christopher Schmitt - Christoph Woinke Chris Truebe Clay Heaton Cody Parker @@ -422,6 +417,7 @@ generous deed immortalized in the next stable release of Godot Engine. Dmitry Fisher Dmytro Korchynskyi Dominik Wetzel + Douglas Plumley Dragontrapper Dr Ewan Murray Dr.Raccoon @@ -435,11 +431,10 @@ generous deed immortalized in the next stable release of Godot Engine. Elgenzay Elias Nykrem Ephemeral - Eric Ellingson + Eric Walkingshaw Eric Williams Erkki Seppälä Evan Rose - Fain Faisal Alkubaisi Fancy Ants Studios Fekinox @@ -449,15 +444,15 @@ generous deed immortalized in the next stable release of Godot Engine. Francois Holland Frank FuDiggity - Gadzhi Kharkharov gamedev by Celio Game Endeavor + Gareth Knowles Gary Thomas George Marques - Gerard Ruiz Torruella + georgios katsanakis + GFizz Greg Lincoln Greg Olson - GREGORY C FEIN Greyson Richey Grid Guillaume Audirac @@ -467,7 +462,6 @@ generous deed immortalized in the next stable release of Godot Engine. Hal A helija Heribert Hirth - Hieu Thanh Hunter Jones Ian Williams Iiari @@ -484,10 +478,9 @@ generous deed immortalized in the next stable release of Godot Engine. James James A F Manley James Thomas - Jamiee H Jamie Massey + Jan Vetulani JARKKO PARVIAINEN - Jasiek Vetulani Jason Uechi Jean-Baptiste LEPESME Jeff Hungerford @@ -496,6 +489,7 @@ generous deed immortalized in the next stable release of Godot Engine. Jhon Adams Joe Klemmer John Gabriel + Jonah Branch Jonas Jonas Bernemann Jonas Rudlang @@ -507,21 +501,23 @@ generous deed immortalized in the next stable release of Godot Engine. Jon Sully Jordy Goodridge Jorge Antunes - Jorge Javier Araya Navarro + Jorge Araya Navarro Jose C. Rubio Joseph Catrambone Josh Taylor Josue David + jromkjrom Juanfran + Juan Uys Jueast Julian Murgia June Little Justin Hamilton Justin Oaksford Justin Spedding + Justin W. Flory KaDokta Kalin - Kauzig Keedong Park Keinan Powers Keith Bradner @@ -539,8 +535,8 @@ generous deed immortalized in the next stable release of Godot Engine. KsyTek Games kycho Kyle Jacobs - Kyle Szklenski Kyuppin + Lasse le Dous Laurent CHEA Laurent Tréguier Laxman Pradhan @@ -558,19 +554,16 @@ generous deed immortalized in the next stable release of Godot Engine. Malcolm Marco Lardelli Mark Jad - Mark Krenz Mark Malone Markus Martin Markus Michael Egger Martin FIbik Martin Holas - Martin Linklater Martin Trbola Marvin Mathieu Matt Edwards Matthew Booe - Max Brister Max Fiedler Maxime Blade Maxwell @@ -582,13 +575,13 @@ generous deed immortalized in the next stable release of Godot Engine. Michael Bruce-Lockhart Michael Haney Michał Skwarek + MidoriBunn 'tis BS Mikayla Mike Birkhead Mike Cunningham Mitchell J. Wagner Molinghu Molly Jameson - MoM MrAZIE Nathan Fish Nathaniel @@ -612,30 +605,31 @@ generous deed immortalized in the next stable release of Godot Engine. OKV Oleg Reva Oleksandr Kryvonos - Olivier Omar Delarosa + Oriol Muñoz Princep Oscar Domingo Parinya Teerakasemsuk patricio lara briones + Patrick Brock Patrick Dully Patrick Nafarrete Paul Gieske - Paul Mason Paweł Kowal Paweł Łyczkowski Peter Höglund + Peter Richmond Petrus Prinsloo Philip Cohoe - Phillip Zolla + Pierre Caye Piotr Góral Pipo Point08 Preethi Vaidyanathan pwab - pyacier Rad Cat Rafa Laguna Raffaele Aramo + Rami Hanano RAMupgrade Remi Rampin Rémi Verschelde @@ -652,6 +646,7 @@ generous deed immortalized in the next stable release of Godot Engine. Ronan Ross Squires Ryan Groom + Sam Caulfield Sam Edson Samuele Zolfanelli scapegoat57 @@ -659,8 +654,9 @@ generous deed immortalized in the next stable release of Godot Engine. Scott Longley Sean Lynch Sebastian Michailidis - Sebastian Vetter SeongWan Kim + Serenitor + Sergey Sergiy Onenko Shane Shane Sicienski @@ -683,6 +679,7 @@ generous deed immortalized in the next stable release of Godot Engine. tannhauser_gate Tarch Terry + The Liquidator Theodore Lindsey TheVoiceInMyHead thomas @@ -693,8 +690,8 @@ generous deed immortalized in the next stable release of Godot Engine. Tim Erskine Tim Gleason Timothy B. MacDonald - Tobbun Tobias Bradtke + Tom Coxon Toni Duran Tony Zhao Torgeir Lilleskog @@ -712,11 +709,11 @@ generous deed immortalized in the next stable release of Godot Engine. Uther Vaughan Ling Victor - Vigilant Watch Viktor Ismagilov + Vi Watch Vladimir Savin Vladislav Smirnov - Výrus Hemomancer + Vytenis Narušis waka nya Wayne Haak werner mendizabal @@ -725,13 +722,12 @@ generous deed immortalized in the next stable release of Godot Engine. William F Siqueira William Hogben Wyatt Goodin - Xaver Fischer + x1212 xenomat Yegor Smirnov Zack Yang Zak Stephens 蕭惟允 - 郝晨煜 ## Bronze donors @@ -50,8 +50,7 @@ Godot is not only an engine but an ever-growing community of users and engine developers. The main community channels are listed [on the homepage](https://godotengine.org/community). To get in touch with the engine developers, the best way is to join the -[#godotengine-devel IRC channel](https://webchat.freenode.net/?channels=godotengine-devel) -on Freenode. +[Godot Contributors Chat](https://chat.godotengine.org). To get started contributing to the project, see the [contributing guide](CONTRIBUTING.md). diff --git a/SConstruct b/SConstruct index f03fb72ff3..b006dddbe6 100644 --- a/SConstruct +++ b/SConstruct @@ -61,11 +61,15 @@ elif platform_arg == "javascript": # Use generic POSIX build toolchain for Emscripten. custom_tools = ["cc", "c++", "ar", "link", "textfile", "zip"] +# We let SCons build its default ENV as it includes OS-specific things which we don't +# want to have to pull in manually. +# Then we prepend PATH to make it take precedence, while preserving SCons' own entries. env_base = Environment(tools=custom_tools) -if "TERM" in os.environ: +env_base.PrependENVPath("PATH", os.getenv("PATH")) +env_base.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) +if "TERM" in os.environ: # Used for colored output. env_base["ENV"]["TERM"] = os.environ["TERM"] -env_base.AppendENVPath("PATH", os.getenv("PATH")) -env_base.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) + env_base.disabled_modules = [] env_base.module_version_string = "" env_base.msvc = False diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index c872ae2162..02effc2001 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -909,7 +909,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust custom_features += f; } - if (p_path.ends_with(".godot")) { + if (p_path.ends_with(".godot") || p_path.ends_with("override.cfg")) { return _save_settings_text(p_path, props, p_custom, custom_features); } else if (p_path.ends_with(".binary")) { return _save_settings_binary(p_path, props, p_custom, custom_features); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 47c75cfa28..e7a77384da 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -566,7 +566,7 @@ struct _OSCoreBindImg { void _OS::print_all_textures_by_size() { List<_OSCoreBindImg> imgs; - int total = 0; + uint64_t total = 0; { List<Ref<Resource>> rsrc; ResourceCache::get_cached_resources(&rsrc); diff --git a/core/core_constants.cpp b/core/core_constants.cpp index f9edff1899..a99df93638 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -521,8 +521,10 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_2D_RENDER); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_2D_PHYSICS); + BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_2D_NAVIGATION); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_3D_RENDER); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_3D_PHYSICS); + BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_3D_NAVIGATION); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_FILE); BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_DIR); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 7392e6b9a6..bdbb7766fa 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -76,6 +76,7 @@ public: NetworkProfiler() {} int bandwidth_usage(const Vector<BandwidthFrame> &p_buffer, int p_pointer) { + ERR_FAIL_COND_V(p_buffer.size() == 0, 0); int total_bandwidth = 0; uint32_t timestamp = OS::get_singleton()->get_ticks_msec(); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 18afdc678e..3863dce0f6 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -96,6 +96,11 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) { ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object."); + if (ssl) { + ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerSSL>(p_connection.ptr()), + "Connection is not a reference to a valid StreamPeerSSL object."); + } + if (connection == p_connection) { return; } diff --git a/core/io/json.cpp b/core/io/json.cpp index bc4527869b..0d9117fdda 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -234,6 +234,52 @@ Error JSON::_get_token(const char32_t *p_str, int &index, int p_len, Token &r_to } index += 4; //will add at the end anyway + if ((res & 0xfffffc00) == 0xd800) { + if (p_str[index + 1] != '\\' || p_str[index + 2] != 'u') { + r_err_str = "Invalid UTF-16 sequence in string, unpaired lead surrogate"; + return ERR_PARSE_ERROR; + } + index += 2; + char32_t trail = 0; + for (int j = 0; j < 4; j++) { + char32_t c = p_str[index + j + 1]; + if (c == 0) { + r_err_str = "Unterminated String"; + return ERR_PARSE_ERROR; + } + if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) { + r_err_str = "Malformed hex constant in string"; + return ERR_PARSE_ERROR; + } + char32_t v; + if (c >= '0' && c <= '9') { + v = c - '0'; + } else if (c >= 'a' && c <= 'f') { + v = c - 'a'; + v += 10; + } else if (c >= 'A' && c <= 'F') { + v = c - 'A'; + v += 10; + } else { + ERR_PRINT("Bug parsing hex constant."); + v = 0; + } + + trail <<= 4; + trail |= v; + } + if ((trail & 0xfffffc00) == 0xdc00) { + res = (res << 10UL) + trail - ((0xd800 << 10UL) + 0xdc00 - 0x10000); + index += 4; //will add at the end anyway + } else { + r_err_str = "Invalid UTF-16 sequence in string, unpaired lead surrogate"; + return ERR_PARSE_ERROR; + } + } else if ((res & 0xfffffc00) == 0xdc00) { + r_err_str = "Invalid UTF-16 sequence in string, unpaired trail surrogate"; + return ERR_PARSE_ERROR; + } + } break; default: { res = next; diff --git a/core/io/logger.cpp b/core/io/logger.cpp index bd0285a7a9..8a07459a1d 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -43,6 +43,12 @@ bool Logger::should_log(bool p_err) { return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled); } +bool Logger::_flush_stdout_on_print = true; + +void Logger::set_flush_stdout_on_print(bool value) { + _flush_stdout_on_print = value; +} + void Logger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) { if (!should_log(true)) { return; @@ -207,7 +213,7 @@ void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) { Memory::free_static(buf); } - if (p_err || !ProjectSettings::get_singleton() || GLOBAL_GET("application/run/flush_stdout_on_print")) { + if (p_err || _flush_stdout_on_print) { // Don't always flush when printing stdout to avoid performance // issues when `print()` is spammed in release builds. file->flush(); @@ -228,7 +234,7 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) { vfprintf(stderr, p_format, p_list); } else { vprintf(p_format, p_list); - if (!ProjectSettings::get_singleton() || GLOBAL_GET("application/run/flush_stdout_on_print")) { + if (_flush_stdout_on_print) { // Don't always flush when printing stdout to avoid performance // issues when `print()` is spammed in release builds. fflush(stdout); diff --git a/core/io/logger.h b/core/io/logger.h index b8e615b436..a12945911c 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -41,6 +41,8 @@ class Logger { protected: bool should_log(bool p_err); + static bool _flush_stdout_on_print; + public: enum ErrorType { ERR_ERROR, @@ -49,6 +51,8 @@ public: ERR_SHADER }; + static void set_flush_stdout_on_print(bool value); + virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0 = 0; virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR); diff --git a/core/math/color.cpp b/core/math/color.cpp index e1b45cac9c..8affb07e8c 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -452,56 +452,9 @@ String Color::to_html(bool p_alpha) const { } Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const { - p_h = Math::fmod(p_h * 360.0f, 360.0f); - if (p_h < 0.0) { - p_h += 360.0f; - } - - const float h_ = p_h / 60.0f; - const float c = p_v * p_s; - const float x = c * (1.0f - Math::abs(Math::fmod(h_, 2.0f) - 1.0f)); - float r, g, b; - - switch ((int)h_) { - case 0: { - r = c; - g = x; - b = 0; - } break; - case 1: { - r = x; - g = c; - b = 0; - } break; - case 2: { - r = 0; - g = c; - b = x; - } break; - case 3: { - r = 0; - g = x; - b = c; - } break; - case 4: { - r = x; - g = 0; - b = c; - } break; - case 5: { - r = c; - g = 0; - b = x; - } break; - default: { - r = 0; - g = 0; - b = 0; - } break; - } - - const float m = p_v - c; - return Color(m + r, m + g, m + b, p_a); + Color c; + c.set_hsv(p_h, p_s, p_v, p_a); + return c; } Color::operator String() const { diff --git a/core/object/object.h b/core/object/object.h index 029478873d..448a33d3bc 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -66,8 +66,10 @@ enum PropertyHint { PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags) PROPERTY_HINT_LAYERS_2D_RENDER, PROPERTY_HINT_LAYERS_2D_PHYSICS, + PROPERTY_HINT_LAYERS_2D_NAVIGATION, PROPERTY_HINT_LAYERS_3D_RENDER, PROPERTY_HINT_LAYERS_3D_PHYSICS, + PROPERTY_HINT_LAYERS_3D_NAVIGATION, PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," PROPERTY_HINT_DIR, ///< a directory path must be passed PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," diff --git a/core/os/thread.cpp b/core/os/thread.cpp index aea370787d..73e31bdb3d 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -41,9 +41,13 @@ void (*Thread::set_priority_func)(Thread::Priority) = nullptr; void (*Thread::init_func)() = nullptr; void (*Thread::term_func)() = nullptr; -Thread::ID Thread::main_thread_id = 1; -SafeNumeric<Thread::ID> Thread::last_thread_id{ 1 }; -thread_local Thread::ID Thread::caller_id = 1; +uint64_t Thread::_thread_id_hash(const std::thread::id &p_t) { + static std::hash<std::thread::id> hasher; + return hasher(p_t); +} + +Thread::ID Thread::main_thread_id = _thread_id_hash(std::this_thread::get_id()); +thread_local Thread::ID Thread::caller_id = 0; void Thread::_set_platform_funcs( Error (*p_set_name_func)(const String &), @@ -57,7 +61,7 @@ void Thread::_set_platform_funcs( } void Thread::callback(Thread *p_self, const Settings &p_settings, Callback p_callback, void *p_userdata) { - Thread::caller_id = p_self->id; + Thread::caller_id = _thread_id_hash(p_self->thread.get_id()); if (set_priority_func) { set_priority_func(p_settings.priority); } @@ -73,7 +77,7 @@ void Thread::callback(Thread *p_self, const Settings &p_settings, Callback p_cal } void Thread::start(Thread::Callback p_callback, void *p_user, const Settings &p_settings) { - if (id != 0) { + if (id != _thread_id_hash(std::thread::id())) { #ifdef DEBUG_ENABLED WARN_PRINT("A Thread object has been re-started without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread."); #endif @@ -81,22 +85,22 @@ void Thread::start(Thread::Callback p_callback, void *p_user, const Settings &p_ std::thread empty_thread; thread.swap(empty_thread); } - id = last_thread_id.increment(); std::thread new_thread(&Thread::callback, this, p_settings, p_callback, p_user); thread.swap(new_thread); + id = _thread_id_hash(thread.get_id()); } bool Thread::is_started() const { - return id != 0; + return id != _thread_id_hash(std::thread::id()); } void Thread::wait_to_finish() { - if (id != 0) { + if (id != _thread_id_hash(std::thread::id())) { ERR_FAIL_COND_MSG(id == get_caller_id(), "A Thread can't wait for itself to finish."); thread.join(); std::thread empty_thread; thread.swap(empty_thread); - id = 0; + id = _thread_id_hash(std::thread::id()); } } @@ -108,8 +112,12 @@ Error Thread::set_name(const String &p_name) { return ERR_UNAVAILABLE; } +Thread::Thread() { + caller_id = _thread_id_hash(std::this_thread::get_id()); +} + Thread::~Thread() { - if (id != 0) { + if (id != _thread_id_hash(std::thread::id())) { #ifdef DEBUG_ENABLED WARN_PRINT("A Thread object has been destroyed without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread."); #endif diff --git a/core/os/thread.h b/core/os/thread.h index 76f5be182e..17ac82c650 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -62,9 +62,10 @@ private: friend class Main; static ID main_thread_id; - static SafeNumeric<Thread::ID> last_thread_id; - ID id = 0; + static uint64_t _thread_id_hash(const std::thread::id &p_t); + + ID id = _thread_id_hash(std::thread::id()); static thread_local ID caller_id; std::thread thread; @@ -97,6 +98,7 @@ public: ///< waits until thread is finished, and deallocates it. void wait_to_finish(); + Thread(); ~Thread(); #else _FORCE_INLINE_ ID get_id() const { return 0; } diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index a57c7b2504..9f931ef30b 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4394,6 +4394,18 @@ String String::property_name_encode() const { return *this; } +// Changes made to the set of invalid characters must also be reflected in the String documentation. +const String String::invalid_node_name_characters = ". : @ / \""; + +String String::validate_node_name() const { + Vector<String> chars = String::invalid_node_name_characters.split(" "); + String name = this->replace(chars[0], ""); + for (int i = 1; i < chars.size(); i++) { + name = name.replace(chars[i], ""); + } + return name; +} + String String::get_basename() const { int pos = rfind("."); if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) { diff --git a/core/string/ustring.h b/core/string/ustring.h index 821941036f..1e362d7683 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -419,6 +419,10 @@ public: String property_name_encode() const; + // node functions + static const String invalid_node_name_characters; + String validate_node_name() const; + bool is_valid_identifier() const; bool is_valid_integer() const; bool is_valid_float() const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 54ca1a911d..90272ad5b4 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -956,6 +956,8 @@ static void _register_variant_builtin_methods() { bind_method(String, c_unescape, sarray(), varray()); bind_method(String, json_escape, sarray(), varray()); + bind_method(String, validate_node_name, sarray(), varray()); + bind_method(String, is_valid_identifier, sarray(), varray()); bind_method(String, is_valid_integer, sarray(), varray()); bind_method(String, is_valid_float, sarray(), varray()); diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp index 52f9f6060e..f0c9e52b46 100644 --- a/core/variant/variant_construct.cpp +++ b/core/variant/variant_construct.cpp @@ -773,6 +773,7 @@ void Variant::_unregister_variant_constructors() { } void Variant::construct(Variant::Type p_type, Variant &base, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { + ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); uint32_t s = construct_data[p_type].size(); for (uint32_t i = 0; i < s; i++) { int argc = construct_data[p_type][i].argument_count; diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 3ca7e0716b..d57d241b53 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1280,6 +1280,10 @@ <constant name="HORIZONTAL" value="0" enum="Orientation"> General horizontal alignment, usually used for [Separator], [ScrollBar], [Slider], etc. </constant> + <constant name="CLOCKWISE" value="0" enum="ClockDirection"> + </constant> + <constant name="COUNTERCLOCKWISE" value="1" enum="ClockDirection"> + </constant> <constant name="HALIGN_LEFT" value="0" enum="HAlign"> Horizontal left alignment, usually for text-derived classes. </constant> @@ -2405,43 +2409,49 @@ <constant name="PROPERTY_HINT_LAYERS_2D_PHYSICS" value="9" enum="PropertyHint"> Hints that an integer property is a bitmask using the optionally named 2D physics layers. </constant> - <constant name="PROPERTY_HINT_LAYERS_3D_RENDER" value="10" enum="PropertyHint"> + <constant name="PROPERTY_HINT_LAYERS_2D_NAVIGATION" value="10" enum="PropertyHint"> + Hints that an integer property is a bitmask using the optionally named 2D navigation layers. + </constant> + <constant name="PROPERTY_HINT_LAYERS_3D_RENDER" value="11" enum="PropertyHint"> Hints that an integer property is a bitmask using the optionally named 3D render layers. </constant> - <constant name="PROPERTY_HINT_LAYERS_3D_PHYSICS" value="11" enum="PropertyHint"> + <constant name="PROPERTY_HINT_LAYERS_3D_PHYSICS" value="12" enum="PropertyHint"> Hints that an integer property is a bitmask using the optionally named 3D physics layers. </constant> - <constant name="PROPERTY_HINT_FILE" value="12" enum="PropertyHint"> + <constant name="PROPERTY_HINT_LAYERS_3D_NAVIGATION" value="13" enum="PropertyHint"> + Hints that an integer property is a bitmask using the optionally named 2D navigation layers. + </constant> + <constant name="PROPERTY_HINT_FILE" value="14" enum="PropertyHint"> Hints that a string property is a path to a file. Editing it will show a file dialog for picking the path. The hint string can be a set of filters with wildcards like [code]"*.png,*.jpg"[/code]. </constant> - <constant name="PROPERTY_HINT_DIR" value="13" enum="PropertyHint"> + <constant name="PROPERTY_HINT_DIR" value="15" enum="PropertyHint"> Hints that a string property is a path to a directory. Editing it will show a file dialog for picking the path. </constant> - <constant name="PROPERTY_HINT_GLOBAL_FILE" value="14" enum="PropertyHint"> + <constant name="PROPERTY_HINT_GLOBAL_FILE" value="16" enum="PropertyHint"> Hints that a string property is an absolute path to a file outside the project folder. Editing it will show a file dialog for picking the path. The hint string can be a set of filters with wildcards like [code]"*.png,*.jpg"[/code]. </constant> - <constant name="PROPERTY_HINT_GLOBAL_DIR" value="15" enum="PropertyHint"> + <constant name="PROPERTY_HINT_GLOBAL_DIR" value="17" enum="PropertyHint"> Hints that a string property is an absolute path to a directory outside the project folder. Editing it will show a file dialog for picking the path. </constant> - <constant name="PROPERTY_HINT_RESOURCE_TYPE" value="16" enum="PropertyHint"> + <constant name="PROPERTY_HINT_RESOURCE_TYPE" value="18" enum="PropertyHint"> Hints that a property is an instance of a [Resource]-derived type, optionally specified via the hint string (e.g. [code]"Texture2D"[/code]). Editing it will show a popup menu of valid resource types to instantiate. </constant> - <constant name="PROPERTY_HINT_MULTILINE_TEXT" value="17" enum="PropertyHint"> + <constant name="PROPERTY_HINT_MULTILINE_TEXT" value="19" enum="PropertyHint"> Hints that a string property is text with line breaks. Editing it will show a text input field where line breaks can be typed. </constant> - <constant name="PROPERTY_HINT_PLACEHOLDER_TEXT" value="18" enum="PropertyHint"> + <constant name="PROPERTY_HINT_PLACEHOLDER_TEXT" value="20" enum="PropertyHint"> Hints that a string property should have a placeholder text visible on its input field, whenever the property is empty. The hint string is the placeholder text to use. </constant> - <constant name="PROPERTY_HINT_COLOR_NO_ALPHA" value="19" enum="PropertyHint"> + <constant name="PROPERTY_HINT_COLOR_NO_ALPHA" value="21" enum="PropertyHint"> Hints that a color property should be edited without changing its alpha component, i.e. only R, G and B channels are edited. </constant> - <constant name="PROPERTY_HINT_IMAGE_COMPRESS_LOSSY" value="20" enum="PropertyHint"> + <constant name="PROPERTY_HINT_IMAGE_COMPRESS_LOSSY" value="22" enum="PropertyHint"> Hints that an image is compressed using lossy compression. </constant> - <constant name="PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS" value="21" enum="PropertyHint"> + <constant name="PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS" value="23" enum="PropertyHint"> Hints that an image is compressed using lossless compression. </constant> - <constant name="PROPERTY_HINT_TYPE_STRING" value="23" enum="PropertyHint"> + <constant name="PROPERTY_HINT_TYPE_STRING" value="25" enum="PropertyHint"> Hint that a property represents a particular type. If a property is [constant TYPE_STRING], allows to set a type from the create dialog. If you need to create an [Array] to contain elements of a specific type, the [code]hint_string[/code] must encode nested types using [code]":"[/code] and [code]"/"[/code] for specifying [Resource] types. For instance: [codeblock] hint_string = "%s:" % [TYPE_INT] # Array of inteters. diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 31e6ea5e54..fa0c3b167a 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -93,7 +93,7 @@ <member name="alpha_scissor_threshold" type="float" setter="set_alpha_scissor_threshold" getter="get_alpha_scissor_threshold"> Threshold at which the alpha scissor will discard values. </member> - <member name="anisotropy" type="float" setter="set_anisotropy" getter="get_anisotropy"> + <member name="anisotropy" type="float" setter="set_anisotropy" getter="get_anisotropy" default="0.0"> The strength of the anisotropy effect. </member> <member name="anisotropy_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> @@ -105,19 +105,19 @@ <member name="ao_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> If [code]true[/code], ambient occlusion is enabled. Ambient occlusion darkens areas based on the [member ao_texture]. </member> - <member name="ao_light_affect" type="float" setter="set_ao_light_affect" getter="get_ao_light_affect"> + <member name="ao_light_affect" type="float" setter="set_ao_light_affect" getter="get_ao_light_affect" default="0.0"> Amount that ambient occlusion affects lighting from lights. If [code]0[/code], ambient occlusion only affects ambient light. If [code]1[/code], ambient occlusion affects lights just as much as it affects ambient light. This can be used to impact the strength of the ambient occlusion effect, but typically looks unrealistic. </member> - <member name="ao_on_uv2" type="bool" setter="set_flag" getter="get_flag"> + <member name="ao_on_uv2" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], use [code]UV2[/code] coordinates to look up from the [member ao_texture]. </member> <member name="ao_texture" type="Texture2D" setter="set_texture" getter="get_texture"> Texture that defines the amount of ambient occlusion for a given point on the object. </member> - <member name="ao_texture_channel" type="int" setter="set_ao_texture_channel" getter="get_ao_texture_channel" enum="BaseMaterial3D.TextureChannel"> + <member name="ao_texture_channel" type="int" setter="set_ao_texture_channel" getter="get_ao_texture_channel" enum="BaseMaterial3D.TextureChannel" default="0"> Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. </member> - <member name="backlight" type="Color" setter="set_backlight" getter="get_backlight"> + <member name="backlight" type="Color" setter="set_backlight" getter="get_backlight" default="Color( 0, 0, 0, 1 )"> The color used by the backlight effect. Represents the light passing through an object. </member> <member name="backlight_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> @@ -137,13 +137,13 @@ The material's blend mode. [b]Note:[/b] Values other than [code]Mix[/code] force the object into the transparent pipeline. See [enum BlendMode]. </member> - <member name="clearcoat" type="float" setter="set_clearcoat" getter="get_clearcoat"> + <member name="clearcoat" type="float" setter="set_clearcoat" getter="get_clearcoat" default="1.0"> Sets the strength of the clearcoat effect. Setting to [code]0[/code] looks the same as disabling the clearcoat effect. </member> <member name="clearcoat_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> If [code]true[/code], clearcoat rendering is enabled. Adds a secondary transparent pass to the lighting calculation resulting in an added specular blob. This makes materials appear as if they have a clear layer on them that can be either glossy or rough. </member> - <member name="clearcoat_gloss" type="float" setter="set_clearcoat_gloss" getter="get_clearcoat_gloss"> + <member name="clearcoat_gloss" type="float" setter="set_clearcoat_gloss" getter="get_clearcoat_gloss" default="0.5"> Sets the roughness of the clearcoat pass. A higher value results in a smoother clearcoat while a lower value results in a rougher clearcoat. </member> <member name="clearcoat_texture" type="Texture2D" setter="set_texture" getter="get_texture"> @@ -158,7 +158,7 @@ <member name="detail_albedo" type="Texture2D" setter="set_texture" getter="get_texture"> Texture that specifies the color of the detail overlay. </member> - <member name="detail_blend_mode" type="int" setter="set_detail_blend_mode" getter="get_detail_blend_mode" enum="BaseMaterial3D.BlendMode"> + <member name="detail_blend_mode" type="int" setter="set_detail_blend_mode" getter="get_detail_blend_mode" enum="BaseMaterial3D.BlendMode" default="0"> Specifies how the [member detail_albedo] should blend with the current [code]ALBEDO[/code]. See [enum BlendMode] for options. </member> <member name="detail_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> @@ -171,7 +171,7 @@ Texture that specifies the per-pixel normal of the detail overlay. [b]Note:[/b] Godot expects the normal map to use X+, Y-, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. </member> - <member name="detail_uv_layer" type="int" setter="set_detail_uv" getter="get_detail_uv" enum="BaseMaterial3D.DetailUV"> + <member name="detail_uv_layer" type="int" setter="set_detail_uv" getter="get_detail_uv" enum="BaseMaterial3D.DetailUV" default="0"> Specifies whether to use [code]UV[/code] or [code]UV2[/code] for the detail layer. See [enum DetailUV] for options. </member> <member name="diffuse_mode" type="int" setter="set_diffuse_mode" getter="get_diffuse_mode" enum="BaseMaterial3D.DiffuseMode" default="0"> @@ -183,30 +183,30 @@ <member name="disable_receive_shadows" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], the object receives no shadow that would otherwise be cast onto it. </member> - <member name="distance_fade_max_distance" type="float" setter="set_distance_fade_max_distance" getter="get_distance_fade_max_distance"> + <member name="distance_fade_max_distance" type="float" setter="set_distance_fade_max_distance" getter="get_distance_fade_max_distance" default="10.0"> Distance at which the object appears fully opaque. [b]Note:[/b] If [code]distance_fade_max_distance[/code] is less than [code]distance_fade_min_distance[/code], the behavior will be reversed. The object will start to fade away at [code]distance_fade_max_distance[/code] and will fully disappear once it reaches [code]distance_fade_min_distance[/code]. </member> - <member name="distance_fade_min_distance" type="float" setter="set_distance_fade_min_distance" getter="get_distance_fade_min_distance"> + <member name="distance_fade_min_distance" type="float" setter="set_distance_fade_min_distance" getter="get_distance_fade_min_distance" default="0.0"> Distance at which the object starts to become visible. If the object is less than this distance away, it will be invisible. [b]Note:[/b] If [code]distance_fade_min_distance[/code] is greater than [code]distance_fade_max_distance[/code], the behavior will be reversed. The object will start to fade away at [code]distance_fade_max_distance[/code] and will fully disappear once it reaches [code]distance_fade_min_distance[/code]. </member> <member name="distance_fade_mode" type="int" setter="set_distance_fade" getter="get_distance_fade" enum="BaseMaterial3D.DistanceFadeMode" default="0"> Specifies which type of fade to use. Can be any of the [enum DistanceFadeMode]s. </member> - <member name="emission" type="Color" setter="set_emission" getter="get_emission"> + <member name="emission" type="Color" setter="set_emission" getter="get_emission" default="Color( 0, 0, 0, 1 )"> The emitted light's color. See [member emission_enabled]. </member> <member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> If [code]true[/code], the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a [GIProbe] is used and this object is used in baked lighting. </member> - <member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy"> + <member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy" default="1.0"> The emitted light's strength. See [member emission_enabled]. </member> - <member name="emission_on_uv2" type="bool" setter="set_flag" getter="get_flag"> + <member name="emission_on_uv2" type="bool" setter="set_flag" getter="get_flag" default="false"> Use [code]UV2[/code] to read from the [member emission_texture]. </member> - <member name="emission_operator" type="int" setter="set_emission_operator" getter="get_emission_operator" enum="BaseMaterial3D.EmissionOperator"> + <member name="emission_operator" type="int" setter="set_emission_operator" getter="get_emission_operator" enum="BaseMaterial3D.EmissionOperator" default="0"> Sets how [member emission] interacts with [member emission_texture]. Can either add or multiply. See [enum EmissionOperator] for options. </member> <member name="emission_texture" type="Texture2D" setter="set_texture" getter="get_texture"> @@ -221,21 +221,23 @@ <member name="grow_amount" type="float" setter="set_grow" getter="get_grow" default="0.0"> Grows object vertices in the direction of their normals. </member> - <member name="heightmap_deep_parallax" type="bool" setter="set_heightmap_deep_parallax" getter="is_heightmap_deep_parallax_enabled"> + <member name="heightmap_deep_parallax" type="bool" setter="set_heightmap_deep_parallax" getter="is_heightmap_deep_parallax_enabled" default="false"> </member> <member name="heightmap_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> + If [code]true[/code], height mapping is enabled (also called "parallax mapping" or "depth mapping"). See also [member normal_enabled]. + [b]Note:[/b] Height mapping is not supported if triplanar mapping is used on the same material. The value of [member heightmap_enabled] will be ignored if [member uv1_triplanar] is enabled. </member> - <member name="heightmap_flip_binormal" type="bool" setter="set_heightmap_deep_parallax_flip_binormal" getter="get_heightmap_deep_parallax_flip_binormal"> + <member name="heightmap_flip_binormal" type="bool" setter="set_heightmap_deep_parallax_flip_binormal" getter="get_heightmap_deep_parallax_flip_binormal" default="false"> </member> - <member name="heightmap_flip_tangent" type="bool" setter="set_heightmap_deep_parallax_flip_tangent" getter="get_heightmap_deep_parallax_flip_tangent"> + <member name="heightmap_flip_tangent" type="bool" setter="set_heightmap_deep_parallax_flip_tangent" getter="get_heightmap_deep_parallax_flip_tangent" default="false"> </member> - <member name="heightmap_flip_texture" type="bool" setter="set_flag" getter="get_flag"> + <member name="heightmap_flip_texture" type="bool" setter="set_flag" getter="get_flag" default="false"> </member> <member name="heightmap_max_layers" type="int" setter="set_heightmap_deep_parallax_max_layers" getter="get_heightmap_deep_parallax_max_layers"> </member> <member name="heightmap_min_layers" type="int" setter="set_heightmap_deep_parallax_min_layers" getter="get_heightmap_deep_parallax_min_layers"> </member> - <member name="heightmap_scale" type="float" setter="set_heightmap_scale" getter="get_heightmap_scale"> + <member name="heightmap_scale" type="float" setter="set_heightmap_scale" getter="get_heightmap_scale" default="0.05"> </member> <member name="heightmap_texture" type="Texture2D" setter="set_texture" getter="get_texture"> </member> @@ -258,7 +260,7 @@ <member name="normal_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> If [code]true[/code], normal mapping is enabled. </member> - <member name="normal_scale" type="float" setter="set_normal_scale" getter="get_normal_scale"> + <member name="normal_scale" type="float" setter="set_normal_scale" getter="get_normal_scale" default="1.0"> The strength of the normal map's effect. </member> <member name="normal_texture" type="Texture2D" setter="set_texture" getter="get_texture"> @@ -279,7 +281,7 @@ <member name="point_size" type="float" setter="set_point_size" getter="get_point_size" default="1.0"> The point size in pixels. See [member use_point_size]. </member> - <member name="proximity_fade_distance" type="float" setter="set_proximity_fade_distance" getter="get_proximity_fade_distance"> + <member name="proximity_fade_distance" type="float" setter="set_proximity_fade_distance" getter="get_proximity_fade_distance" default="1.0"> Distance over which the fade effect takes place. The larger the distance the longer it takes for an object to fade. </member> <member name="proximity_fade_enable" type="bool" setter="set_proximity_fade" getter="is_proximity_fade_enabled" default="false"> @@ -288,16 +290,16 @@ <member name="refraction_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> If [code]true[/code], the refraction effect is enabled. Distorts transparency based on light from behind the object. </member> - <member name="refraction_scale" type="float" setter="set_refraction" getter="get_refraction"> + <member name="refraction_scale" type="float" setter="set_refraction" getter="get_refraction" default="0.05"> The strength of the refraction effect. </member> <member name="refraction_texture" type="Texture2D" setter="set_texture" getter="get_texture"> Texture that controls the strength of the refraction per-pixel. Multiplied by [member refraction_scale]. </member> - <member name="refraction_texture_channel" type="int" setter="set_refraction_texture_channel" getter="get_refraction_texture_channel" enum="BaseMaterial3D.TextureChannel"> + <member name="refraction_texture_channel" type="int" setter="set_refraction_texture_channel" getter="get_refraction_texture_channel" enum="BaseMaterial3D.TextureChannel" default="0"> Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. </member> - <member name="rim" type="float" setter="set_rim" getter="get_rim"> + <member name="rim" type="float" setter="set_rim" getter="get_rim" default="1.0"> Sets the strength of the rim lighting effect. </member> <member name="rim_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> @@ -306,7 +308,7 @@ <member name="rim_texture" type="Texture2D" setter="set_texture" getter="get_texture"> Texture used to set the strength of the rim lighting effect per-pixel. Multiplied by [member rim]. </member> - <member name="rim_tint" type="float" setter="set_rim_tint" getter="get_rim_tint"> + <member name="rim_tint" type="float" setter="set_rim_tint" getter="get_rim_tint" default="0.5"> The amount of to blend light and albedo color when rendering rim effect. If [code]0[/code] the light color is used, while [code]1[/code] means albedo color is used. An intermediate value generally works best. </member> <member name="roughness" type="float" setter="set_roughness" getter="get_roughness" default="1.0"> @@ -330,24 +332,24 @@ <member name="subsurf_scatter_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> If [code]true[/code], subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges. </member> - <member name="subsurf_scatter_skin_mode" type="bool" setter="set_flag" getter="get_flag"> + <member name="subsurf_scatter_skin_mode" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], subsurface scattering will use a special mode optimized for the color and density of human skin. </member> - <member name="subsurf_scatter_strength" type="float" setter="set_subsurface_scattering_strength" getter="get_subsurface_scattering_strength"> + <member name="subsurf_scatter_strength" type="float" setter="set_subsurface_scattering_strength" getter="get_subsurface_scattering_strength" default="0.0"> The strength of the subsurface scattering effect. </member> <member name="subsurf_scatter_texture" type="Texture2D" setter="set_texture" getter="get_texture"> Texture used to control the subsurface scattering strength. Stored in the red texture channel. Multiplied by [member subsurf_scatter_strength]. </member> - <member name="subsurf_scatter_transmittance_boost" type="float" setter="set_transmittance_boost" getter="get_transmittance_boost"> + <member name="subsurf_scatter_transmittance_boost" type="float" setter="set_transmittance_boost" getter="get_transmittance_boost" default="0.0"> </member> - <member name="subsurf_scatter_transmittance_color" type="Color" setter="set_transmittance_color" getter="get_transmittance_color"> + <member name="subsurf_scatter_transmittance_color" type="Color" setter="set_transmittance_color" getter="get_transmittance_color" default="Color( 1, 1, 1, 1 )"> </member> - <member name="subsurf_scatter_transmittance_curve" type="float" setter="set_transmittance_curve" getter="get_transmittance_curve"> + <member name="subsurf_scatter_transmittance_curve" type="float" setter="set_transmittance_curve" getter="get_transmittance_curve" default="1.0"> </member> - <member name="subsurf_scatter_transmittance_depth" type="float" setter="set_transmittance_depth" getter="get_transmittance_depth"> + <member name="subsurf_scatter_transmittance_depth" type="float" setter="set_transmittance_depth" getter="get_transmittance_depth" default="0.1"> </member> - <member name="subsurf_scatter_transmittance_enabled" type="bool" setter="set_feature" getter="get_feature"> + <member name="subsurf_scatter_transmittance_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> </member> <member name="subsurf_scatter_transmittance_texture" type="Texture2D" setter="set_texture" getter="get_texture"> </member> diff --git a/doc/classes/Callable.xml b/doc/classes/Callable.xml index f137ede90f..b69768d33f 100644 --- a/doc/classes/Callable.xml +++ b/doc/classes/Callable.xml @@ -8,26 +8,26 @@ [b]Example:[/b] [codeblocks] [gdscript] - var callable = Callable(self, "print_args") func print_args(arg1, arg2, arg3 = ""): prints(arg1, arg2, arg3) func test(): - callable.call("hello", "world") # Prints "hello world". + var callable = Callable(self, "print_args") + callable.call("hello", "world") # Prints "hello world ". callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(Node.gd)::print_args". callable.call("invalid") # Invalid call, should have at least 2 arguments. [/gdscript] [csharp] - Callable callable = new Callable(this, "print_args"); - public void PrintArgs(object arg1, object arg2, object arg3 = "") + public void PrintArgs(object arg1, object arg2, object arg3 = null) { GD.PrintS(arg1, arg2, arg3); } public void Test() { - callable.Call("hello", "world"); // Prints "hello world". - callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.gd)::print_args". + Callable callable = new Callable(this, nameof(PrintArgs)); + callable.Call("hello", "world"); // Prints "hello world null". + callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs". callable.Call("invalid"); // Invalid call, should have at least 2 arguments. } [/csharp] @@ -67,6 +67,7 @@ <return type="Callable"> </return> <description> + Returns a copy of this [Callable] with the arguments bound. Bound arguments are passed after the arguments supplied by [method call]. </description> </method> <method name="call" qualifiers="vararg"> @@ -108,24 +109,28 @@ <return type="int"> </return> <description> + Returns the hash value of this [Callable]'s object. </description> </method> <method name="is_custom"> <return type="bool"> </return> <description> + Returns [code]true[/code] if this [Callable] is a custom callable whose behavior differs based on implementation details. Custom callables are used in the engine for various reasons. If [code]true[/code], you can't use [method get_method]. </description> </method> <method name="is_null"> <return type="bool"> </return> <description> + Returns [code]true[/code] if this [Callable] has no target to call the method on. </description> </method> <method name="is_standard"> <return type="bool"> </return> <description> + Returns [code]true[/code] if this [Callable] is a standard callable, referencing an object and a method using a [StringName]. </description> </method> <method name="operator !=" qualifiers="operator"> @@ -134,6 +139,7 @@ <argument index="0" name="right" type="Callable"> </argument> <description> + Returns [code]true[/code] if both [Callable]s invoke different targets. </description> </method> <method name="operator ==" qualifiers="operator"> @@ -142,6 +148,7 @@ <argument index="0" name="right" type="Callable"> </argument> <description> + Returns [code]true[/code] if both [Callable]s invoke the same custom target. </description> </method> <method name="unbind"> @@ -150,6 +157,7 @@ <argument index="0" name="argcount" type="int"> </argument> <description> + Returns a copy of this [Callable] with the arguments unbound. Calling the returned [Callable] will call the method without the extra arguments that are supplied in the [Callable] on which you are calling this method. </description> </method> </methods> diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index aea3542867..2fc4313e47 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -91,6 +91,9 @@ <theme_item name="add_preset" type="Texture2D"> The icon for the "Add Preset" button. </theme_item> + <theme_item name="bar_arrow" type="Texture2D"> + The texture for the arrow grabber. + </theme_item> <theme_item name="color_hue" type="Texture2D"> Custom texture for the hue selection slider on the right. </theme_item> diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index 2d50d98a74..b33f3b4ffc 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -63,7 +63,7 @@ <argument index="0" name="to_point" type="Vector2"> </argument> <description> - Returns the closest point (in curve's local space) to [code]to_point[/code]. + Returns the closest baked point (in curve's local space) to [code]to_point[/code]. [code]to_point[/code] must be in this curve's local space. </description> </method> diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index bda04f010b..fcd150ad57 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -78,7 +78,7 @@ <argument index="0" name="to_point" type="Vector3"> </argument> <description> - Returns the closest point (in curve's local space) to [code]to_point[/code]. + Returns the closest baked point (in curve's local space) to [code]to_point[/code]. [code]to_point[/code] must be in this curve's local space. </description> </method> diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index 322cff4e43..1e9d089962 100644 --- a/doc/classes/EditorNode3DGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -98,6 +98,13 @@ Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_mesh] and [method EditorNode3DGizmo.add_lines]. Should not be overridden. </description> </method> + <method name="get_gizmo_name" qualifiers="virtual"> + <return type="String"> + </return> + <description> + Override this method to provide the name that will appear in the gizmo visibility menu. + </description> + </method> <method name="get_handle_name" qualifiers="virtual"> <return type="String"> </return> @@ -131,13 +138,6 @@ Gets material from the internal list of materials. If an [EditorNode3DGizmo] is provided, it will try to get the corresponding variant (selected and/or editable). </description> </method> - <method name="get_name" qualifiers="virtual"> - <return type="String"> - </return> - <description> - Override this method to provide the name that will appear in the gizmo visibility menu. - </description> - </method> <method name="get_priority" qualifiers="virtual"> <return type="int"> </return> diff --git a/doc/classes/GLTFState.xml b/doc/classes/GLTFState.xml index a8e96ec8a9..8255cd73d0 100644 --- a/doc/classes/GLTFState.xml +++ b/doc/classes/GLTFState.xml @@ -109,6 +109,12 @@ <description> </description> </method> + <method name="get_unique_animation_names"> + <return type="Array"> + </return> + <description> + </description> + </method> <method name="get_unique_names"> <return type="Array"> </return> @@ -219,6 +225,14 @@ <description> </description> </method> + <method name="set_unique_animation_names"> + <return type="void"> + </return> + <argument index="0" name="unique_animation_names" type="Array"> + </argument> + <description> + </description> + </method> <method name="set_unique_names"> <return type="void"> </return> diff --git a/doc/classes/GLTFTexture.xml b/doc/classes/GLTFTexture.xml index c7f94ab0da..be2210331f 100644 --- a/doc/classes/GLTFTexture.xml +++ b/doc/classes/GLTFTexture.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="src_image" type="int" setter="set_src_image" getter="get_src_image" default="4"> + <member name="src_image" type="int" setter="set_src_image" getter="get_src_image" default="195773152"> </member> </members> <constants> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index ffeb45907d..0020cbf242 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -302,16 +302,7 @@ <argument index="1" name="custom_bg_color" type="Color"> </argument> <description> - [codeblocks] - [gdscript] - var itemList = ItemList.new() - some_string.set_item_custom_bg_color(0, Color.red) # This will set the background color of the first item of the control to red. - [/gdscript] - [csharp] - var itemList = new ItemList(); - itemList.SetItemCustomBgColor(0, Colors.Red); // This will set the background color of the first item of the control to red. - [/csharp] - [/codeblocks] + Sets the background color of the item specified by [code]idx[/code] index to the specified [Color]. </description> </method> <method name="set_item_custom_fg_color"> @@ -323,16 +314,6 @@ </argument> <description> Sets the foreground color of the item specified by [code]idx[/code] index to the specified [Color]. - [codeblocks] - [gdscript] - var item_list = ItemList.new() - item_list.set_item_custom_fg_color(0, Color.red) # This will set the foreground color of the first item of the control to red. - [/gdscript] - [csharp] - var itemList = new ItemList(); - itemList.SetItemCustomFgColor(0, Colors.Red); // This will set the foreground color of the first item of the control to red. - [/csharp] - [/codeblocks] </description> </method> <method name="set_item_disabled"> diff --git a/doc/classes/MarginContainer.xml b/doc/classes/MarginContainer.xml index c8eebd4677..a51632d5f1 100644 --- a/doc/classes/MarginContainer.xml +++ b/doc/classes/MarginContainer.xml @@ -5,21 +5,23 @@ </brief_description> <description> Adds a top, left, bottom, and right margin to all [Control] nodes that are direct children of the container. To control the [MarginContainer]'s margin, use the [code]margin_*[/code] theme properties listed below. - [b]Note:[/b] Be careful, [Control] margin values are different than the constant margin values. If you want to change the custom margin values of the [MarginContainer] by code, you should use the following examples: + [b]Note:[/b] Be careful, [Control] margin values are different from the constant margin values. If you want to change the custom margin values of the [MarginContainer] by code, you should use the following examples: [codeblocks] [gdscript] + # This code sample assumes the current script is extending MarginContainer. var margin_value = 100 - set("custom_constants/margin_top", margin_value) - set("custom_constants/margin_left", margin_value) - set("custom_constants/margin_bottom", margin_value) - set("custom_constants/margin_right", margin_value) + add_theme_constant_override("margin_top", margin_value) + add_theme_constant_override("margin_left", margin_value) + add_theme_constant_override("margin_bottom", margin_value) + add_theme_constant_override("margin_right", margin_value) [/gdscript] [csharp] + // This code sample assumes the current script is extending MarginContainer. int marginValue = 100; - Set("custom_constants/margin_top", marginValue); - Set("custom_constants/margin_left", marginValue); - Set("custom_constants/margin_bottom", marginValue); - Set("custom_constants/margin_right", marginValue); + AddThemeConstantOverride("margin_top", marginValue); + AddThemeConstantOverride("margin_left", marginValue); + AddThemeConstantOverride("margin_bottom", marginValue); + AddThemeConstantOverride("margin_right", marginValue); [/csharp] [/codeblocks] </description> diff --git a/doc/classes/Navigation2D.xml b/doc/classes/Navigation2D.xml deleted file mode 100644 index abac29bdb7..0000000000 --- a/doc/classes/Navigation2D.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="Navigation2D" inherits="Node2D" version="4.0"> - <brief_description> - 2D navigation and pathfinding node. - </brief_description> - <description> - Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of [NavigationPolygon] resources. These are automatically collected from child [NavigationRegion2D] nodes. - </description> - <tutorials> - <link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link> - </tutorials> - <methods> - <method name="get_closest_point" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="to_point" type="Vector2"> - </argument> - <description> - Returns the point closest to the provided [code]to_point[/code] on the navigation mesh surface. - </description> - </method> - <method name="get_closest_point_owner" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="to_point" type="Vector2"> - </argument> - <description> - Returns the owner region RID for the point returned by [method get_closest_point]. - </description> - </method> - <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> - <description> - </description> - </method> - <method name="get_simple_path" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="start" type="Vector2"> - </argument> - <argument index="1" name="end" type="Vector2"> - </argument> - <argument index="2" name="optimize" type="bool" default="true"> - </argument> - <description> - Returns the path between two given points. Points are in local coordinate space. If [code]optimize[/code] is [code]true[/code] (the default), the path is smoothed by merging path segments where possible. - </description> - </method> - </methods> - <members> - <member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="10.0"> - </member> - <member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="100.0"> - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/Navigation3D.xml b/doc/classes/Navigation3D.xml deleted file mode 100644 index e7a4fe3c43..0000000000 --- a/doc/classes/Navigation3D.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="Navigation3D" inherits="Node3D" version="4.0"> - <brief_description> - Mesh-based navigation and pathfinding node. - </brief_description> - <description> - Provides navigation and pathfinding within a collection of [NavigationMesh]es. These will be automatically collected from child [NavigationRegion3D] nodes. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on. - </description> - <tutorials> - <link title="3D Navmesh Demo">https://godotengine.org/asset-library/asset/124</link> - </tutorials> - <methods> - <method name="get_closest_point" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to_point" type="Vector3"> - </argument> - <description> - Returns the point closest to the provided [code]to_point[/code] on the navigation mesh surface. - </description> - </method> - <method name="get_closest_point_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to_point" type="Vector3"> - </argument> - <description> - Returns the normal for the point returned by [method get_closest_point]. - </description> - </method> - <method name="get_closest_point_owner" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="to_point" type="Vector3"> - </argument> - <description> - Returns the owner region RID for the point returned by [method get_closest_point]. - </description> - </method> - <method name="get_closest_point_to_segment" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="start" type="Vector3"> - </argument> - <argument index="1" name="end" type="Vector3"> - </argument> - <argument index="2" name="use_collision" type="bool" default="false"> - </argument> - <description> - Returns the closest point between the navigation surface and the segment. - </description> - </method> - <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> - <description> - </description> - </method> - <method name="get_simple_path" qualifiers="const"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="start" type="Vector3"> - </argument> - <argument index="1" name="end" type="Vector3"> - </argument> - <argument index="2" name="optimize" type="bool" default="true"> - </argument> - <description> - Returns the path between two given points. Points are in local coordinate space. If [code]optimize[/code] is [code]true[/code] (the default), the agent properties associated with each [NavigationMesh] (radius, height, etc.) are considered in the path calculation, otherwise they are ignored. - </description> - </method> - </methods> - <members> - <member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="0.3"> - </member> - <member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="5.0"> - </member> - <member name="up_vector" type="Vector3" setter="set_up_vector" getter="get_up_vector" default="Vector3( 0, 1, 0 )"> - Defines which direction is up. By default, this is [code](0, 1, 0)[/code], which is the world's "up" direction. - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml index 5a9c31ef67..59bf06eaf2 100644 --- a/doc/classes/NavigationAgent2D.xml +++ b/doc/classes/NavigationAgent2D.xml @@ -4,7 +4,7 @@ 2D Agent used in navigation for collision avoidance. </brief_description> <description> - 2D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. This can be done by having the agent as a child of a [Navigation2D] node, or using [method set_navigation]. [NavigationAgent2D] is physics safe. + 2D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. [NavigationAgent2D] is physics safe. </description> <tutorials> </tutorials> @@ -37,13 +37,6 @@ Returns which index the agent is currently on in the navigation path's [PackedVector2Array]. </description> </method> - <method name="get_navigation" qualifiers="const"> - <return type="Node"> - </return> - <description> - Returns the [Navigation2D] node that the agent is using for its navigation system. - </description> - </method> <method name="get_next_location"> <return type="Vector2"> </return> @@ -79,15 +72,6 @@ Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location]. </description> </method> - <method name="set_navigation"> - <return type="void"> - </return> - <argument index="0" name="navigation" type="Node"> - </argument> - <description> - Sets the [Navigation2D] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation2D] node. - </description> - </method> <method name="set_target_location"> <return type="void"> </return> diff --git a/doc/classes/NavigationAgent3D.xml b/doc/classes/NavigationAgent3D.xml index f9df1d390b..7a130e9591 100644 --- a/doc/classes/NavigationAgent3D.xml +++ b/doc/classes/NavigationAgent3D.xml @@ -4,7 +4,7 @@ 3D Agent used in navigation for collision avoidance. </brief_description> <description> - 3D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. This can be done by having the agent as a child of a [Navigation3D] node, or using [method set_navigation]. [NavigationAgent3D] is physics safe. + 3D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. [NavigationAgent3D] is physics safe. </description> <tutorials> </tutorials> @@ -37,13 +37,6 @@ Returns which index the agent is currently on in the navigation path's [PackedVector3Array]. </description> </method> - <method name="get_navigation" qualifiers="const"> - <return type="Node"> - </return> - <description> - Returns the [Navigation3D] node that the agent is using for its navigation system. - </description> - </method> <method name="get_next_location"> <return type="Vector3"> </return> @@ -79,15 +72,6 @@ Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location]. </description> </method> - <method name="set_navigation"> - <return type="void"> - </return> - <argument index="0" name="navigation" type="Node"> - </argument> - <description> - Sets the [Navigation3D] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation3D] node. - </description> - </method> <method name="set_target_location"> <return type="void"> </return> diff --git a/doc/classes/NavigationObstacle2D.xml b/doc/classes/NavigationObstacle2D.xml index ddd96975f1..2e94eb0bba 100644 --- a/doc/classes/NavigationObstacle2D.xml +++ b/doc/classes/NavigationObstacle2D.xml @@ -4,27 +4,11 @@ 2D Obstacle used in navigation for collision avoidance. </brief_description> <description> - 2D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation2D] node, or using [method set_navigation]. [NavigationObstacle2D] is physics safe. + 2D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. [NavigationObstacle2D] is physics safe. </description> <tutorials> </tutorials> <methods> - <method name="get_navigation" qualifiers="const"> - <return type="Node"> - </return> - <description> - Returns the [Navigation2D] node that the obstacle is using for its navigation system. - </description> - </method> - <method name="set_navigation"> - <return type="void"> - </return> - <argument index="0" name="navigation" type="Node"> - </argument> - <description> - Sets the [Navigation2D] node used by the obstacle. Useful when you don't want to make the obstacle a child of a [Navigation2D] node. - </description> - </method> </methods> <constants> </constants> diff --git a/doc/classes/NavigationObstacle3D.xml b/doc/classes/NavigationObstacle3D.xml index e01a40ed73..d7454a7bea 100644 --- a/doc/classes/NavigationObstacle3D.xml +++ b/doc/classes/NavigationObstacle3D.xml @@ -4,27 +4,11 @@ 3D Obstacle used in navigation for collision avoidance. </brief_description> <description> - 3D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation3D] node, or using [method set_navigation]. [NavigationObstacle3D] is physics safe. + 3D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. [NavigationObstacle3D] is physics safe. </description> <tutorials> </tutorials> <methods> - <method name="get_navigation" qualifiers="const"> - <return type="Node"> - </return> - <description> - Returns the [Navigation3D] node that the obstacle is using for its navigation system. - </description> - </method> - <method name="set_navigation"> - <return type="void"> - </return> - <argument index="0" name="navigation" type="Node"> - </argument> - <description> - Sets the [Navigation3D] node used by the obstacle. Useful when you don't want to make the obstacle a child of a [Navigation3D] node. - </description> - </method> </methods> <constants> </constants> diff --git a/doc/classes/NavigationRegion2D.xml b/doc/classes/NavigationRegion2D.xml index aef114e1db..33a3f04c3d 100644 --- a/doc/classes/NavigationRegion2D.xml +++ b/doc/classes/NavigationRegion2D.xml @@ -1,8 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="NavigationRegion2D" inherits="Node2D" version="4.0"> <brief_description> + A region of the 2D navigation map. </brief_description> <description> + A region of the navigation map. It tells the [NavigationServer2D] what can be navigated and what cannot, based on its [NavigationPolygon] resource. + Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using [method NavigationServer2D.map_set_edge_connection_margin]. + [b]Note:[/b] Overlapping two regions' polygons is not enough for connecting two regions. They must share a similar edge. </description> <tutorials> </tutorials> @@ -10,8 +14,13 @@ </methods> <members> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true"> + Determines if the [NavigationRegion2D] is enabled or disabled. + </member> + <member name="layers" type="int" setter="set_layers" getter="get_layers" default="1"> + A bitfield determining all layers the region belongs to. These layers can be checked upon when requesting a path with [method NavigationServer2D.map_get_path]. </member> <member name="navpoly" type="NavigationPolygon" setter="set_navigation_polygon" getter="get_navigation_polygon"> + The [NavigationPolygon] resource to use. </member> </members> <constants> diff --git a/doc/classes/NavigationRegion3D.xml b/doc/classes/NavigationRegion3D.xml index b70bfb6596..2904ba4200 100644 --- a/doc/classes/NavigationRegion3D.xml +++ b/doc/classes/NavigationRegion3D.xml @@ -4,7 +4,8 @@ A region of the navigation map. </brief_description> <description> - A region of the navigation map. It tells the [Navigation3D] node what can be navigated and what cannot, based on the [NavigationMesh] resource. This should be a child of a [Navigation3D] node (even not a direct child). + A region of the navigation map. It tells the [NavigationServer3D] what can be navigated and what cannot, based on its [NavigationMesh] resource. + Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using [method NavigationServer3D.map_set_edge_connection_margin]. </description> <tutorials> </tutorials> @@ -21,6 +22,9 @@ <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true"> Determines if the [NavigationRegion3D] is enabled or disabled. </member> + <member name="layers" type="int" setter="set_layers" getter="get_layers" default="1"> + A bitfield determining all layers the region belongs to. These layers can be checked upon when requesting a path with [method NavigationServer3D.map_get_path]. + </member> <member name="navmesh" type="NavigationMesh" setter="set_navigation_mesh" getter="get_navigation_mesh"> The [NavigationMesh] resource to use. </member> diff --git a/doc/classes/NavigationServer2D.xml b/doc/classes/NavigationServer2D.xml index 5f0b04487e..4f34a8a424 100644 --- a/doc/classes/NavigationServer2D.xml +++ b/doc/classes/NavigationServer2D.xml @@ -4,7 +4,12 @@ Server interface for low-level 2D navigation access </brief_description> <description> - NavigationServer2D is the server responsible for all 2D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. + NavigationServer2D is the server responsible for all 2D navigation. It handles several objects, namely maps, regions and agents. + Maps are made up of regions, which are made of navigation polygons. Together, they define the navigable areas in the 2D world. For two regions to be connected to each other, they must share a similar edge. An edges is considered connected to another if both of its two vertices are at a distance less than [code]edge_connection_margin[/code] to the respective other edge's vertex. + You may assign navigation layers to regions with [method NavigationServer2D.region_set_layers], which then can be checked upon when requesting a path with [method NavigationServer2D.map_get_path]. This allows allowing or forbidding some areas to 2D objects. + To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity. + [b]Note:[/b] the collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine. + This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. </description> <tutorials> <link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link> @@ -207,8 +212,10 @@ </argument> <argument index="3" name="optimize" type="bool"> </argument> + <argument index="4" name="layers" type="int" default="1"> + </argument> <description> - Returns the navigation path to reach the destination from the origin, while avoiding static obstacles. + Returns the navigation path to reach the destination from the origin. [code]layers[/code] is a bitmask of all region layers that are allowed to be in the path. </description> </method> <method name="map_is_active" qualifiers="const"> @@ -260,6 +267,26 @@ Creates a new region. </description> </method> + <method name="region_get_layers" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="region" type="RID"> + </argument> + <description> + Returns the region's layers. + </description> + </method> + <method name="region_set_layers" qualifiers="const"> + <return type="void"> + </return> + <argument index="0" name="region" type="RID"> + </argument> + <argument index="1" name="layers" type="int"> + </argument> + <description> + Set the region's layers. This allows selecting regions from a path request (when using [method NavigationServer2D.map_get_path]). + </description> + </method> <method name="region_set_map" qualifiers="const"> <return type="void"> </return> diff --git a/doc/classes/NavigationServer3D.xml b/doc/classes/NavigationServer3D.xml index 95890c4b4c..0653c0d27d 100644 --- a/doc/classes/NavigationServer3D.xml +++ b/doc/classes/NavigationServer3D.xml @@ -4,7 +4,12 @@ Server interface for low-level 3D navigation access </brief_description> <description> - NavigationServer3D is the server responsible for all 3D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. + NavigationServer3D is the server responsible for all 3D navigation. It handles several objects, namely maps, regions and agents. + Maps are made up of regions, which are made of navigation meshes. Together, they define the navigable areas in the 3D world. For two regions to be connected to each other, they must share a similar edge. An edges is considered connected to another if both of its two vertices are at a distance less than [code]edge_connection_margin[/code] to the respective other edge's vertex. + You may assign navigation layers to regions with [method NavigationServer3D.region_set_layers], which then can be checked upon when requesting a path with [method NavigationServer3D.map_get_path]. This allows allowing or forbidding some areas to 3D objects. + To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity. + [b]Note:[/b] the collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine. + This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. </description> <tutorials> <link title="3D Navmesh Demo">https://godotengine.org/asset-library/asset/124</link> @@ -219,7 +224,7 @@ <argument index="0" name="map" type="RID"> </argument> <description> - Returns the edge connection margin of the map. + Returns the edge connection margin of the map. This distance is the minimum vertex distance needed to connect two edges from different regions. </description> </method> <method name="map_get_path" qualifiers="const"> @@ -233,8 +238,10 @@ </argument> <argument index="3" name="optimize" type="bool"> </argument> + <argument index="4" name="layers" type="int" default="1"> + </argument> <description> - Returns the navigation path to reach the destination from the origin. + Returns the navigation path to reach the destination from the origin. [code]layers[/code] is a bitmask of all region layers that are allowed to be in the path. </description> </method> <method name="map_get_up" qualifiers="const"> @@ -285,7 +292,7 @@ <argument index="1" name="margin" type="float"> </argument> <description> - Set the map edge connection margein used to weld the compatible region edges. + Set the map edge connection margin used to weld the compatible region edges. </description> </method> <method name="map_set_up" qualifiers="const"> @@ -328,6 +335,26 @@ Creates a new region. </description> </method> + <method name="region_get_layers" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="region" type="RID"> + </argument> + <description> + Returns the region's layers. + </description> + </method> + <method name="region_set_layers" qualifiers="const"> + <return type="void"> + </return> + <argument index="0" name="region" type="RID"> + </argument> + <argument index="1" name="layers" type="int"> + </argument> + <description> + Set the region's layers. This allows selecting regions from a path request (when using [method NavigationServer3D.map_get_path]). + </description> + </method> <method name="region_set_map" qualifiers="const"> <return type="void"> </return> diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml index 1fa82adb7a..701a430538 100644 --- a/doc/classes/PhysicsServer2D.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -58,7 +58,7 @@ <return type="RID"> </return> <description> - Creates an [Area2D]. + Creates an [Area2D]. After creating an [Area2D] with this method, assign it to a space using [method area_set_space] to use the created [Area2D] in the physics world. </description> </method> <method name="area_get_canvas_instance_id" qualifiers="const"> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index b68ca2ac67..ac63c5da79 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -169,6 +169,7 @@ </return> <description> Saves the configuration to the [code]project.godot[/code] file. + [b]Note:[/b] This method is intended to be used by editor plugins, as modified [ProjectSettings] can't be loaded back in the running app. If you want to change project settings in exported projects, use [method save_custom] to save [code]override.cfg[/code] file. </description> </method> <method name="save_custom"> @@ -177,7 +178,7 @@ <argument index="0" name="file" type="String"> </argument> <description> - Saves the configuration to a custom file. The file extension must be [code].godot[/code] (to save in text-based [ConfigFile] format) or [code].binary[/code] (to save in binary format). + Saves the configuration to a custom file. The file extension must be [code].godot[/code] (to save in text-based [ConfigFile] format) or [code].binary[/code] (to save in binary format). You can also save [code]override.cfg[/code] file, which is also text, but can be used in exported projects unlike other formats. </description> </method> <method name="set_initial_value"> @@ -273,9 +274,11 @@ If [code]true[/code], flushes the standard output stream every time a line is printed. This affects both terminal logging and file logging. When running a project, this setting must be enabled if you want logs to be collected by service managers such as systemd/journalctl. This setting is disabled by default on release builds, since flushing on every printed line will negatively affect performance if lots of lines are printed in a rapid succession. Also, if this setting is enabled, logged files will still be written successfully if the application crashes or is otherwise killed by the user (without being closed "normally"). [b]Note:[/b] Regardless of this setting, the standard error stream ([code]stderr[/code]) is always flushed when a line is printed to it. + Changes to this setting will only be applied upon restarting the application. </member> <member name="application/run/flush_stdout_on_print.debug" type="bool" setter="" getter="" default="true"> Debug build override for [member application/run/flush_stdout_on_print], as performance is less important during debugging. + Changes to this setting will only be applied upon restarting the application. </member> <member name="application/run/frame_delay_msec" type="int" setter="" getter="" default="0"> Forces a delay between frames in the main loop (in milliseconds). This may be useful if you plan to disable vertical synchronization. @@ -466,7 +469,7 @@ <member name="debug/shapes/collision/max_contacts_displayed" type="int" setter="" getter="" default="10000"> Maximum number of contact points between collision shapes to display when "Visible Collision Shapes" is enabled in the Debug menu. </member> - <member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color( 0, 0.6, 0.7, 0.5 )"> + <member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color( 0, 0.6, 0.7, 0.42 )"> Color of the collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu. </member> <member name="debug/shapes/navigation/disabled_geometry_color" type="Color" setter="" getter="" default="Color( 1, 0.7, 0.1, 0.4 )"> @@ -485,7 +488,7 @@ Position offset for tooltips, relative to the mouse cursor's hotspot. </member> <member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="false"> - If [code]true[/code], allows HiDPI display on Windows and macOS. This setting has no effect on desktop Linux, as DPI-awareness fallbacks are not supported there. + If [code]true[/code], allows HiDPI display on Windows, macOS, and the HTML5 platform. This setting has no effect on desktop Linux, as DPI-awareness fallbacks are not supported there. </member> <member name="display/window/energy_saving/keep_screen_on" type="bool" setter="" getter="" default="true"> If [code]true[/code], keeps the screen on (even in case of inactivity), so the screensaver does not take over. Works on desktop and mobile platforms. @@ -755,6 +758,66 @@ <member name="internationalization/rendering/text_driver" type="String" setter="" getter="" default=""""> Specifies the [TextServer] to use. If left empty, the default will be used. </member> + <member name="layer_names/2d_navigation/layer_0" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 0. If left empty, the layer will display as "Layer 0". + </member> + <member name="layer_names/2d_navigation/layer_1" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 1. If left empty, the layer will display as "Layer 1". + </member> + <member name="layer_names/2d_navigation/layer_10" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 10. If left empty, the layer will display as "Layer 10". + </member> + <member name="layer_names/2d_navigation/layer_11" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 11. If left empty, the layer will display as "Layer 11". + </member> + <member name="layer_names/2d_navigation/layer_12" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 12. If left empty, the layer will display as "Layer 12". + </member> + <member name="layer_names/2d_navigation/layer_13" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 13. If left empty, the layer will display as "Layer 13". + </member> + <member name="layer_names/2d_navigation/layer_14" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 14. If left empty, the layer will display as "Layer 14". + </member> + <member name="layer_names/2d_navigation/layer_15" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 15. If left empty, the layer will display as "Layer 15". + </member> + <member name="layer_names/2d_navigation/layer_16" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 16. If left empty, the layer will display as "Layer 16". + </member> + <member name="layer_names/2d_navigation/layer_17" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 17. If left empty, the layer will display as "Layer 17". + </member> + <member name="layer_names/2d_navigation/layer_18" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 18. If left empty, the layer will display as "Layer 18". + </member> + <member name="layer_names/2d_navigation/layer_19" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 19. If left empty, the layer will display as "Layer 19". + </member> + <member name="layer_names/2d_navigation/layer_2" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 2. If left empty, the layer will display as "Layer 2". + </member> + <member name="layer_names/2d_navigation/layer_3" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 3. If left empty, the layer will display as "Layer 3". + </member> + <member name="layer_names/2d_navigation/layer_4" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 4. If left empty, the layer will display as "Layer 4". + </member> + <member name="layer_names/2d_navigation/layer_5" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 5. If left empty, the layer will display as "Layer 5". + </member> + <member name="layer_names/2d_navigation/layer_6" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 6. If left empty, the layer will display as "Layer 6". + </member> + <member name="layer_names/2d_navigation/layer_7" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 7. If left empty, the layer will display as "Layer 7". + </member> + <member name="layer_names/2d_navigation/layer_8" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 8. If left empty, the layer will display as "Layer 8". + </member> + <member name="layer_names/2d_navigation/layer_9" type="String" setter="" getter="" default=""""> + Optional name for the 2D navigation layer 9. If left empty, the layer will display as "Layer 9". + </member> <member name="layer_names/2d_physics/layer_0" type="String" setter="" getter="" default=""""> Optional name for the 2D physics layer 0. If left empty, the layer will display as "Layer 0". </member> @@ -875,6 +938,66 @@ <member name="layer_names/2d_render/layer_9" type="String" setter="" getter="" default=""""> Optional name for the 2D render layer 9. If left empty, the layer will display as "Layer 9". </member> + <member name="layer_names/3d_navigation/layer_0" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 0. If left empty, the layer will display as "Layer 0". + </member> + <member name="layer_names/3d_navigation/layer_1" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 1. If left empty, the layer will display as "Layer 1". + </member> + <member name="layer_names/3d_navigation/layer_10" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 10. If left empty, the layer will display as "Layer 10". + </member> + <member name="layer_names/3d_navigation/layer_11" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 11. If left empty, the layer will display as "Layer 11". + </member> + <member name="layer_names/3d_navigation/layer_12" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 12. If left empty, the layer will display as "Layer 12". + </member> + <member name="layer_names/3d_navigation/layer_13" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 13. If left empty, the layer will display as "Layer 13". + </member> + <member name="layer_names/3d_navigation/layer_14" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 14. If left empty, the layer will display as "Layer 14". + </member> + <member name="layer_names/3d_navigation/layer_15" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 15. If left empty, the layer will display as "Layer 15". + </member> + <member name="layer_names/3d_navigation/layer_16" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 16. If left empty, the layer will display as "Layer 16". + </member> + <member name="layer_names/3d_navigation/layer_17" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 17. If left empty, the layer will display as "Layer 17". + </member> + <member name="layer_names/3d_navigation/layer_18" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 18. If left empty, the layer will display as "Layer 18". + </member> + <member name="layer_names/3d_navigation/layer_19" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 19. If left empty, the layer will display as "Layer 19". + </member> + <member name="layer_names/3d_navigation/layer_2" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 2. If left empty, the layer will display as "Layer 2". + </member> + <member name="layer_names/3d_navigation/layer_3" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 3. If left empty, the layer will display as "Layer 3". + </member> + <member name="layer_names/3d_navigation/layer_4" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 4. If left empty, the layer will display as "Layer 4". + </member> + <member name="layer_names/3d_navigation/layer_5" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 5. If left empty, the layer will display as "Layer 5". + </member> + <member name="layer_names/3d_navigation/layer_6" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 6. If left empty, the layer will display as "Layer 6". + </member> + <member name="layer_names/3d_navigation/layer_7" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 7. If left empty, the layer will display as "Layer 7". + </member> + <member name="layer_names/3d_navigation/layer_8" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 8. If left empty, the layer will display as "Layer 8". + </member> + <member name="layer_names/3d_navigation/layer_9" type="String" setter="" getter="" default=""""> + Optional name for the 3D navigation layer 9. If left empty, the layer will display as "Layer 9". + </member> <member name="layer_names/3d_physics/layer_0" type="String" setter="" getter="" default=""""> Optional name for the 3D physics layer 0. If left empty, the layer will display as "Layer 0". </member> @@ -1017,6 +1140,18 @@ </member> <member name="mono/unhandled_exception_policy" type="int" setter="" getter="" default="0"> </member> + <member name="navigation/2d/default_cell_size" type="int" setter="" getter="" default="10"> + Default cell size for 2D navigation maps. See [method NavigationServer2D.map_set_cell_size]. + </member> + <member name="navigation/2d/default_edge_connection_margin" type="int" setter="" getter="" default="100"> + Default edge connection margin for 2D navigation maps. See [method NavigationServer2D.map_set_edge_connection_margin]. + </member> + <member name="navigation/3d/default_cell_size" type="float" setter="" getter="" default="0.3"> + Default cell size for 3D navigation maps. See [method NavigationServer3D.map_set_cell_size]. + </member> + <member name="navigation/3d/default_edge_connection_margin" type="float" setter="" getter="" default="5.0"> + Default edge connection margin for 3D navigation maps. See [method NavigationServer3D.map_set_edge_connection_margin]. + </member> <member name="network/limits/debugger/max_chars_per_second" type="int" setter="" getter="" default="32768"> Maximum amount of characters allowed to send as output from the debugger. Over this value, content is dropped. This helps not to stall the debugger connection. </member> diff --git a/doc/classes/RayCast3D.xml b/doc/classes/RayCast3D.xml index d24e86a08b..443890438f 100644 --- a/doc/classes/RayCast3D.xml +++ b/doc/classes/RayCast3D.xml @@ -136,6 +136,13 @@ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> + <member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color( 0, 0, 0, 1 )"> + The custom color to use to draw the shape in the editor and at run-time if [b]Visible Collision Shapes[/b] is enabled in the [b]Debug[/b] menu. This color will be highlighted at run-time if the [RayCast3D] is colliding with something. + If set to [code]Color(0.0, 0.0, 0.0)[/code] (by default), the color set in [member ProjectSettings.debug/shapes/collision/shape_color] is used. + </member> + <member name="debug_shape_thickness" type="float" setter="set_debug_shape_thickness" getter="get_debug_shape_thickness" default="2.0"> + If set to [code]1[/code], a line is used as the debug shape. Otherwise, a truncated pyramid is drawn to represent the [RayCast3D]. Requires [b]Visible Collision Shapes[/b] to be enabled in the [b]Debug[/b] menu for the debug shape to be visible at run-time. + </member> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true"> If [code]true[/code], collisions will be reported. </member> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index dfd4a5c2d5..d2b95fda20 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -2704,11 +2704,14 @@ <description> Copies the viewport to a region of the screen specified by [code]rect[/code]. If [method viewport_set_render_direct_to_screen] is [code]true[/code], then the viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. For example, you can set the root viewport to not render at all with the following code: - [codeblock] + FIXME: The method seems to be non-existent. + [codeblocks] + [gdscript] func _ready(): get_viewport().set_attach_to_screen_rect(Rect2()) $Viewport.set_attach_to_screen_rect(Rect2(0, 0, 600, 600)) - [/codeblock] + [/gdscript] + [/codeblocks] Using this can result in significant optimization, especially on lower-end devices. However, it comes at the cost of having to manage your viewports manually. For a further optimization see, [method viewport_set_render_direct_to_screen]. </description> </method> diff --git a/doc/classes/RichTextEffect.xml b/doc/classes/RichTextEffect.xml index 726b26fbc7..edab35f162 100644 --- a/doc/classes/RichTextEffect.xml +++ b/doc/classes/RichTextEffect.xml @@ -6,10 +6,16 @@ <description> A custom effect for use with [RichTextLabel]. [b]Note:[/b] For a [RichTextEffect] to be usable, a BBCode tag must be defined as a member variable called [code]bbcode[/code] in the script. - [codeblock] + [codeblocks] + [gdscript] # The RichTextEffect will be usable like this: `[example]Some text[/example]` var bbcode = "example" - [/codeblock] + [/gdscript] + [csharp] + // The RichTextEffect will be usable like this: `[example]Some text[/example]` + public string bbcode = "example"; + [/csharp] + [/codeblocks] [b]Note:[/b] As soon as a [RichTextLabel] contains at least one [RichTextEffect], it will continuously process the effect unless the project is paused. This may impact battery life negatively. </description> <tutorials> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index c54e2f4b88..e1f6830eb2 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -69,15 +69,33 @@ <description> Returns a [SceneTreeTimer] which will [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this [SceneTree]. If [code]process_always[/code] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer. Commonly used to create a one-shot delay timer as in the following example: - [codeblock] + [codeblocks] + [gdscript] func some_function(): print("start") yield(get_tree().create_timer(1.0), "timeout") print("end") - [/codeblock] + [/gdscript] + [csharp] + public async void SomeFunction() + { + GD.Print("start"); + await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); + GD.Print("end"); + } + [/csharp] + [/codeblocks] The timer will be automatically freed after its time elapses. </description> </method> + <method name="get_first_node_in_group"> + <return type="Node"> + </return> + <argument index="0" name="group" type="StringName"> + </argument> + <description> + </description> + </method> <method name="get_frame" qualifiers="const"> <return type="int"> </return> diff --git a/doc/classes/SceneTreeTimer.xml b/doc/classes/SceneTreeTimer.xml index a4a83fa65b..b223bf6821 100644 --- a/doc/classes/SceneTreeTimer.xml +++ b/doc/classes/SceneTreeTimer.xml @@ -6,12 +6,22 @@ <description> A one-shot timer managed by the scene tree, which emits [signal timeout] on completion. See also [method SceneTree.create_timer]. As opposed to [Timer], it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example: - [codeblock] + [codeblocks] + [gdscript] func some_function(): print("Timer started.") yield(get_tree().create_timer(1.0), "timeout") print("Timer ended.") - [/codeblock] + [/gdscript] + [csharp] + public async void SomeFunction() + { + GD.Print("Timer started."); + await ToSignal(GetTree().CreateTimer(1.0f), "timeout"); + GD.Print("Timer ended."); + } + [/csharp] + [/codeblocks] </description> <tutorials> </tutorials> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml index aa60ecb12b..7185213c44 100644 --- a/doc/classes/ScriptCreateDialog.xml +++ b/doc/classes/ScriptCreateDialog.xml @@ -5,12 +5,24 @@ </brief_description> <description> The [ScriptCreateDialog] creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling one of the [method Window.popup] methods. - [codeblock] + [codeblocks] + [gdscript] func _ready(): - dialog.config("Node", "res://new_node.gd") # For in-engine types - dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # For script types + var dialog = ScriptCreateDialog.new(); + dialog.config("Node", "res://new_node.gd") # For in-engine types. + dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # For script types. dialog.popup_centered() - [/codeblock] + [/gdscript] + [csharp] + public override void _Ready() + { + var dialog = new ScriptCreateDialog(); + dialog.Config("Node", "res://NewNode.cs"); // For in-engine types. + dialog.Config("\"res://BaseNode.cs\"", "res://DerivedNode.cs"); // For script types. + dialog.PopupCentered(); + } + [/csharp] + [/codeblocks] </description> <tutorials> </tutorials> diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml index a08d4f5b44..7e2481f458 100644 --- a/doc/classes/SpinBox.xml +++ b/doc/classes/SpinBox.xml @@ -6,13 +6,22 @@ <description> SpinBox is a numerical input text field. It allows entering integers and floats. [b]Example:[/b] - [codeblock] + [codeblocks] + [gdscript] var spin_box = SpinBox.new() add_child(spin_box) var line_edit = spin_box.get_line_edit() line_edit.context_menu_enabled = false spin_box.align = LineEdit.ALIGN_RIGHT - [/codeblock] + [/gdscript] + [csharp] + var spinBox = new SpinBox(); + AddChild(spinBox); + var lineEdit = spinBox.GetLineEdit(); + lineEdit.ContextMenuEnabled = false; + spinBox.Align = LineEdit.AlignEnum.Right; + [/csharp] + [/codeblocks] The above code will create a [SpinBox], disable context menu on it and set the text alignment to right. See [Range] class for more options over the [SpinBox]. [b]Note:[/b] [SpinBox] relies on an underlying [LineEdit] node. To theme a [SpinBox]'s background, add theme items for [LineEdit] and customize them. diff --git a/doc/classes/Sprite2D.xml b/doc/classes/Sprite2D.xml index c56596423d..e4df753674 100644 --- a/doc/classes/Sprite2D.xml +++ b/doc/classes/Sprite2D.xml @@ -15,12 +15,29 @@ </return> <description> Returns a [Rect2] representing the Sprite2D's boundary in local coordinates. Can be used to detect if the Sprite2D was clicked. Example: - [codeblock] + [codeblocks] + [gdscript] func _input(event): if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT: if get_rect().has_point(to_local(event.position)): print("A click!") - [/codeblock] + [/gdscript] + [csharp] + public override void _Input(InputEvent inputEvent) + { + if (inputEvent is InputEventMouseButton inputEventMouse) + { + if (inputEventMouse.Pressed && inputEventMouse.ButtonIndex == (int)ButtonList.Left) + { + if (GetRect().HasPoint(ToLocal(inputEventMouse.Position))) + { + GD.Print("A click!"); + } + } + } + } + [/csharp] + [/codeblocks] </description> </method> <method name="is_pixel_opaque" qualifiers="const"> @@ -60,7 +77,7 @@ If [code]true[/code], texture is cut from a larger atlas texture. See [member region_rect]. </member> <member name="region_filter_clip" type="bool" setter="set_region_filter_clip" getter="is_region_filter_clip_enabled" default="false"> - If [code]true[/code], the outermost pixels get blurred out. + If [code]true[/code], the outermost pixels get blurred out. [member region_enabled] must be [code]true[/code]. </member> <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )"> The region of the atlas texture to display. [member region_enabled] must be [code]true[/code]. diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml index a73d3c8212..a1b858acf6 100644 --- a/doc/classes/StreamPeer.xml +++ b/doc/classes/StreamPeer.xml @@ -212,9 +212,14 @@ <description> Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size. Note: To put an ASCII string without prepending its size, you can use [method put_data]: - [codeblock] + [codeblocks] + [gdscript] put_data("Hello world".to_ascii()) - [/codeblock] + [/gdscript] + [csharp] + PutData("Hello World".ToAscii()); + [/csharp] + [/codeblocks] </description> </method> <method name="put_u16"> @@ -261,9 +266,14 @@ <description> Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size. Note: To put an UTF-8 string without prepending its size, you can use [method put_data]: - [codeblock] + [codeblocks] + [gdscript] put_data("Hello world".to_utf8()) - [/codeblock] + [/gdscript] + [csharp] + PutData("Hello World".ToUTF8()); + [/csharp] + [/codeblocks] </description> </method> <method name="put_var"> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index c03f6357ab..475b17d395 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -163,11 +163,15 @@ <description> Returns the index of the [b]first[/b] case-sensitive occurrence of the specified string in this instance, or [code]-1[/code]. Optionally, the starting search index can be specified, continuing to the end of the string. [b]Note:[/b] If you just want to know whether a string contains a substring, use the [code]in[/code] operator as follows: - [codeblock] - # Will evaluate to `false`. - if "i" in "team": - pass - [/codeblock] + [codeblocks] + [gdscript] + print("i" in "team") # Will print `false`. + [/gdscript] + [csharp] + // C# has no in operator, but we can use `Contains()`. + GD.Print("team".Contains("i")); // Will print `false`. + [/csharp] + [/codeblocks] </description> </method> <method name="findn"> @@ -354,9 +358,14 @@ <description> Return a [String] which is the concatenation of the [code]parts[/code]. The separator between elements is the string providing this method. Example: - [codeblock] + [codeblocks] + [gdscript] print(", ".join(["One", "Two", "Three", "Four"])) - [/codeblock] + [/gdscript] + [csharp] + GD.Print(String.Join(",", new string[] {"One", "Two", "Three", "Four"})); + [/csharp] + [/codeblocks] </description> </method> <method name="json_escape"> @@ -654,13 +663,18 @@ The splits in the returned array are sorted in the same order as the original string, from left to right. If [code]maxsplit[/code] is specified, it defines the number of splits to do from the right up to [code]maxsplit[/code]. The default value of 0 means that all items are split, thus giving the same result as [method split]. Example: - [codeblock] + [codeblocks] + [gdscript] var some_string = "One,Two,Three,Four" var some_array = some_string.rsplit(",", true, 1) print(some_array.size()) # Prints 2 print(some_array[0]) # Prints "Four" print(some_array[1]) # Prints "Three,Two,One" - [/codeblock] + [/gdscript] + [csharp] + // There is no Rsplit. + [/csharp] + [/codeblocks] </description> </method> <method name="rstrip"> @@ -723,13 +737,21 @@ Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. The [code]delimiter[/code] can be of any length. If [code]maxsplit[/code] is specified, it defines the number of splits to do from the left up to [code]maxsplit[/code]. The default value of [code]0[/code] means that all items are split. Example: - [codeblock] + [codeblocks] + [gdscript] var some_string = "One,Two,Three,Four" var some_array = some_string.split(",", true, 1) print(some_array.size()) # Prints 2 - print(some_array[0]) # Prints "One" - print(some_array[1]) # Prints "Two,Three,Four" - [/codeblock] + print(some_array[0]) # Prints "Four" + print(some_array[1]) # Prints "Three,Two,One" + [/gdscript] + [csharp] + var someString = "One,Two,Three,Four"; + var someArray = someString.Split(",", true); // This is as close as it gets to Godots API. + GD.Print(someArray[0]); // Prints "Four" + GD.Print(someArray[1]); // Prints "Three,Two,One" + [/csharp] + [/codeblocks] If you need to split strings with more complex rules, use the [RegEx] class instead. </description> </method> @@ -887,6 +909,13 @@ [/codeblocks] </description> </method> + <method name="validate_node_name"> + <return type="String"> + </return> + <description> + Removes any characters from the string that are prohibited in [Node] names ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code]). + </description> + </method> <method name="xml_escape"> <return type="String"> </return> diff --git a/doc/classes/StyleBoxFlat.xml b/doc/classes/StyleBoxFlat.xml index 13ea7df294..d66ae210ec 100644 --- a/doc/classes/StyleBoxFlat.xml +++ b/doc/classes/StyleBoxFlat.xml @@ -4,12 +4,12 @@ Customizable [StyleBox] with a given set of parameters (no texture required). </brief_description> <description> - This [StyleBox] can be used to achieve all kinds of looks without the need of a texture. Those properties are customizable: + This [StyleBox] can be used to achieve all kinds of looks without the need of a texture. The following properties are customizable: - Color - Border width (individual width for each border) - Rounded corners (individual radius for each corner) - Shadow (with blur and offset) - Setting corner radius to high values is allowed. As soon as corners would overlap, the stylebox will switch to a relative system. Example: + Setting corner radius to high values is allowed. As soon as corners overlap, the stylebox will switch to a relative system. Example: [codeblock] height = 30 corner_radius_top_left = 50 @@ -178,8 +178,8 @@ Border width for the top border. </member> <member name="corner_detail" type="int" setter="set_corner_detail" getter="get_corner_detail" default="8"> - This sets the amount of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value, you should take the corner radius ([method set_corner_radius_all]) into account. - For corner radii smaller than 10, [code]4[/code] or [code]5[/code] should be enough. For corner radii smaller than 30, values between [code]8[/code] and [code]12[/code] should be enough. + This sets the number of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value, you should take the corner radius ([method set_corner_radius_all]) into account. + For corner radii less than 10, [code]4[/code] or [code]5[/code] should be enough. For corner radii less than 30, values between [code]8[/code] and [code]12[/code] should be enough. A corner detail of [code]1[/code] will result in chamfered corners instead of rounded corners, which is useful for some artistic effects. </member> <member name="corner_radius_bottom_left" type="int" setter="set_corner_radius" getter="get_corner_radius" default="0"> diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index 331de4284e..d145b4ce97 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -5,13 +5,22 @@ </brief_description> <description> The [SurfaceTool] is used to construct a [Mesh] by specifying vertex attributes individually. It can be used to construct a [Mesh] from a script. All properties except indices need to be added before calling [method add_vertex]. For example, to add vertex colors and UVs: - [codeblock] + [codeblocks] + [gdscript] var st = SurfaceTool.new() st.begin(Mesh.PRIMITIVE_TRIANGLES) st.set_color(Color(1, 0, 0)) st.set_uv(Vector2(0, 0)) st.set_vertex(Vector3(0, 0, 0)) - [/codeblock] + [/gdscript] + [csharp] + var st = new SurfaceTool(); + st.Begin(Mesh.PrimitiveType.Triangles); + st.SetColor(new Color(1, 0, 0)); + st.SetUv(new Vector2(0, 0)); + st.SetVertex(new Vector3(0, 0, 0)); + [/csharp] + [/codeblocks] The above [SurfaceTool] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calling [method set_uv] or [method set_color], then the last values would be used. Vertex attributes must be passed [b]before[/b] calling [method add_vertex]. Failure to do so will result in an error when committing the vertex information to a mesh. Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example, if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices. diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 1d50cd60e5..088bcd1c3c 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -402,13 +402,24 @@ <description> Perform a search inside the text. Search flags can be specified in the [enum SearchFlags] enum. Returns an empty [code]Dictionary[/code] if no result was found. Otherwise, returns a [code]Dictionary[/code] containing [code]line[/code] and [code]column[/code] entries, e.g: - [codeblock] - var result = search(key, flags, line, column) - if !result.is_empty(): + [codeblocks] + [gdscript] + var result = search("print", SEARCH_WHOLE_WORDS, 0, 0) + if !result.empty(): # Result found. var line_number = result.line var column_number = result.column - [/codeblock] + [/gdscript] + [csharp] + int[] result = Search("print", (uint)TextEdit.SearchFlags.WholeWords, 0, 0); + if (result.Length > 0) + { + // Result found. + int lineNumber = result[(int)TextEdit.SearchResult.Line]; + int columnNumber = result[(int)TextEdit.SearchResult.Column]; + } + [/csharp] + [/codeblocks] </description> </method> <method name="select"> diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml index a12ef614e3..7ed8ad6d4a 100644 --- a/doc/classes/TileMap.xml +++ b/doc/classes/TileMap.xml @@ -172,12 +172,22 @@ [b]Note:[/b] Data such as navigation polygons and collision shapes are not immediately updated for performance reasons. If you need these to be immediately updated, you can call [method update_dirty_quadrants]. Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed: - [codeblock] + [codeblocks] + [gdscript] func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2()) # Write your custom logic here. # To call the default method: .set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord) - [/codeblock] + [/gdscript] + [csharp] + public void SetCell(int x, int y, int tile, bool flipX = false, bool flipY = false, bool transpose = false, Vector2 autotileCoord = new Vector2()) + { + // Write your custom logic here. + // To call the default method: + base.SetCell(x, y, tile, flipX, flipY, transpose, autotileCoord); + } + [/csharp] + [/codeblocks] </description> </method> <method name="set_cellv"> @@ -262,6 +272,9 @@ </method> </methods> <members> + <member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false"> + If [code]true[/code], this TileMap bakes a navigation region. + </member> <member name="cell_clip_uv" type="bool" setter="set_clip_uv" getter="get_clip_uv" default="false"> If [code]true[/code], the cell's UVs will be clipped. </member> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index 8502707096..a09f1bf470 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -6,16 +6,30 @@ <description> This shows a tree of items that can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like text editing, buttons and popups. It can be useful for structured displays and interactions. Trees are built via code, using [TreeItem] objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added. - [codeblock] + [codeblocks] + [gdscript] func _ready(): var tree = Tree.new() var root = tree.create_item() - tree.set_hide_root(true) + tree.hide_root = true var child1 = tree.create_item(root) var child2 = tree.create_item(root) var subchild1 = tree.create_item(child1) subchild1.set_text(0, "Subchild1") - [/codeblock] + [/gdscript] + [csharp] + public override void _Ready() + { + var tree = new Tree(); + TreeItem root = tree.CreateItem(); + tree.HideRoot = true; + TreeItem child1 = tree.CreateItem(root); + TreeItem child2 = tree.CreateItem(root); + TreeItem subchild1 = tree.CreateItem(child1); + subchild1.SetText(0, "Subchild1"); + } + [/csharp] + [/codeblocks] To iterate over all the [TreeItem] objects in a [Tree] object, use [method TreeItem.get_next] and [method TreeItem.get_children] after getting the root through [method get_root]. You can use [method Object.free] on a [TreeItem] to remove it from the [Tree]. </description> <tutorials> @@ -152,13 +166,26 @@ </return> <description> Returns the currently edited item. Can be used with [signal item_edited] to get the item that was modified. - [codeblock] + [codeblocks] + [gdscript] func _ready(): $Tree.item_edited.connect(on_Tree_item_edited) func on_Tree_item_edited(): print($Tree.get_edited()) # This item just got edited (e.g. checked). - [/codeblock] + [/gdscript] + [csharp] + public override void _Ready() + { + GetNode<Tree>("Tree").ItemEdited += OnTreeItemEdited; + } + + public void OnTreeItemEdited() + { + GD.Print(GetNode<Tree>("Tree").GetEdited()); // This item just got edited (e.g. checked). + } + [/csharp] + [/codeblocks] </description> </method> <method name="get_edited_column" qualifiers="const"> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 56ccaaf383..b32bb1e2d9 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -7,13 +7,22 @@ Tweens are useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them. [Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween] node; it would be difficult to do the same thing with an [AnimationPlayer] node. Here is a brief usage example that makes a 2D node move smoothly between two positions: - [codeblock] + [codeblocks] + [gdscript] var tween = get_node("Tween") tween.interpolate_property($Node2D, "position", Vector2(0, 0), Vector2(100, 100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) tween.start() - [/codeblock] + [/gdscript] + [csharp] + var tween = GetNode<Tween>("Tween"); + tween.InterpolateProperty(GetNode<Node2D>("Node2D"), "position", + new Vector2(0, 0), new Vector2(100, 100), 1, + Tween.TransitionType.Linear, Tween.EaseType.InOut); + tween.Start(); + [/csharp] + [/codeblocks] Many methods require a property name, such as [code]"position"[/code] above. You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (eg. [code]position:x[/code]), where it would only apply to that particular component. Many of the methods accept [code]trans_type[/code] and [code]ease_type[/code]. The first accepts an [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [url=https://easings.net/]easings.net[/url] for some examples). The second accepts an [enum EaseType] constant, and controls where the [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [constant EASE_IN_OUT], and use the one that looks best. [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/tween_cheatsheet.png]Tween easing and transition types cheatsheet[/url] diff --git a/doc/classes/UDPServer.xml b/doc/classes/UDPServer.xml index aabfed85f0..0fc00f67f8 100644 --- a/doc/classes/UDPServer.xml +++ b/doc/classes/UDPServer.xml @@ -7,8 +7,9 @@ A simple server that opens a UDP socket and returns connected [PacketPeerUDP] upon receiving new packets. See also [method PacketPeerUDP.connect_to_host]. After starting the server ([method listen]), you will need to [method poll] it at regular intervals (e.g. inside [method Node._process]) for it to process new packets, delivering them to the appropriate [PacketPeerUDP], and taking new connections. Below a small example of how it can be used: - [codeblock] - # server.gd + [codeblocks] + [gdscript] + class_name Server extends Node var server := UDPServer.new() @@ -21,20 +22,57 @@ server.poll() # Important! if server.is_connection_available(): var peer : PacketPeerUDP = server.take_connection() - var pkt = peer.get_packet() + var packet = peer.get_packet() print("Accepted peer: %s:%s" % [peer.get_packet_ip(), peer.get_packet_port()]) - print("Received data: %s" % [pkt.get_string_from_utf8()]) + print("Received data: %s" % [packet.get_string_from_utf8()]) # Reply so it knows we received the message. - peer.put_packet(pkt) + peer.put_packet(packet) # Keep a reference so we can keep contacting the remote peer. peers.append(peer) for i in range(0, peers.size()): pass # Do something with the connected peers. + [/gdscript] + [csharp] + using Godot; + using System; + using System.Collections.Generic; - [/codeblock] - [codeblock] - # client.gd + public class Server : Node + { + public UDPServer Server = new UDPServer(); + public List<PacketPeerUDP> Peers = new List<PacketPeerUDP>(); + + public override void _Ready() + { + Server.Listen(4242); + } + + public override void _Process(float delta) + { + Server.Poll(); // Important! + if (Server.IsConnectionAvailable()) + { + PacketPeerUDP peer = Server.TakeConnection(); + byte[] packet = peer.GetPacket(); + GD.Print($"Accepted Peer: {peer.GetPacketIp()}:{peer.GetPacketPort()}"); + GD.Print($"Received Data: {packet.GetStringFromUTF8()}"); + // Reply so it knows we received the message. + peer.PutPacket(packet); + // Keep a reference so we can keep contacting the remote peer. + Peers.Add(peer); + } + foreach (var peer in Peers) + { + // Do something with the peers. + } + } + } + [/csharp] + [/codeblocks] + [codeblocks] + [gdscript] + class_name Client extends Node var udp := PacketPeerUDP.new() @@ -50,7 +88,37 @@ if udp.get_available_packet_count() > 0: print("Connected: %s" % udp.get_packet().get_string_from_utf8()) connected = true - [/codeblock] + [/gdscript] + [csharp] + using Godot; + using System; + + public class Client : Node + { + public PacketPeerUDP Udp = new PacketPeerUDP(); + public bool Connected = false; + + public override void _Ready() + { + Udp.ConnectToHost("127.0.0.1", 4242); + } + + public override void _Process(float delta) + { + if (!Connected) + { + // Try to contact server + Udp.PutPacket("The Answer Is..42!".ToUTF8()); + } + if (Udp.GetAvailablePacketCount() > 0) + { + GD.Print($"Connected: {Udp.GetPacket().GetStringFromUTF8()}"); + Connected = true; + } + } + } + [/csharp] + [/codeblocks] </description> <tutorials> </tutorials> diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml index e8124d0e6a..a0330de4fa 100644 --- a/doc/classes/UndoRedo.xml +++ b/doc/classes/UndoRedo.xml @@ -7,7 +7,8 @@ Helper to manage undo/redo operations in the editor or custom tools. It works by registering methods and property changes inside "actions". Common behavior is to create an action, then add do/undo calls to functions or property changes, then committing the action. Here's an example on how to add an action to the Godot editor's own [UndoRedo], from a plugin: - [codeblock] + [codeblocks] + [gdscript] var undo_redo = get_undo_redo() # Method of EditorPlugin. func do_something(): @@ -24,7 +25,37 @@ undo_redo.add_do_property(node, "position", Vector2(100,100)) undo_redo.add_undo_property(node, "position", node.position) undo_redo.commit_action() - [/codeblock] + [/gdscript] + [csharp] + public UndoRedo UndoRedo; + + public override void _Ready() + { + UndoRedo = GetUndoRedo(); // Method of EditorPlugin. + } + + public void DoSomething() + { + // Put your code here. + } + + public void UndoSomething() + { + // Put here the code that reverts what's done by "DoSomething()". + } + + private void OnMyButtonPressed() + { + var node = GetNode<Node2D>("MyNode2D"); + UndoRedo.CreateAction("Move the node"); + UndoRedo.AddDoMethod(this, nameof(DoSomething)); + UndoRedo.AddUndoMethod(this, nameof(UndoSomething)); + UndoRedo.AddDoProperty(node, "position", new Vector2(100, 100)); + UndoRedo.AddUndoProperty(node, "position", node.Position); + UndoRedo.CommitAction(); + } + [/csharp] + [/codeblocks] [method create_action], [method add_do_method], [method add_undo_method], [method add_do_property], [method add_undo_property], and [method commit_action] should be called one after the other, like in the example. Not doing so could lead to crashes. If you don't need to register a method, you can leave [method add_do_method] and [method add_undo_method] out; the same goes for properties. You can also register more than one method/property. </description> diff --git a/doc/classes/World2D.xml b/doc/classes/World2D.xml index 25033cdb09..20b3afbd0b 100644 --- a/doc/classes/World2D.xml +++ b/doc/classes/World2D.xml @@ -18,6 +18,9 @@ <member name="direct_space_state" type="PhysicsDirectSpaceState2D" setter="" getter="get_direct_space_state"> Direct access to the world's physics 2D space state. Used for querying current and potential collisions. When using multi-threaded physics, access is limited to [code]_physics_process(delta)[/code] in the main thread. </member> + <member name="navigation_map" type="RID" setter="" getter="get_navigation_map"> + The [RID] of this world's navigation map. Used by the [NavigationServer2D]. + </member> <member name="space" type="RID" setter="" getter="get_space"> The [RID] of this world's physics space resource. Used by the [PhysicsServer2D] for 2D physics, treating it as both a space and an area. </member> diff --git a/doc/classes/World3D.xml b/doc/classes/World3D.xml index fe92077432..610ecacff4 100644 --- a/doc/classes/World3D.xml +++ b/doc/classes/World3D.xml @@ -23,6 +23,9 @@ <member name="fallback_environment" type="Environment" setter="set_fallback_environment" getter="get_fallback_environment"> The World3D's fallback_environment will be used if the World3D's [Environment] fails or is missing. </member> + <member name="navigation_map" type="RID" setter="" getter="get_navigation_map"> + The [RID] of this world's navigation map. Used by the [NavigationServer3D]. + </member> <member name="scenario" type="RID" setter="" getter="get_scenario"> The World3D's visual scenario. </member> diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index a76520dcdb..9d6be1a802 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -674,7 +674,7 @@ public: void render_info_end_capture() override {} int get_captured_render_info(RS::RenderInfo p_info) override { return 0; } - int get_render_info(RS::RenderInfo p_info) override { return 0; } + uint64_t get_render_info(RS::RenderInfo p_info) override { return 0; } String get_video_adapter_name() const override { return String(); } String get_video_adapter_vendor() const override { return String(); } diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index c564cee757..ad740efec4 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -1705,7 +1705,7 @@ VulkanContext::~VulkanContext() { vkDestroySemaphore(device, image_ownership_semaphores[i], nullptr); } } - if (inst_initialized && use_validation_layers) { + if (inst_initialized && enabled_debug_utils) { DestroyDebugUtilsMessengerEXT(inst, dbg_messenger, nullptr); } vkDestroyDevice(device, nullptr); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 934c6b95a4..804f02765c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -5885,7 +5885,7 @@ AnimationTrackEditor::AnimationTrackEditor() { optimize_max_angle->set_value(22); optimize_dialog->get_ok_button()->set_text(TTR("Optimize")); - optimize_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_CLEAN_UP_ANIMATION_CONFIRM)); + optimize_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_OPTIMIZE_ANIMATION_CONFIRM)); // diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index a9ed1bc2b9..711072f4b2 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -170,6 +170,7 @@ void CreateDialog::_update_search() { root->set_text(0, base_type); root->set_icon(0, search_options->get_theme_icon(icon_fallback, "EditorIcons")); search_options_types[base_type] = root; + _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type)); const String search_text = search_box->get_text(); bool empty_search = search_text == ""; diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index be2b98bf1a..c92e94270e 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -343,7 +343,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da DebuggerMarshalls::ResourceUsage usage; usage.deserialize(p_data); - int total = 0; + uint64_t total = 0; for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { TreeItem *it = vmem_tree->create_item(root); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 6bfc16ccd7..dbe4aa55fa 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -716,12 +716,18 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) { case LAYER_PHYSICS_2D: basename = "layer_names/2d_physics"; break; + case LAYER_NAVIGATION_2D: + basename = "layer_names/2d_navigation"; + break; case LAYER_RENDER_3D: basename = "layer_names/3d_render"; break; case LAYER_PHYSICS_3D: basename = "layer_names/3d_physics"; break; + case LAYER_NAVIGATION_3D: + basename = "layer_names/3d_navigation"; + break; } Vector<String> names; @@ -3300,7 +3306,12 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ editor->setup(options); add_property_editor(p_path, editor); - } else if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_2D_RENDER || p_hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_3D_RENDER) { + } else if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || + p_hint == PROPERTY_HINT_LAYERS_2D_RENDER || + p_hint == PROPERTY_HINT_LAYERS_2D_NAVIGATION || + p_hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || + p_hint == PROPERTY_HINT_LAYERS_3D_RENDER || + p_hint == PROPERTY_HINT_LAYERS_3D_NAVIGATION) { EditorPropertyLayers::LayerType lt = EditorPropertyLayers::LAYER_RENDER_2D; switch (p_hint) { case PROPERTY_HINT_LAYERS_2D_RENDER: @@ -3309,12 +3320,18 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ case PROPERTY_HINT_LAYERS_2D_PHYSICS: lt = EditorPropertyLayers::LAYER_PHYSICS_2D; break; + case PROPERTY_HINT_LAYERS_2D_NAVIGATION: + lt = EditorPropertyLayers::LAYER_NAVIGATION_2D; + break; case PROPERTY_HINT_LAYERS_3D_RENDER: lt = EditorPropertyLayers::LAYER_RENDER_3D; break; case PROPERTY_HINT_LAYERS_3D_PHYSICS: lt = EditorPropertyLayers::LAYER_PHYSICS_3D; break; + case PROPERTY_HINT_LAYERS_3D_NAVIGATION: + lt = EditorPropertyLayers::LAYER_NAVIGATION_3D; + break; default: { } //compiler could be smarter here and realize this can't happen } diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 6f097fb5df..07a1e72319 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -239,8 +239,10 @@ public: enum LayerType { LAYER_PHYSICS_2D, LAYER_RENDER_2D, + LAYER_NAVIGATION_2D, LAYER_PHYSICS_3D, LAYER_RENDER_3D, + LAYER_NAVIGATION_3D, }; private: diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 3d40c145f2..fe748b81c3 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1283,6 +1283,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("add_preset", "ColorPicker", theme->get_icon("Add", "EditorIcons")); theme->set_icon("preset_bg", "ColorPicker", theme->get_icon("GuiMiniCheckerboard", "EditorIcons")); theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon("OverbrightIndicator", "EditorIcons")); + theme->set_icon("bar_arrow", "ColorPicker", theme->get_icon("ColorPickerBarArrow", "EditorIcons")); theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons")); diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 07edae833d..d80003a12a 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -43,7 +43,7 @@ void EditorFileServer::_close_client(ClientData *cd) { cd->connection->disconnect_from_host(); { MutexLock lock(cd->efs->wait_mutex); - cd->efs->to_wait.insert(&cd->thread); + cd->efs->to_wait.insert(cd->thread); } while (cd->files.size()) { memdelete(cd->files.front()->get()); @@ -278,7 +278,8 @@ void EditorFileServer::_thread_start(void *s) { cd->connection = self->server->take_connection(); cd->efs = self; cd->quit = false; - cd->thread.start(_subthread_start, cd); + cd->thread = memnew(Thread); + cd->thread->start(_subthread_start, cd); } } diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index e4c8327d76..8ffd4f9692 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -47,7 +47,7 @@ class EditorFileServer : public Object { }; struct ClientData { - Thread thread; + Thread *thread; Ref<StreamPeerTCP> connection; Map<int, FileAccess *> files; EditorFileServer *efs = nullptr; diff --git a/editor/icons/ColorPickerBarArrow.svg b/editor/icons/ColorPickerBarArrow.svg new file mode 100644 index 0000000000..9d034106ee --- /dev/null +++ b/editor/icons/ColorPickerBarArrow.svg @@ -0,0 +1 @@ +<svg height="20" viewBox="0 0 16 20" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 16h12l-6-6z" fill="#e0e0e0" stroke-width="2"/></svg> diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index d0e5798045..14ecccc13e 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -35,7 +35,7 @@ #include "editor/import/scene_importer_mesh_node_3d.h" #include "scene/3d/collision_shape_3d.h" #include "scene/3d/mesh_instance_3d.h" -#include "scene/3d/navigation_3d.h" +#include "scene/3d/navigation_region_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/3d/vehicle_body_3d.h" #include "scene/animation/animation_player.h" diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index e6b99fa63f..16eefb1ad3 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -198,7 +198,11 @@ void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, } void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard, const Color &p_modulate) { - if (p_lines.is_empty()) { + add_vertices(p_lines, p_material, Mesh::PRIMITIVE_LINES, p_billboard, p_modulate); +} + +void EditorNode3DGizmo::add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard, const Color &p_modulate) { + if (p_vertices.is_empty()) { return; } @@ -209,13 +213,13 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate Array a; a.resize(Mesh::ARRAY_MAX); - a[Mesh::ARRAY_VERTEX] = p_lines; + a[Mesh::ARRAY_VERTEX] = p_vertices; Vector<Color> color; - color.resize(p_lines.size()); + color.resize(p_vertices.size()); { Color *w = color.ptrw(); - for (int i = 0; i < p_lines.size(); i++) { + for (int i = 0; i < p_vertices.size(); i++) { if (is_selected()) { w[i] = Color(1, 1, 1, 0.8) * p_modulate; } else { @@ -226,13 +230,13 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate a[Mesh::ARRAY_COLOR] = color; - mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, a); + mesh->add_surface_from_arrays(p_primitive_type, a); mesh->surface_set_material(0, p_material); if (p_billboard) { float md = 0; - for (int i = 0; i < p_lines.size(); i++) { - md = MAX(0, p_lines[i].length()); + for (int i = 0; i < p_vertices.size(); i++) { + md = MAX(0, p_vertices[i].length()); } if (md) { mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); @@ -1906,16 +1910,15 @@ void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); - Vector<Vector3> lines; + const Ref<StandardMaterial3D> material = raycast->is_enabled() ? raycast->get_debug_material() : get_material("shape_material_disabled"); - lines.push_back(Vector3()); - lines.push_back(raycast->get_target_position()); + p_gizmo->add_lines(raycast->get_debug_line_vertices(), material); - const Ref<StandardMaterial3D> material = - get_material(raycast->is_enabled() ? "shape_material" : "shape_material_disabled", p_gizmo); + if (raycast->get_debug_shape_thickness() > 1) { + p_gizmo->add_vertices(raycast->get_debug_shape_vertices(), material, Mesh::PRIMITIVE_TRIANGLE_STRIP); + } - p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); + p_gizmo->add_collision_segments(raycast->get_debug_line_vertices()); } ///// diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 19c9662162..2a0e7d0732 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -112,7 +112,7 @@ void PluginConfigDialog::_on_confirmed() { } #endif - emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? subfolder_edit->get_text() : ""); + emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? _to_absolute_plugin_path(subfolder_edit->get_text()) : ""); } else { EditorNode::get_singleton()->get_project_settings()->update_plugins(); } @@ -129,6 +129,10 @@ void PluginConfigDialog::_on_required_text_changed(const String &) { get_ok_button()->set_disabled(script_edit->get_text().get_basename().is_empty() || script_edit->get_text().get_extension() != ext || name_edit->get_text().is_empty()); } +String PluginConfigDialog::_to_absolute_plugin_path(const String &p_plugin_name) { + return "res://addons/" + p_plugin_name + "/plugin.cfg"; +} + void PluginConfigDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/plugin_config_dialog.h b/editor/plugin_config_dialog.h index 50ca417d81..f49f14c881 100644 --- a/editor/plugin_config_dialog.h +++ b/editor/plugin_config_dialog.h @@ -56,6 +56,8 @@ class PluginConfigDialog : public ConfirmationDialog { void _on_cancelled(); void _on_required_text_changed(const String &p_text); + static String _to_absolute_plugin_path(const String &p_plugin_name); + protected: virtual void _notification(int p_what); static void _bind_methods(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 4d9c5625a3..030ce4655d 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -969,14 +969,16 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int for (int i = from; i < to; i++) { if (i == p_page) { Button *current = memnew(Button); - current->set_text(itos(i + 1)); + // Keep the extended padding for the currently active page (see below). + current->set_text(vformat(" %d ", i + 1)); current->set_disabled(true); current->set_focus_mode(Control::FOCUS_NONE); hbc->add_child(current); } else { Button *current = memnew(Button); - current->set_text(itos(i + 1)); + // Add padding to make page number buttons easier to click. + current->set_text(vformat(" %d ", i + 1)); current->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(i)); hbc->add_child(current); @@ -1394,6 +1396,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { support = memnew(MenuButton); search_hb2->add_child(support); support->set_text(TTR("Support")); + support->get_popup()->set_hide_on_checkable_item_selection(false); support->get_popup()->add_check_item(TTR("Official"), SUPPORT_OFFICIAL); support->get_popup()->add_check_item(TTR("Community"), SUPPORT_COMMUNITY); support->get_popup()->add_check_item(TTR("Testing"), SUPPORT_TESTING); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 28926d18c2..bac6f3cd79 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -955,9 +955,11 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - canvas_item->_edit_set_state(se->undo_state); - if (restore_bones) { - _restore_canvas_item_ik_chain(canvas_item, &(se->pre_drag_bones_undo_state)); + if (se) { + canvas_item->_edit_set_state(se->undo_state); + if (restore_bones) { + _restore_canvas_item_ik_chain(canvas_item, &(se->pre_drag_bones_undo_state)); + } } } } @@ -982,13 +984,15 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); - if (commit_bones) { - for (List<Dictionary>::Element *F = se->pre_drag_bones_undo_state.front(); F; F = F->next()) { - canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); - undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", F->get()); + if (se) { + undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); + if (commit_bones) { + for (List<Dictionary>::Element *F = se->pre_drag_bones_undo_state.front(); F; F = F->next()) { + canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); + undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", F->get()); + } } } } @@ -1021,6 +1025,32 @@ void CanvasItemEditor::_selection_menu_hide() { selection_menu->set_size(Vector2(0, 0)); } +void CanvasItemEditor::_add_node_pressed(int p_result) { + if (p_result == AddNodeOption::ADD_NODE) { + editor->get_scene_tree_dock()->open_add_child_dialog(); + } else if (p_result == AddNodeOption::ADD_INSTANCE) { + editor->get_scene_tree_dock()->open_instance_child_dialog(); + } +} + +void CanvasItemEditor::_node_created(Node *p_node) { + if (node_create_position == Point2()) { + return; + } + + CanvasItem *c = Object::cast_to<CanvasItem>(p_node); + if (c) { + Transform2D xform = c->get_global_transform_with_canvas().affine_inverse() * c->get_transform(); + c->_edit_set_position(xform.xform(node_create_position)); + } + + call_deferred("_reset_create_position"); // Defer the call in case more than one node is added. +} + +void CanvasItemEditor::_reset_create_position() { + node_create_position = Point2(); +} + bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> b = p_event; Ref<InputEventMouseMotion> m = p_event; @@ -2212,17 +2242,19 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); - - Node2D *node2d = Object::cast_to<Node2D>(canvas_item); - if (node2d && se->pre_drag_bones_undo_state.size() > 0 && !force_no_IK) { - real_t initial_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); - _restore_canvas_item_ik_chain(node2d, &(all_bones_ik_states[index])); - real_t final_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); - node2d->rotate(initial_leaf_node_rotation - final_leaf_node_rotation); - _solve_IK(node2d, new_pos); - } else { - canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + if (se) { + Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); + + Node2D *node2d = Object::cast_to<Node2D>(canvas_item); + if (node2d && se->pre_drag_bones_undo_state.size() > 0 && !force_no_IK) { + real_t initial_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); + _restore_canvas_item_ik_chain(node2d, &(all_bones_ik_states[index])); + real_t final_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); + node2d->rotate(initial_leaf_node_rotation - final_leaf_node_rotation); + _solve_IK(node2d, new_pos); + } else { + canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + } } index++; } @@ -2346,17 +2378,19 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); - - Node2D *node2d = Object::cast_to<Node2D>(canvas_item); - if (node2d && se->pre_drag_bones_undo_state.size() > 0) { - real_t initial_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); - _restore_canvas_item_ik_chain(node2d, &(all_bones_ik_states[index])); - real_t final_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); - node2d->rotate(initial_leaf_node_rotation - final_leaf_node_rotation); - _solve_IK(node2d, new_pos); - } else { - canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + if (se) { + Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); + + Node2D *node2d = Object::cast_to<Node2D>(canvas_item); + if (node2d && se->pre_drag_bones_undo_state.size() > 0) { + real_t initial_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); + _restore_canvas_item_ik_chain(node2d, &(all_bones_ik_states[index])); + real_t final_leaf_node_rotation = node2d->get_global_transform_with_canvas().get_rotation(); + node2d->rotate(initial_leaf_node_rotation - final_leaf_node_rotation); + _solve_IK(node2d, new_pos); + } else { + canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + } } index++; } @@ -2463,6 +2497,14 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } } + if (b.is_valid() && b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && b->get_control()) { + add_node_menu->set_position(get_global_transform().xform(get_local_mouse_position())); + add_node_menu->set_size(Vector2(1, 1)); + add_node_menu->popup(); + node_create_position = transform.affine_inverse().xform((get_local_mouse_position())); + return true; + } + if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && tool == TOOL_SELECT) { // Single item selection Point2 click = transform.affine_inverse().xform(b->get_position()); @@ -5364,6 +5406,7 @@ void CanvasItemEditor::_bind_methods() { ClassDB::bind_method("_unhandled_key_input", &CanvasItemEditor::_unhandled_key_input); ClassDB::bind_method("_queue_update_bone_list", &CanvasItemEditor::_update_bone_list); ClassDB::bind_method("_update_bone_list", &CanvasItemEditor::_update_bone_list); + ClassDB::bind_method("_reset_create_position", &CanvasItemEditor::_reset_create_position); ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state); ClassDB::bind_method(D_METHOD("update_viewport"), &CanvasItemEditor::update_viewport); @@ -5685,6 +5728,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { editor_selection->connect("selection_changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); editor_selection->connect("selection_changed", callable_mp(this, &CanvasItemEditor::_selection_changed)); + editor->get_scene_tree_dock()->connect("node_created", callable_mp(this, &CanvasItemEditor::_node_created)); + editor->get_scene_tree_dock()->connect("add_node_used", callable_mp(this, &CanvasItemEditor::_reset_create_position)); + editor->call_deferred("connect", "play_pressed", Callable(this, "_update_override_camera_button"), make_binds(true)); editor->call_deferred("connect", "stop_pressed", Callable(this, "_update_override_camera_button"), make_binds(false)); @@ -6106,6 +6152,12 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { selection_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_selection_result_pressed)); selection_menu->connect("popup_hide", callable_mp(this, &CanvasItemEditor::_selection_menu_hide)); + add_node_menu = memnew(PopupMenu); + add_child(add_node_menu); + add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon("Add", "EditorIcons"), TTR("Add Node Here")); + add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon("Instance", "EditorIcons"), TTR("Instance Scene Here")); + add_node_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_add_node_pressed)); + multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY); divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTR("Divide grid step by 2"), KEY_KP_DIVIDE); pan_view_shortcut = ED_SHORTCUT("canvas_item_editor/pan_view", TTR("Pan View"), KEY_SPACE); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 24149a57b0..62a9b1e162 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -79,6 +79,11 @@ public: TOOL_MAX }; + enum AddNodeOption { + ADD_NODE, + ADD_INSTANCE, + }; + private: EditorNode *editor; @@ -284,6 +289,7 @@ private: bool ruler_tool_active; Point2 ruler_tool_origin; + Point2 node_create_position; MenuOption last_option; @@ -376,6 +382,7 @@ private: Button *key_auto_insert_button; PopupMenu *selection_menu; + PopupMenu *add_node_menu; Control *top_ruler; Control *left_ruler; @@ -436,6 +443,9 @@ private: void _snap_changed(); void _selection_result_pressed(int); void _selection_menu_hide(); + void _add_node_pressed(int p_result); + void _node_created(Node *p_node); + void _reset_create_position(); UndoRedo *undo_redo; bool _build_bones_list(Node *p_node); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index bb6cc50a31..9643881f96 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -4713,7 +4713,7 @@ Dictionary Node3DEditor::get_state() const { continue; } int state = gizmos_menu->get_item_state(gizmos_menu->get_item_index(i)); - String name = gizmo_plugins_by_name[i]->get_name(); + String name = gizmo_plugins_by_name[i]->get_gizmo_name(); gizmos_status[name] = state; } @@ -4839,7 +4839,7 @@ void Node3DEditor::set_state(const Dictionary &p_state) { } int state = EditorNode3DGizmoPlugin::VISIBLE; for (int i = 0; i < keys.size(); i++) { - if (gizmo_plugins_by_name.write[j]->get_name() == String(keys[i])) { + if (gizmo_plugins_by_name.write[j]->get_gizmo_name() == String(keys[i])) { state = gizmos_status[keys[i]]; break; } @@ -5750,7 +5750,7 @@ void Node3DEditor::_update_gizmos_menu() { if (!gizmo_plugins_by_name[i]->can_be_hidden()) { continue; } - String plugin_name = gizmo_plugins_by_name[i]->get_name(); + String plugin_name = gizmo_plugins_by_name[i]->get_gizmo_name(); const int plugin_state = gizmo_plugins_by_name[i]->get_state(); gizmos_menu->add_multistate_item(plugin_name, 3, plugin_state, i); const int idx = gizmos_menu->get_item_index(i); @@ -7252,7 +7252,7 @@ void Node3DEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) { struct _GizmoPluginPriorityComparator { bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { if (p_a->get_priority() == p_b->get_priority()) { - return p_a->get_name() < p_b->get_name(); + return p_a->get_gizmo_name() < p_b->get_gizmo_name(); } return p_a->get_priority() > p_b->get_priority(); } @@ -7260,7 +7260,7 @@ struct _GizmoPluginPriorityComparator { struct _GizmoPluginNameComparator { bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { - return p_a->get_name() < p_b->get_name(); + return p_a->get_gizmo_name() < p_b->get_gizmo_name(); } }; @@ -7471,7 +7471,7 @@ void EditorNode3DGizmoPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>())); - BIND_VMETHOD(MethodInfo(Variant::STRING, "get_name")); + BIND_VMETHOD(MethodInfo(Variant::STRING, "get_gizmo_name")); BIND_VMETHOD(MethodInfo(Variant::INT, "get_priority")); BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_be_hidden")); BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_selectable_when_hidden")); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index cf4aa33257..ff4a941b06 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -99,6 +99,7 @@ protected: public: void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); + void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>()); void add_collision_segments(const Vector<Vector3> &p_lines); void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a6afd45686..8bf5d0611d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -755,8 +755,8 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { _save_layout(); } -void ScriptEditor::_close_current_tab() { - _close_tab(tab_container->get_current_tab()); +void ScriptEditor::_close_current_tab(bool p_save) { + _close_tab(tab_container->get_current_tab(), p_save); } void ScriptEditor::_close_discard_current_tab(const String &p_str) { @@ -802,7 +802,7 @@ void ScriptEditor::_close_other_tabs() { } } - _close_current_tab(); + _close_current_tab(false); } } @@ -820,7 +820,7 @@ void ScriptEditor::_close_all_tabs() { } } - _close_current_tab(); + _close_current_tab(false); } } @@ -1372,7 +1372,7 @@ void ScriptEditor::_menu_option(int p_option) { if (current->is_unsaved()) { _ask_close_current_unsaved_tab(current); } else { - _close_current_tab(); + _close_current_tab(false); } } break; case FILE_COPY_PATH: { @@ -3497,7 +3497,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { erase_tab_confirm = memnew(ConfirmationDialog); erase_tab_confirm->get_ok_button()->set_text(TTR("Save")); erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard"); - erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab)); + erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab), varray(true)); erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab)); add_child(erase_tab_confirm); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 09ed3854ea..b2172e7f10 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -325,7 +325,7 @@ class ScriptEditor : public PanelContainer { void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true); - void _close_current_tab(); + void _close_current_tab(bool p_save = true); void _close_discard_current_tab(const String &p_str); void _close_docs_tab(); void _close_other_tabs(); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 6a16aa28a9..74b01b3c36 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -40,9 +40,12 @@ void TileMapEditor::_node_removed(Node *p_node) { if (p_node == node && node) { - // Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes. - node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); + Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed); + if (node->is_connected("settings_changed", callable_tileset_settings_changed)) { + // Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes. + node->disconnect("settings_changed", callable_tileset_settings_changed); + } node = nullptr; } } @@ -1870,7 +1873,11 @@ void TileMapEditor::edit(Node *p_tile_map) { } if (node) { - node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); + Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed); + + if (node->is_connected("settings_changed", callable_tileset_settings_changed)) { + node->disconnect("settings_changed", callable_tileset_settings_changed); + } } if (p_tile_map) { node = Object::cast_to<TileMap>(p_tile_map); @@ -1897,7 +1904,11 @@ void TileMapEditor::edit(Node *p_tile_map) { } if (node) { - node->connect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); + Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed); + + if (!node->is_connected("settings_changed", callable_tileset_settings_changed)) { + node->connect("settings_changed", callable_tileset_settings_changed); + } } _clear_bucket_cache(); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 07312e42b4..8ce7153355 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -417,7 +417,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: updating = false; return false; - } else if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) { + } else if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || + hint == PROPERTY_HINT_LAYERS_2D_RENDER || + hint == PROPERTY_HINT_LAYERS_2D_NAVIGATION || + hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || + hint == PROPERTY_HINT_LAYERS_3D_RENDER || + hint == PROPERTY_HINT_LAYERS_3D_NAVIGATION) { String basename; switch (hint) { case PROPERTY_HINT_LAYERS_2D_RENDER: @@ -426,12 +431,18 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: case PROPERTY_HINT_LAYERS_2D_PHYSICS: basename = "layer_names/2d_physics"; break; + case PROPERTY_HINT_LAYERS_2D_NAVIGATION: + basename = "layer_names/2d_navigation"; + break; case PROPERTY_HINT_LAYERS_3D_RENDER: basename = "layer_names/3d_render"; break; case PROPERTY_HINT_LAYERS_3D_PHYSICS: basename = "layer_names/3d_physics"; break; + case PROPERTY_HINT_LAYERS_3D_NAVIGATION: + basename = "layer_names/3d_navigation"; + break; } checks20gc->show(); @@ -1153,7 +1164,12 @@ void CustomPropertyEditor::_action_pressed(int p_which) { emit_signal("variant_changed"); } break; case Variant::INT: { - if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) { + if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || + hint == PROPERTY_HINT_LAYERS_2D_RENDER || + hint == PROPERTY_HINT_LAYERS_2D_NAVIGATION || + hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || + hint == PROPERTY_HINT_LAYERS_3D_RENDER || + hint == PROPERTY_HINT_LAYERS_3D_NAVIGATION) { uint32_t f = v; if (checks20[p_which]->is_pressed()) { f |= (1 << p_which); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 3b48685264..2cdab83d90 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -219,6 +219,9 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node editor_data->get_undo_redo().commit_action(); editor->push_item(instances[instances.size() - 1]); + for (int i = 0; i < instances.size(); i++) { + emit_signal("node_created", instances[i]); + } } void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) { @@ -347,6 +350,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } + if (reset_create_dialog) { + create_dialog->set_base_type("Node"); + reset_create_dialog = false; + } + // Prefer nodes that inherit from the current scene root. Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene(); if (current_edited_scene_root) { @@ -367,6 +375,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } create_dialog->popup_create(true); + if (!p_confirm_override) { + emit_signal("add_node_used"); + } } break; case TOOL_INSTANCE: { if (!profile_allow_editing) { @@ -381,7 +392,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { quick_open->popup_dialog("PackedScene", true); quick_open->set_title(TTR("Instance Child Scene")); - + if (!p_confirm_override) { + emit_signal("add_node_used"); + } } break; case TOOL_EXPAND_COLLAPSE: { if (!scene_tree->get_selected()) { @@ -2091,6 +2104,8 @@ void SceneTreeDock::_do_create(Node *p_parent) { } ct->set_size(ms); } + + emit_signal("node_created", c); } void SceneTreeDock::_create() { @@ -2311,10 +2326,14 @@ void SceneTreeDock::_new_scene_from(String p_file) { Node *base = selection.front()->get(); - Map<Node *, Node *> reown; - reown[editor_data->get_edited_scene_root()] = base; - Node *copy = base->duplicate_and_reown(reown); + Map<const Node *, Node *> duplimap; + Node *copy = base->duplicate_from_editor(duplimap); + if (copy) { + for (int i = 0; i < copy->get_child_count(); i++) { + _set_node_owner_recursive(copy->get_child(i), copy); + } + Ref<PackedScene> sdata = memnew(PackedScene); Error err = sdata->pack(copy); memdelete(copy); @@ -2344,6 +2363,16 @@ void SceneTreeDock::_new_scene_from(String p_file) { } } +void SceneTreeDock::_set_node_owner_recursive(Node *p_node, Node *p_owner) { + if (!p_node->get_owner()) { + p_node->set_owner(p_owner); + } + + for (int i = 0; i < p_node->get_child_count(); i++) { + _set_node_owner_recursive(p_node->get_child(i), p_owner); + } +} + static bool _is_node_visible(Node *p_node) { if (!p_node->get_owner()) { return false; @@ -2766,6 +2795,16 @@ void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) { } } +void SceneTreeDock::open_add_child_dialog() { + create_dialog->set_base_type("CanvasItem"); + _tool_selected(TOOL_NEW, true); + reset_create_dialog = true; +} + +void SceneTreeDock::open_instance_child_dialog() { + _tool_selected(TOOL_INSTANCE, true); +} + void SceneTreeDock::add_remote_tree_editor(Control *p_remote) { ERR_FAIL_COND(remote_tree != nullptr); add_child(p_remote); @@ -2965,6 +3004,8 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("replace_node"), &SceneTreeDock::replace_node); ADD_SIGNAL(MethodInfo("remote_tree_selected")); + ADD_SIGNAL(MethodInfo("add_node_used")); + ADD_SIGNAL(MethodInfo("node_created", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); } SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data) { diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 3779b61c60..aa62c93cb5 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -100,6 +100,7 @@ class SceneTreeDock : public VBoxContainer { Vector<ObjectID> subresources; bool restore_script_editor_on_drag; + bool reset_create_dialog = false; int current_option; CreateDialog *create_dialog; @@ -203,6 +204,7 @@ class SceneTreeDock : public VBoxContainer { void _import_subscene(); void _new_scene_from(String p_file); + void _set_node_owner_recursive(Node *p_node, Node *p_owner); bool _validate_no_foreign(); bool _validate_no_instance(); @@ -273,6 +275,9 @@ public: void attach_script_to_selected(bool p_extend); void open_script_dialog(Node *p_for_node, bool p_extend); + void open_add_child_dialog(); + void open_instance_child_dialog(); + ScriptCreateDialog *get_script_create_dialog() { return script_create_dialog; } SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index b6347d3b46..2d739202fb 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -776,9 +776,11 @@ void SceneTreeEditor::_renamed() { return; } - String new_name = which->get_text(0); - if (!Node::_validate_node_name(new_name)) { - error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n" + Node::invalid_character); + String raw_new_name = which->get_text(0); + String new_name = raw_new_name.validate_node_name(); + + if (new_name != raw_new_name) { + error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n" + String::invalid_node_name_characters); error->popup_centered(); if (new_name.is_empty()) { diff --git a/editor/translations/af.po b/editor/translations/af.po index e2a66e1acc..bda0eed750 100644 --- a/editor/translations/af.po +++ b/editor/translations/af.po @@ -1913,8 +1913,8 @@ msgid "Open a File or Directory" msgstr "Open 'n Lêer of Gids" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Stoor" @@ -4079,6 +4079,21 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Skep Vouer" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Ek sien..." + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Laai Verstek" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5186,7 +5201,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10397,6 +10411,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Laai Verstek" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12425,6 +12444,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12680,11 +12707,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ar.po b/editor/translations/ar.po index d12383f798..5c03984e01 100644 --- a/editor/translations/ar.po +++ b/editor/translations/ar.po @@ -46,12 +46,13 @@ # Musab Alasaifer <mousablasefer@gmail.com>, 2020. # Yassine Oudjana <y.oudjana@protonmail.com>, 2020. # bruvzg <bruvzg13@gmail.com>, 2020. -# StarlkYT <mrsstarlkps4@gmail.com>, 2020. +# StarlkYT <mrsstarlkps4@gmail.com>, 2020, 2021. +# Games Toon <xxtvgoodxx@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-12-29 15:03+0000\n" +"PO-Revision-Date: 2021-03-07 06:04+0000\n" "Last-Translator: StarlkYT <mrsstarlkps4@gmail.com>\n" "Language-Team: Arabic <https://hosted.weblate.org/projects/godot-engine/" "godot/ar/>\n" @@ -61,7 +62,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " "&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" -"X-Generator: Weblate 4.4.1-dev\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1701,9 +1702,8 @@ msgid "Node Dock" msgstr "رصيف العُقد" #: editor/editor_feature_profile.cpp -#, fuzzy msgid "FileSystem Dock" -msgstr "نظام الملفات" +msgstr "قوائم نظام الملفات" #: editor/editor_feature_profile.cpp msgid "Import Dock" @@ -1885,8 +1885,8 @@ msgid "Open a File or Directory" msgstr "إفتح ملف أو وجهة" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "حفظ" @@ -2342,6 +2342,9 @@ msgid "" "To restore the Default layout to its base settings, use the Delete Layout " "option and delete the Default layout." msgstr "" +"تم تجاوز اعدادات المحرر الاساسيه.\n" +"لإستعادة اعدادات المحرر, اذهب إلى خيار 'Delete Layout' من ثم إحفظ الاعدادات " +"الاساسيه." #: editor/editor_node.cpp msgid "Layout name not found!" @@ -2406,7 +2409,7 @@ msgstr "ليس هناك مشهد محدد ليتم تشغيله." #: editor/editor_node.cpp msgid "Save scene before running..." -msgstr "" +msgstr "احفظ المشهد قبل التشغيل..." #: editor/editor_node.cpp msgid "Could not start subprocess!" @@ -3147,13 +3150,12 @@ msgid "Open & Run a Script" msgstr "فتح و تشغيل كود" #: editor/editor_node.cpp -#, fuzzy msgid "" "The following files are newer on disk.\n" "What action should be taken?" msgstr "" "الملفات التالية أحدث على القرص.\n" -"ما الإجراء الذي ينبغي اتخاذه؟:" +"ما الإجراء الذي ينبغي اتخاذه؟" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp @@ -4074,6 +4076,21 @@ msgstr "هل قمت بإرجاع كائن مشتق من العقدة في دال msgid "Saving..." msgstr "جاري الحفظ..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "تحديد الوضع" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "إستيراد" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "تحميل الإفتراضي" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d ملفات" @@ -5145,7 +5162,6 @@ msgid "Sort:" msgstr "ترتيب:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "الفئة:" @@ -7346,9 +7362,8 @@ msgid "Yaw" msgstr "الإنحراف Yaw" #: editor/plugins/spatial_editor_plugin.cpp -#, fuzzy msgid "Size" -msgstr "الحجم: " +msgstr "الحجم" #: editor/plugins/spatial_editor_plugin.cpp msgid "Objects Drawn" @@ -10413,6 +10428,11 @@ msgstr "تحميل تلقائي" msgid "Plugins" msgstr "إضافات" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "تحميل الإفتراضي" + #: editor/property_editor.cpp msgid "Preset..." msgstr "إعداد مُسبق..." @@ -10474,9 +10494,8 @@ msgid "Batch Rename" msgstr "إعادة تسمية الدفعة" #: editor/rename_dialog.cpp -#, fuzzy msgid "Replace:" -msgstr "إستبدال: " +msgstr "إستبدال:" #: editor/rename_dialog.cpp #, fuzzy @@ -12463,6 +12482,14 @@ msgstr "" "مُضلع تصادم ثنائي الأبعاد (CollisionPolygon2D) الفارغ ليس له أي تأثير على " "التصادم." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12799,11 +12826,6 @@ msgstr "" "GIProbes لا يدعم برنامج تشغيل الفيديو GLES2.\n" "استخدم BakedLightmap بدلاً من ذلك." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "بقعة الضوء بزاوية أكبر من 90 درجة لا يمكنها إلقاء الظلال." diff --git a/editor/translations/bg.po b/editor/translations/bg.po index 595899152d..47fd10411a 100644 --- a/editor/translations/bg.po +++ b/editor/translations/bg.po @@ -1811,8 +1811,8 @@ msgid "Open a File or Directory" msgstr "Отваряне на файл или папка" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Запазване" @@ -3895,6 +3895,21 @@ msgstr "" msgid "Saving..." msgstr "Запазване..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Режим на избиране" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Внасяне" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Задаване на входен порт по подразбиране" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Файлове" @@ -4958,7 +4973,6 @@ msgid "Sort:" msgstr "Сортиране:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Категория:" @@ -10037,6 +10051,11 @@ msgstr "" msgid "Plugins" msgstr "Приставки" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Внасяне на преводи" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12010,6 +12029,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Празен CollisionPolygon2D не влияе на колизиите." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12288,11 +12315,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -12884,9 +12906,6 @@ msgstr "Константите не могат да бъдат променен #~ msgid "Import Large Texture" #~ msgstr "Внасяне на голяма текстура" -#~ msgid "Import Translations" -#~ msgstr "Внасяне на преводи" - #~ msgid "Couldn't import!" #~ msgstr "Неуспешно внасяне!" diff --git a/editor/translations/bn.po b/editor/translations/bn.po index 18ac61a269..ca8fff0724 100644 --- a/editor/translations/bn.po +++ b/editor/translations/bn.po @@ -1926,8 +1926,8 @@ msgid "Open a File or Directory" msgstr "ফাইল বা পথ/ডিরেক্টরি খুলুন" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "সংরক্ষন করুন" @@ -4307,6 +4307,21 @@ msgstr "" msgid "Saving..." msgstr "সংরক্ষিত হচ্ছে..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "মোড (Mode) বাছাই করুন" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "ইম্পোর্ট" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "প্রাথমিক sRGB ব্যবহার করুন" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5468,7 +5483,6 @@ msgid "Sort:" msgstr "সাজান:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "বিভাগ:" @@ -11013,6 +11027,11 @@ msgstr "স্বয়ংক্রিয়-লোড" msgid "Plugins" msgstr "প্লাগইন-সমূহ" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "লোড ডিফল্ট" + #: editor/property_editor.cpp msgid "Preset..." msgstr "প্রিসেট..." @@ -13204,6 +13223,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "সংঘর্ষে ফাঁকা/শুন্য CollisionPolygon2D-এর কোনো প্রভাব নেই।" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -13495,11 +13522,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -15440,9 +15462,6 @@ msgstr "" #~ msgid "Use Default Light" #~ msgstr "প্রাথমিক লাইট ব্যবহার করুন" -#~ msgid "Use Default sRGB" -#~ msgstr "প্রাথমিক sRGB ব্যবহার করুন" - #~ msgid "Default Light Normal:" #~ msgstr "লাইটের প্রাথমিক নরমাল:" diff --git a/editor/translations/br.po b/editor/translations/br.po index 3651e8fb0e..7600dd4eb1 100644 --- a/editor/translations/br.po +++ b/editor/translations/br.po @@ -1812,8 +1812,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3889,6 +3889,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4940,7 +4952,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9968,6 +9979,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11917,6 +11932,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12172,11 +12195,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ca.po b/editor/translations/ca.po index 38f08f66cd..141f2cd58f 100644 --- a/editor/translations/ca.po +++ b/editor/translations/ca.po @@ -1871,8 +1871,8 @@ msgid "Open a File or Directory" msgstr "Obre un Fitxer o Directori" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Desa" @@ -4105,6 +4105,21 @@ msgstr "" msgid "Saving..." msgstr "Desant..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Mode de selecció" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importa" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Carrega Valors predeterminats" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Fitxers" @@ -5197,7 +5212,6 @@ msgid "Sort:" msgstr "Ordena:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoria:" @@ -10685,6 +10699,11 @@ msgstr "Càrrega Automàtica" msgid "Plugins" msgstr "Connectors" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Carrega Valors predeterminats" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Configuració..." @@ -12827,6 +12846,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Un CollisionPolygon2D buit no té cap efecte en la col·lisió." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -13148,11 +13175,6 @@ msgstr "" "Les GIProbes no estan suportades pel controlador de vídeo GLES2.\n" "Utilitzeu un BakedLightmap en el seu lloc." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp #, fuzzy msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." diff --git a/editor/translations/cs.po b/editor/translations/cs.po index 625daea641..2c21fc0e63 100644 --- a/editor/translations/cs.po +++ b/editor/translations/cs.po @@ -11,12 +11,12 @@ # zxey <r.hozak@seznam.cz>, 2018. # Vojtěch Šamla <auzkok@seznam.cz>, 2018, 2019, 2020, 2021. # Peeter Angelo <contact@peeterangelo.com>, 2019. -# VojtechBrezina <vojta.brezina@gmail.com>, 2019. +# VojtechBrezina <vojta.brezina@gmail.com>, 2019, 2021. # Garrom Orc Shaman <garromorcshaman@gmail.com>, 2019. # David Husička <davidek251@seznam.cz>, 2019. # Luboš Nečas <lubosnecas506@seznam.cz>, 2019. # David Kubeš <kubesdavid@email.cz>, 2019. -# Emil Jiří Tywoniak <emil.tywoniak@gmail.com>, 2020. +# Emil Jiří Tywoniak <emil.tywoniak@gmail.com>, 2020, 2021. # Filip Vincůrek <vincurek.f@gmail.com>, 2020. # Ondrej Pavelka <ondrej.pavelka@outlook.com>, 2020. # Zbyněk <zbynek.fiala@gmail.com>, 2020. @@ -28,7 +28,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-01-22 10:21+0000\n" +"PO-Revision-Date: 2021-03-08 15:33+0000\n" "Last-Translator: Václav Blažej <vaclavblazej@seznam.cz>\n" "Language-Team: Czech <https://hosted.weblate.org/projects/godot-engine/godot/" "cs/>\n" @@ -37,7 +37,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 4.5-dev\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -186,11 +186,11 @@ msgstr "Animace: Změna času klíčových snímků" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Transition" -msgstr "Animace: změna přechodů" +msgstr "Animace: Změna přechodů" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Transform" -msgstr "Animace: změna transformací" +msgstr "Animace: Změna transformací" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Keyframe Value" @@ -198,7 +198,7 @@ msgstr "Animace: Změnit hodnotu klíčových snímků" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Call" -msgstr "Animace: změna volání" +msgstr "Animace: Změna více volání" #: editor/animation_track_editor.cpp msgid "Change Animation Length" @@ -292,7 +292,7 @@ msgstr "Čas (s): " #: editor/animation_track_editor.cpp msgid "Toggle Track Enabled" -msgstr "Přepínací stopa povolena" +msgstr "Povolit stopu" #: editor/animation_track_editor.cpp msgid "Continuous" @@ -676,7 +676,7 @@ msgstr "Vybrat vše/nic" #: editor/animation_track_editor_plugins.cpp msgid "Add Audio Track Clip" -msgstr "Přidat klip audio stopy" +msgstr "Přidat audio klip" #: editor/animation_track_editor_plugins.cpp msgid "Change Audio Track Clip Start Offset" @@ -1299,7 +1299,7 @@ msgstr "Přepnout bypass efektů na zvukové sběrnice" #: editor/editor_audio_buses.cpp msgid "Select Audio Bus Send" -msgstr "Vybrat přenos zvukové sběrnice" +msgstr "Vybrat cíl zvukové sběrnice" #: editor/editor_audio_buses.cpp msgid "Add Audio Bus Effect" @@ -1867,8 +1867,8 @@ msgid "Open a File or Directory" msgstr "Otevřít soubor nebo složku" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Uložit" @@ -2477,7 +2477,7 @@ msgid "" "The current scene has unsaved changes.\n" "Reload the saved scene anyway? This action cannot be undone." msgstr "" -"Tato scéna obsahuje neuložené změny.\n" +"Aktuální scéna obsahuje neuložené změny.\n" "Přesto znovu načíst? Tuto akci nelze vrátit zpět." #: editor/editor_node.cpp @@ -2538,10 +2538,8 @@ msgstr "" "Nelze povolit rozšiřující plugin: '%s' parsování konfigurace se nezdařilo." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "" -"Nelze najít záznam skriptu pro rozšiřující plugin v: 'res://addons/%s'." +msgstr "Nelze najít záznam skriptu pro rozšiřující plugin v: '%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -3132,13 +3130,12 @@ msgid "Open & Run a Script" msgstr "Otevřít a spustit skript" #: editor/editor_node.cpp -#, fuzzy msgid "" "The following files are newer on disk.\n" "What action should be taken?" msgstr "" "Následující soubory mají novější verzi na disku.\n" -"Jaká akce se má vykonat?:" +"Jaká akce se má vykonat?" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp @@ -4064,6 +4061,21 @@ msgstr "Vrátili jste objekt, který dědí z Node metodou `post_import()`?" msgid "Saving..." msgstr "Ukládání..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Režim výběru" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Import" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Načíst výchozí" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d souborů" @@ -5026,9 +5038,8 @@ msgid "Got:" msgstr "Staženo:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Neúspěšná kontrola sha256 hashe" +msgstr "Neúspěšná kontrola SHA-256 hashe" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5131,7 +5142,6 @@ msgid "Sort:" msgstr "Řadit podle:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategorie:" @@ -6302,9 +6312,8 @@ msgid "Can only set point into a ParticlesMaterial process material" msgstr "Bod lze vložit pouze do process materiálu ParticlesMaterial" #: editor/plugins/particles_2d_editor_plugin.cpp -#, fuzzy msgid "Convert to CPUParticles2D" -msgstr "Převést na CPUParticles" +msgstr "Převést na CPUParticles2D" #: editor/plugins/particles_2d_editor_plugin.cpp #: editor/plugins/particles_editor_plugin.cpp @@ -10006,9 +10015,8 @@ msgid "Projects" msgstr "Projekty" #: editor/project_manager.cpp -#, fuzzy msgid "Loading, please wait..." -msgstr "Získávání zrcadel, prosím čekejte..." +msgstr "Načítání, prosím čekejte..." #: editor/project_manager.cpp msgid "Last Modified" @@ -10381,6 +10389,11 @@ msgstr "Autoload" msgid "Plugins" msgstr "Pluginy" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Načíst výchozí" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Předvolba..." @@ -10634,7 +10647,6 @@ msgid "Can't paste root node into the same scene." msgstr "Nelze manipulovat s uzly z cizí scény!" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" msgstr "Vložit uzly" @@ -10765,7 +10777,6 @@ msgid "Attach Script" msgstr "Připojit skript" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" msgstr "Vyjmout uzly" @@ -11576,29 +11587,25 @@ msgstr "Přiřaďte uzlu GridMap zdroj MeshLibrary k použití jeho sítě." #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Begin Bake" -msgstr "" +msgstr "Začít zapečení" #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Preparing data structures" -msgstr "" +msgstr "Připravování datových struktur" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Generate buffers" -msgstr "Vygenerovat AABB" +msgstr "Vygenerovat buffery" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Direct lighting" -msgstr "Směry" +msgstr "Přímé osvětlení" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Indirect lighting" -msgstr "Odsadit zprava" +msgstr "Nepřímé osvětlení" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Post processing" msgstr "Následné zpracování" @@ -12112,9 +12119,8 @@ msgid "Select device from the list" msgstr "Vyberte zařízení ze seznamu" #: platform/android/export/export.cpp -#, fuzzy msgid "Unable to find the 'apksigner' tool." -msgstr "Nelze najít nástroj zipalign." +msgstr "Nelze najít nástroj 'apksigner'." #: platform/android/export/export.cpp msgid "" @@ -12136,14 +12142,12 @@ msgstr "" "Úložiště klíčů pro vydání je nakonfigurováno nesprávně v profilu exportu." #: platform/android/export/export.cpp -#, fuzzy msgid "A valid Android SDK path is required in Editor Settings." -msgstr "Nesprávná cesta Android SDK pro vlastní sestavení v Nastavení editoru." +msgstr "Je vyžadována platná cesta Android SDK v Nastavení editoru." #: platform/android/export/export.cpp -#, fuzzy msgid "Invalid Android SDK path in Editor Settings." -msgstr "Nesprávná cesta Android SDK pro vlastní sestavení v Nastavení editoru." +msgstr "Neplatná cesta k Android SDK v Nastavení editoru." #: platform/android/export/export.cpp msgid "Missing 'platform-tools' directory!" @@ -12151,12 +12155,11 @@ msgstr "Chybí složka \"platform-tools\"!" #: platform/android/export/export.cpp msgid "Unable to find Android SDK platform-tools' adb command." -msgstr "" +msgstr "Nelze najít příkaz adb z nástrojů platformy Android SDK." #: platform/android/export/export.cpp -#, fuzzy msgid "Please check in the Android SDK directory specified in Editor Settings." -msgstr "Nesprávná cesta Android SDK pro vlastní sestavení v Nastavení editoru." +msgstr "Zkontrolujte ve složce Android SDK uvedené v Nastavení editoru." #: platform/android/export/export.cpp msgid "Missing 'build-tools' directory!" @@ -12164,7 +12167,7 @@ msgstr "Chybí složka \"build-tools\"!" #: platform/android/export/export.cpp msgid "Unable to find Android SDK build-tools' apksigner command." -msgstr "" +msgstr "Nelze najít apksigner, nástrojů Android SDK." #: platform/android/export/export.cpp msgid "Invalid public key for APK expansion." @@ -12422,6 +12425,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Prázdný CollisionPolygon2D nemá při kolizi žádný efekt." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12625,27 +12636,23 @@ msgstr "ARVROrigin musí mít uzel ARVRCamera jako potomka." #: scene/3d/baked_lightmap.cpp msgid "Finding meshes and lights" -msgstr "" +msgstr "Hledat mřížky a světla" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Preparing geometry (%d/%d)" -msgstr "Parsuji geometrii..." +msgstr "Připravuji geometrii (%d/%d)" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Preparing environment" -msgstr "Zobrazit prostředí" +msgstr "Připravuji prostředí" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Generating capture" -msgstr "Generování světelné mapy" +msgstr "Generování snímání" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Saving lightmaps" -msgstr "Generování světelné mapy" +msgstr "Ukládám světelné mapy" #: scene/3d/baked_lightmap.cpp msgid "Done" @@ -12735,11 +12742,6 @@ msgstr "" "Video driver GLES2 nepodporuje GIProby.\n" "Místo toho použijte BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "Uzel InterpolatedCamera je zastaralý a bude odstraněn v Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight s úhlem širším než 90 stupňů nemůže vrhat stíny." @@ -13077,6 +13079,10 @@ msgstr "Odlišnosti mohou být přiřazeny pouze ve vertex funkci." msgid "Constants cannot be modified." msgstr "Konstanty není možné upravovat." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "Uzel InterpolatedCamera je zastaralý a bude odstraněn v Godot 4.0." + #~ msgid "No" #~ msgstr "Ne" diff --git a/editor/translations/da.po b/editor/translations/da.po index 0f677c6f96..bc00612eae 100644 --- a/editor/translations/da.po +++ b/editor/translations/da.po @@ -1938,8 +1938,8 @@ msgid "Open a File or Directory" msgstr "Åben en Fil eller Mappe" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Gem" @@ -4199,6 +4199,21 @@ msgstr "" msgid "Saving..." msgstr "Gemmer..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Vælg Node" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importer" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Indlæs Default" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Filer" @@ -5334,7 +5349,6 @@ msgid "Sort:" msgstr "Sorter:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategori:" @@ -10638,6 +10652,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Indlæs Default" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Forudindstillet..." @@ -12730,6 +12749,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "En tom CollisionPolygon2D har ingen effekt på kollision." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -13019,11 +13046,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/de.po b/editor/translations/de.po index 0c8ab619c5..bf3c01ae14 100644 --- a/editor/translations/de.po +++ b/editor/translations/de.po @@ -63,12 +63,16 @@ # Jonathan Hassel <jonathan.hassel@icloud.com>, 2020. # Artur Schönfeld <schoenfeld.artur@ymail.com>, 2020. # kidinashell <kidinashell@protonmail.com>, 2021. +# Daniel Glocker <mystboy666@gmail.com>, 2021. +# Raphipod <podraphi@googlemail.com>, 2021. +# Daniel Plaster <danimineiromc@googlemail.com>, 2021. +# El Captian <elcaptian@posteo.me>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:50+0000\n" -"Last-Translator: So Wieso <sowieso@dukun.de>\n" +"PO-Revision-Date: 2021-03-07 06:04+0000\n" +"Last-Translator: El Captian <elcaptian@posteo.me>\n" "Language-Team: German <https://hosted.weblate.org/projects/godot-engine/" "godot/de/>\n" "Language: de\n" @@ -76,7 +80,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.5\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1921,8 +1925,8 @@ msgid "Open a File or Directory" msgstr "Datei oder Verzeichnis öffnen" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Speichern" @@ -2443,7 +2447,7 @@ msgid "" "Please read the documentation relevant to debugging to better understand " "this workflow." msgstr "" -"Dies ist ein nicht-lokales Objekt, Änderungen an ihm werden nicht " +"Dies ist ein Laufzeit-Objekt Objekt, Änderungen an ihm werden nicht " "gespeichert.\n" "Die Dokumentation zum Debugging beschreibt den nötigen Arbeitsablauf." @@ -2602,7 +2606,6 @@ msgstr "" "fehlgeschlagen." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." msgstr "" "Skript-Feld für Erweiterung in ‚res://addons/%s‘ konnte nicht gefunden " @@ -3062,7 +3065,7 @@ msgstr "Dokumentationsvorschläge senden" #: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp msgid "Community" -msgstr "Community" +msgstr "Gemeinschaft" #: editor/editor_node.cpp msgid "About" @@ -4144,6 +4147,21 @@ msgstr "" msgid "Saving..." msgstr "Speichere..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Auswahlmodus" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Import" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Nutze Standard-sRGB" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Dateien" @@ -4907,7 +4925,7 @@ msgstr "Abspielmodus:" #: editor/plugins/animation_tree_editor_plugin.cpp #: editor/plugins/animation_tree_player_editor_plugin.cpp msgid "AnimationTree" -msgstr "AnimationTree" +msgstr "AnimationsBaum" #: editor/plugins/animation_tree_player_editor_plugin.cpp msgid "New name:" @@ -5114,9 +5132,8 @@ msgid "Got:" msgstr "Erhalten:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Sha256-Prüfung fehlgeschlagen" +msgstr "Sha256 Checksummen prüfung fehlgeschlagen" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5219,7 +5236,6 @@ msgid "Sort:" msgstr "Sortiere:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategorie:" @@ -5274,7 +5290,7 @@ msgstr "" msgid "Failed determining lightmap size. Maximum lightmap size too small?" msgstr "" "Die Größe des Lightmaps kann nicht bestimmt werden. Möglicherweise ist die " -"maximale Lightmap-Größe zu klein." +"maximale Lightmap-Größe zu klein?" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" @@ -7354,7 +7370,7 @@ msgstr "Knochen in Ruhe-Pose setzen" #: editor/plugins/skeleton_2d_editor_plugin.cpp msgid "Skeleton2D" -msgstr "Skeleton2D" +msgstr "Skelett2D" #: editor/plugins/skeleton_2d_editor_plugin.cpp msgid "Make Rest Pose (From Bones)" @@ -7462,7 +7478,7 @@ msgstr "Zeichenaufrufe" #: editor/plugins/spatial_editor_plugin.cpp msgid "Vertices" -msgstr "Vertices" +msgstr "Eckpunkte" #: editor/plugins/spatial_editor_plugin.cpp msgid "Top View." @@ -8515,7 +8531,7 @@ msgstr "Keine Textur zum Entfernen ausgewählt." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Create from scene? This will overwrite all current tiles." -msgstr "Aus Szene erstellen? Alle aktuellen Kacheln werden überschrieben!" +msgstr "Aus Szene erstellen? Alle aktuellen Kacheln werden überschrieben." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Merge from scene?" @@ -9649,7 +9665,7 @@ msgstr "" #: editor/plugins/visual_shader_editor_plugin.cpp msgid "VisualShader" -msgstr "VisualShader" +msgstr "VisuellerShader" #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Edit Visual Property" @@ -10514,6 +10530,11 @@ msgstr "Autoload" msgid "Plugins" msgstr "Erweiterungen" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Standard laden" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Voreinstellungen..." @@ -10765,14 +10786,12 @@ msgid "Instance Child Scene" msgstr "Szene hier instantiieren" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "Bearbeiten von Nodes einer fremden Szene ist nicht möglich!" +msgstr "Einfügen der Wurzelnode in dieselbe Szene nicht möglich." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Nodes einfügen" +msgstr "Node(s) einfügen" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10902,9 +10921,8 @@ msgid "Attach Script" msgstr "Skript hinzufügen" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Nodes trennen" +msgstr "Node(s) trennen" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -11546,7 +11564,7 @@ msgstr "Bibliotheken: " #: modules/gdnative/register_types.cpp msgid "GDNative" -msgstr "GDNative" +msgstr "GDNativ" #: modules/gdscript/gdscript_functions.cpp msgid "Step argument is zero!" @@ -12577,6 +12595,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Ein leeres CollisionPolygon2D hat keinen Effekt auf Kollisionen." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12906,11 +12932,6 @@ msgstr "" "GIProbes werden vom GLES2-Videotreiber nicht unterstützt.\n" "BakedLightmaps können als Alternative verwendet werden." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera ist veraltet und wird in Godot 4.0 entfernt werden." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13269,6 +13290,11 @@ msgstr "Varyings können nur in Vertex-Funktion zugewiesen werden." msgid "Constants cannot be modified." msgstr "Konstanten können nicht verändert werden." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "InterpolatedCamera ist veraltet und wird in Godot 4.0 entfernt werden." + #~ msgid "No" #~ msgstr "Nein" @@ -15112,9 +15138,6 @@ msgstr "Konstanten können nicht verändert werden." #~ msgid "Use Default Light" #~ msgstr "Nutze Standardlicht" -#~ msgid "Use Default sRGB" -#~ msgstr "Nutze Standard-sRGB" - #~ msgid "Default Light Normal:" #~ msgstr "Standardlichtnormale:" diff --git a/editor/translations/editor.pot b/editor/translations/editor.pot index 21d516e8ee..d11d4f42ac 100644 --- a/editor/translations/editor.pot +++ b/editor/translations/editor.pot @@ -1790,8 +1790,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3867,6 +3867,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4918,7 +4930,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9946,6 +9957,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11895,6 +11910,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12150,11 +12173,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/el.po b/editor/translations/el.po index f6205b3b50..8cd3397399 100644 --- a/editor/translations/el.po +++ b/editor/translations/el.po @@ -15,7 +15,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-15 10:51+0000\n" +"PO-Revision-Date: 2021-03-03 15:50+0000\n" "Last-Translator: Michalis <michalisntovas@yahoo.gr>\n" "Language-Team: Greek <https://hosted.weblate.org/projects/godot-engine/godot/" "el/>\n" @@ -24,7 +24,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.5-dev\n" +"X-Generator: Weblate 4.5.1-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1867,8 +1867,8 @@ msgid "Open a File or Directory" msgstr "Άνοιγμα αρχείου ή φακέλου" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Αποθήκευση" @@ -4088,6 +4088,21 @@ msgstr "" msgid "Saving..." msgstr "Αποθήκευση..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Επιλογή Λειτουργίας" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Εισαγωγή" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Χρήση προεπιλεγμένου sRGB" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d αρχεία" @@ -5163,7 +5178,6 @@ msgid "Sort:" msgstr "Ταξινόμηση:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Κατηγορία:" @@ -8662,7 +8676,7 @@ msgstr "Κανένα αρχείο δεν προστέθηκε στο στάδι #: editor/plugins/version_control_editor_plugin.cpp msgid "Commit" -msgstr "Δέσμευση" +msgstr "Υποβολή" #: editor/plugins/version_control_editor_plugin.cpp msgid "VCS Addon is not initialized" @@ -10473,6 +10487,11 @@ msgstr "Αυτόματη φόρτωση" msgid "Plugins" msgstr "Πρόσθετα" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Φόρτωση προεπιλογής" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Διαμόρφωση..." @@ -12547,6 +12566,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Ένα άδειο ColisionPollygon2D δεν επηρεάζει τη σύγκρουση." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12874,11 +12901,6 @@ msgstr "" "Τα GIProbes δεν υποστηρίζονται από το πρόγραμμα οδήγησης οθόνης GLES2.\n" "Εναλλακτικά, χρησιμοποιήστε ένα BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "Η InterpolatedCamera έχει καταργηθεί και θα αφαιρεθεί στο Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13226,6 +13248,11 @@ msgstr "Τα «varying» μπορούν να ανατεθούν μόνο στη msgid "Constants cannot be modified." msgstr "Οι σταθερές δεν μπορούν να τροποποιηθούν." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "Η InterpolatedCamera έχει καταργηθεί και θα αφαιρεθεί στο Godot 4.0." + #~ msgid "No" #~ msgstr "Όχι" @@ -15054,9 +15081,6 @@ msgstr "Οι σταθερές δεν μπορούν να τροποποιηθο #~ msgid "Use Default Light" #~ msgstr "Χρήση προεπιλεγμέου φωτός" -#~ msgid "Use Default sRGB" -#~ msgstr "Χρήση προεπιλεγμένου sRGB" - #~ msgid "Default Light Normal:" #~ msgstr "Προεπιλεγμένο διάνυσμα κανονικής ανάκλασης φωτός:" diff --git a/editor/translations/eo.po b/editor/translations/eo.po index bbc0d13358..46e3a6b28d 100644 --- a/editor/translations/eo.po +++ b/editor/translations/eo.po @@ -1836,8 +1836,8 @@ msgid "Open a File or Directory" msgstr "Malfermi dosieron aŭ dosierujon" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Konservi" @@ -3979,6 +3979,20 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Selektu nodo(j)n por enporti" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Enporti" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5036,7 +5050,6 @@ msgid "Sort:" msgstr "Ordigi:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10102,6 +10115,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Enporti dokon" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12076,6 +12094,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12331,11 +12357,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/es.po b/editor/translations/es.po index 20a252e6a4..85b79a7605 100644 --- a/editor/translations/es.po +++ b/editor/translations/es.po @@ -63,8 +63,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-15 10:51+0000\n" -"Last-Translator: SteamGoblin <SteamGoblin860@gmail.com>\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" +"Last-Translator: Javier Ocampos <xavier.ocampos@gmail.com>\n" "Language-Team: Spanish <https://hosted.weblate.org/projects/godot-engine/" "godot/es/>\n" "Language: es\n" @@ -72,7 +72,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.5-dev\n" +"X-Generator: Weblate 4.5\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -578,7 +578,7 @@ msgstr "Agrupar las pistas por nodo o mostrarlas como una lista plana." #: editor/animation_track_editor.cpp msgid "Snap:" -msgstr "Snap:" +msgstr "Ajuste:" #: editor/animation_track_editor.cpp msgid "Animation step value." @@ -1642,7 +1642,7 @@ msgid "" "Etc' in Project Settings." msgstr "" "La plataforma de destino requiere compresión de texturas 'ETC' para GLES2. " -"Activa 'Import Etc' en Ajustes del Proyecto." +"Activa 'Import Etc' en Configuración del Proyecto." #: editor/editor_export.cpp msgid "" @@ -1650,7 +1650,7 @@ msgid "" "'Import Etc 2' in Project Settings." msgstr "" "La plataforma de destino requiere compresión de texturas 'ETC2' para GLES3. " -"Activa 'Import Etc 2' en Ajustes del Proyecto." +"Activa 'Import Etc 2' en Configuración del Proyecto." #: editor/editor_export.cpp msgid "" @@ -1661,8 +1661,8 @@ msgid "" msgstr "" "La plataforma de destino requiere compresión de texturas 'ETC' para usar " "GLES2 como controlador de respaldo.\n" -"Activa 'Import Etc' en Ajustes del Proyecto, o desactiva 'Driver Fallback " -"Enabled'." +"Activa 'Import Etc' en Configuración del Proyecto, o desactiva 'Driver " +"Fallback Enabled'." #: editor/editor_export.cpp msgid "" @@ -1670,7 +1670,7 @@ msgid "" "'Import Pvrtc' in Project Settings." msgstr "" "La plataforma de destino requiere compresión de texturas 'PVRTC' para GLES2. " -"Activa 'Import Pvrtc' en Ajustes del Proyecto." +"Activa 'Import Pvrtc' en Configuración del Proyecto." #: editor/editor_export.cpp msgid "" @@ -1678,7 +1678,8 @@ msgid "" "Enable 'Import Etc 2' or 'Import Pvrtc' in Project Settings." msgstr "" "La plataforma de destino requiere compresión de texturas 'ETC2' o 'PVRTC' " -"para GLES3. Activa 'Import Etc 2' o 'Import Pvrtc' en Ajustes del Proyecto." +"para GLES3. Activa 'Import Etc 2' o 'Import Pvrtc' en Configuración del " +"Proyecto." #: editor/editor_export.cpp msgid "" @@ -1689,7 +1690,7 @@ msgid "" msgstr "" "La plataforma del objetivo requiere compresión de texturas 'PVRTC' para el " "driver fallback de GLES2.\n" -"Activa Import Pvrtc' en la Ajustes del Proyecto, o desactiva 'Driver " +"Activa Import Pvrtc' en Configuración del Proyecto, o desactiva 'Driver " "Fallback Enabled'." #: editor/editor_export.cpp platform/android/export/export.cpp @@ -1921,8 +1922,8 @@ msgid "Open a File or Directory" msgstr "Abrir un archivo o directorio" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Guardar" @@ -1993,7 +1994,7 @@ msgstr "Mostrar/Ocultar archivos ocultos." #: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp msgid "View items as a grid of thumbnails." -msgstr "Ver ítems como un grid de miniaturas." +msgstr "Ver ítems como una cuadrícula de miniaturas." #: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp msgid "View items as a list." @@ -2600,11 +2601,8 @@ msgstr "" "configuración de '%s'." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "" -"No se pudo encontrar el campo del script para el plugin addon en: 'res://" -"addons/%s'." +msgstr "No se pudo encontrar el campo script para el plugin de addon en: '%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -2664,8 +2662,8 @@ msgid "" "category." msgstr "" "No se ha definido ninguna escena principal, ¿seleccionar una?\n" -"Es posible cambiarla más tarde en \"Ajustes del Proyecto\" bajo la categoría " -"'application'." +"Es posible cambiarla más tarde en \"Configuración del Proyecto\" bajo la " +"categoría 'application'." #: editor/editor_node.cpp msgid "" @@ -2674,8 +2672,8 @@ msgid "" "category." msgstr "" "La escena seleccionada '%s' no existe, ¿seleccionar una válida?\n" -"Es posible cambiarla más tarde en \"Ajustes del Proyecto\" bajo la categoría " -"'application'." +"Es posible cambiarla más tarde en \"Configuración del Proyecto\" bajo la " +"categoría 'application'." #: editor/editor_node.cpp msgid "" @@ -2685,8 +2683,8 @@ msgid "" msgstr "" "La escena '%s' seleccionada no es un archivo de escena, ¿seleccionar uno " "válido?\n" -"Es posible cambiarla más tarde en \"Ajustes del Proyecto\" bajo la categoría " -"'application'." +"Es posible cambiarla más tarde en \"Configuración del Proyecto\" bajo la " +"categoría 'application'." #: editor/editor_node.cpp msgid "Save Layout" @@ -2847,7 +2845,7 @@ msgstr "Proyecto" #: editor/editor_node.cpp msgid "Project Settings..." -msgstr "Ajustes del Proyecto..." +msgstr "Configuración del Proyecto..." #: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp msgid "Version Control" @@ -3208,13 +3206,12 @@ msgid "Open & Run a Script" msgstr "Abrir y Ejecutar un Script" #: editor/editor_node.cpp -#, fuzzy msgid "" "The following files are newer on disk.\n" "What action should be taken?" msgstr "" "Los siguientes archivos son nuevos en disco.\n" -"¿Qué es lo que quieres hacer?:" +"¿Qué acción se debería tomar?" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp @@ -3969,7 +3966,7 @@ msgid "" "ProjectSettings." msgstr "" "Incluye los archivos con las siguientes extensiones. Añádelos o elimínalos " -"en Ajustes del proyecto." +"en Configuración del Proyecto." #: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/script_text_editor.cpp @@ -4147,6 +4144,21 @@ msgstr "¿Devolviste un objeto derivado de Node en el método `post_import()`?" msgid "Saving..." msgstr "Guardando..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Modo de Selección" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importación" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Usar sRGB predeterminado" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d archivos" @@ -4419,7 +4431,7 @@ msgstr "Seleccionar y mover puntos, crear puntos con clic derecho." #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp msgid "Enable snap and show grid." -msgstr "Activar snap y mostrar grid." +msgstr "Activar ajuste y mostrar cuadrícula." #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp @@ -5119,9 +5131,8 @@ msgid "Got:" msgstr "Tiene:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Fallo en la comprobación del hash sha256" +msgstr "Fallo en la comprobación del hash SHA-256" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5224,7 +5235,6 @@ msgid "Sort:" msgstr "Ordenar:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoría:" @@ -5311,15 +5321,15 @@ msgstr "Vista Previa" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Configure Snap" -msgstr "Configurar Snap" +msgstr "Configurar Ajuste" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Grid Offset:" -msgstr "Grid Offset:" +msgstr "Desplazamiento de Cuadrícula:" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Grid Step:" -msgstr "Grid Step:" +msgstr "Paso de Cuadrícula:" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Primary Line Every:" @@ -5483,11 +5493,11 @@ msgstr "Ancho Inferior" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "VCenter Wide" -msgstr "Ancho Centro Vert." +msgstr "Centro Vert. Ancho" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "HCenter Wide" -msgstr "Ancho Centro Horiz." +msgstr "Centro Horiz. Ancho" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Full Rect" @@ -5647,48 +5657,48 @@ msgstr "Modo de Regla" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Toggle smart snapping." -msgstr "Alternar acople inteligente." +msgstr "Act./Desact. ajuste inteligente." #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Use Smart Snap" -msgstr "Usar Snap Inteligente" +msgstr "Usar Ajuste Inteligente" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Toggle grid snapping." -msgstr "Act./Desact. grid snapping." +msgstr "Act./Desact. ajuste de cuadrícula." #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Use Grid Snap" -msgstr "Usar Grid Snap" +msgstr "Usar Ajuste de Cuadrícula" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Snapping Options" -msgstr "Opciones de Snapping" +msgstr "Opciones de Ajuste" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Use Rotation Snap" -msgstr "Usar Snap de Rotación" +msgstr "Usar Ajuste de Rotación" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Use Scale Snap" -msgstr "Usar Snap de Escalado" +msgstr "Usar Ajuste de Escalado" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Snap Relative" -msgstr "Snap Relativo" +msgstr "Ajuste Relativo" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Use Pixel Snap" -msgstr "Usar Pixel Snap" +msgstr "Usar Ajuste de Píxeles" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Smart Snapping" -msgstr "Snapping Inteligente" +msgstr "Ajuste Inteligente" #: editor/plugins/canvas_item_editor_plugin.cpp #: editor/plugins/spatial_editor_plugin.cpp msgid "Configure Snap..." -msgstr "Configurar Snap..." +msgstr "Configurar Ajuste..." #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Snap to Parent" @@ -5757,7 +5767,7 @@ msgstr "Ver" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Always Show Grid" -msgstr "Mostrar Siempre el Grid" +msgstr "Mostrar Siempre la Cuadrícula" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Show Helpers" @@ -5846,11 +5856,11 @@ msgstr "Limpiar Pose" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Multiply grid step by 2" -msgstr "Multiplicar grid step por 2" +msgstr "Multiplicar paso de cuadrícula por 2" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Divide grid step by 2" -msgstr "Dividir grid step por 2" +msgstr "Dividir paso de cuadrícula por 2" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Pan View" @@ -6767,43 +6777,43 @@ msgstr "Limpiar UV" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Grid Settings" -msgstr "Configuración del Grid" +msgstr "Configuración de la Cuadrícula" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Snap" -msgstr "Snap" +msgstr "Ajuste" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Enable Snap" -msgstr "Activar Snap" +msgstr "Activar Ajuste" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Grid" -msgstr "Grid" +msgstr "Cuadrícula" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Show Grid" -msgstr "Ver Grid" +msgstr "Ver Cuadrícula" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Configure Grid:" -msgstr "Configurar Grid:" +msgstr "Configurar Cuadrícula:" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Grid Offset X:" -msgstr "Grid Offset X:" +msgstr "Desplazamiento de Cuadrícula en X:" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Grid Offset Y:" -msgstr "Grid Offset Y:" +msgstr "Desplazamiento de Cuadrícula en Y:" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Grid Step X:" -msgstr "Grid Step X:" +msgstr "Paso de Cuadrícula en X:" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Grid Step Y:" -msgstr "Grid Step Y:" +msgstr "Paso de Cuadrícula en Y:" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Sync Bones to Polygon" @@ -7768,7 +7778,7 @@ msgstr "Ver Origen" #: editor/plugins/spatial_editor_plugin.cpp msgid "View Grid" -msgstr "Ver Grid" +msgstr "Ver Cuadrícula" #: editor/plugins/spatial_editor_plugin.cpp #: modules/gridmap/grid_map_editor_plugin.cpp @@ -7777,19 +7787,19 @@ msgstr "Configuración..." #: editor/plugins/spatial_editor_plugin.cpp msgid "Snap Settings" -msgstr "Ajustes de Snap" +msgstr "Configuración de Ajuste" #: editor/plugins/spatial_editor_plugin.cpp msgid "Translate Snap:" -msgstr "Snap de Traslación:" +msgstr "Ajuste de Traslación:" #: editor/plugins/spatial_editor_plugin.cpp msgid "Rotate Snap (deg.):" -msgstr "Snap de Rotación (grados):" +msgstr "Ajuste de Rotación (grados):" #: editor/plugins/spatial_editor_plugin.cpp msgid "Scale Snap (%):" -msgstr "Snap de Escala (%):" +msgstr "Ajuste de Escala (%):" #: editor/plugins/spatial_editor_plugin.cpp msgid "Viewport Settings" @@ -8058,7 +8068,7 @@ msgstr "Asignar Margen" #: editor/plugins/texture_region_editor_plugin.cpp msgid "Snap Mode:" -msgstr "Modo Snap:" +msgstr "Modo de Ajuste:" #: editor/plugins/texture_region_editor_plugin.cpp #: scene/resources/visual_shader.cpp @@ -8067,11 +8077,11 @@ msgstr "Ninguno" #: editor/plugins/texture_region_editor_plugin.cpp msgid "Pixel Snap" -msgstr "Pixel Snap" +msgstr "Ajuste de Píxeles" #: editor/plugins/texture_region_editor_plugin.cpp msgid "Grid Snap" -msgstr "Grid Snap" +msgstr "Ajuste de Cuadrícula" #: editor/plugins/texture_region_editor_plugin.cpp msgid "Auto Slice" @@ -8489,7 +8499,8 @@ msgstr "Mantener el polígono dentro del region Rect." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Enable snap and show grid (configurable via the Inspector)." -msgstr "Activar snap y mostrar grid (configurable a través del Inspector)." +msgstr "" +"Activar ajuste y mostrar cuadrícula (configurable a través del Inspector)." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Display Tile Names (Hold Alt Key)" @@ -9680,7 +9691,7 @@ msgid "" msgstr "" "No se pudo exportar el proyecto para la plataforma '%s'.\n" "Esto puede ser debido a un problema de configuración en el preset de " -"exportación o en los ajustes de exportación." +"exportación o en la configuración de exportación." #: editor/project_export.cpp msgid "Release" @@ -10070,8 +10081,8 @@ msgid "" "the \"Application\" category." msgstr "" "No se puede ejecutar el proyecto: no hay una escena principal definida.\n" -"Por favor, edita el proyecto y configura la escena principal en los Ajustes " -"del proyecto, en la categoría \"Application\"." +"Por favor, edita el proyecto y configura la escena principal en " +"Configuración del Proyecto, en la categoría \"Application\"." #: editor/project_manager.cpp msgid "" @@ -10137,9 +10148,8 @@ msgid "Projects" msgstr "Proyectos" #: editor/project_manager.cpp -#, fuzzy msgid "Loading, please wait..." -msgstr "Obteniendo mirrors, por favor espera..." +msgstr "Cargando, espera por favor..." #: editor/project_manager.cpp msgid "Last Modified" @@ -10418,7 +10428,7 @@ msgstr "Cambiar Modo de Filtro Local" #: editor/project_settings_editor.cpp msgid "Project Settings (project.godot)" -msgstr "Ajustes del Proyecto (project.godot)" +msgstr "Configuración del Proyecto (project.godot)" #: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp msgid "General" @@ -10512,6 +10522,11 @@ msgstr "AutoLoad" msgid "Plugins" msgstr "Plugins" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Cargar Valores por Defecto" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Preset..." @@ -10762,14 +10777,12 @@ msgid "Instance Child Scene" msgstr "Instanciar Escena Hija" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "¡No se puede operar sobre los nodos de una escena externa!" +msgstr "No se puede pegar el nodo raíz en la misma escena." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Pegar Nodos" +msgstr "Pegar Nodo(s)" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10899,9 +10912,8 @@ msgid "Attach Script" msgstr "Añadir Script" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Cortar Nodos" +msgstr "Cortar Nodos(s)" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -11612,7 +11624,7 @@ msgstr "Plano:" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "GridMap Delete Selection" -msgstr "GridMap Eliminar Seleccionados" +msgstr "Eliminar Selección de GridMap" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "GridMap Fill Selection" @@ -11620,7 +11632,7 @@ msgstr "Rellenar Selección en GridMap" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "GridMap Paste Selection" -msgstr "Pegar lo Seleccionado en GridMap" +msgstr "Pegar Selección en GridMap" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "GridMap Paint" @@ -11628,7 +11640,7 @@ msgstr "Pintar GridMap" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "Grid Map" -msgstr "Grid Map" +msgstr "Mapeo de Cuadrícula" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "Snap View" @@ -11765,7 +11777,7 @@ msgstr "Estableciendo la configuración..." #: modules/recast/navigation_mesh_generator.cpp msgid "Calculating grid size..." -msgstr "Calculando tamaño de grid..." +msgstr "Calculando tamaño la cuadrícula..." #: modules/recast/navigation_mesh_generator.cpp msgid "Creating heightfield..." @@ -12590,6 +12602,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Un CollisionPolygon2D vacío no tiene ningún efecto en las colisiones." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12910,11 +12930,6 @@ msgstr "" "Las GIProbes no están soportadas por el controlador de vídeo GLES2.\n" "Usa un BakedLightmap en su lugar." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera ha sido desaprobado y será eliminado en Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13206,7 +13221,7 @@ msgid "" "Default Environment as specified in Project Settings (Rendering -> " "Environment -> Default Environment) could not be loaded." msgstr "" -"El Entorno por Defecto como se especifica en los Ajustes del Proyecto " +"El Entorno por Defecto como se especifica en Configuración del Proyecto " "(Rendering -> Environment -> Default Environment) no se ha podido cargar." #: scene/main/viewport.cpp @@ -13264,6 +13279,11 @@ msgstr "Solo se pueden asignar variaciones en funciones de vértice." msgid "Constants cannot be modified." msgstr "Las constantes no pueden modificarse." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "InterpolatedCamera ha sido desaprobado y será eliminado en Godot 4.0." + #~ msgid "No" #~ msgstr "No" @@ -15148,9 +15168,6 @@ msgstr "Las constantes no pueden modificarse." #~ msgid "Use Default Light" #~ msgstr "Usar iluminación predeterminada" -#~ msgid "Use Default sRGB" -#~ msgstr "Usar sRGB predeterminado" - #~ msgid "Default Light Normal:" #~ msgstr "Iluminación por normales predeterminada:" diff --git a/editor/translations/es_AR.po b/editor/translations/es_AR.po index a95f85e753..5f9231e891 100644 --- a/editor/translations/es_AR.po +++ b/editor/translations/es_AR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:50+0000\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" "Last-Translator: Lisandro Lorea <lisandrolorea@gmail.com>\n" "Language-Team: Spanish (Argentina) <https://hosted.weblate.org/projects/" "godot-engine/godot/es_AR/>\n" @@ -1876,8 +1876,8 @@ msgid "Open a File or Directory" msgstr "Abrir un Archivo o Directorio" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Guardar" @@ -2556,11 +2556,8 @@ msgstr "" "configuración." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "" -"No se pudo encontrar el campo script para el plugin de addon en: 'res://" -"addons/%s'." +msgstr "No se pudo encontrar el campo script para el plugin de addon en: '%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4098,6 +4095,21 @@ msgstr "¿Devolviste un objeto derivado de Node en el método `post_import()`?" msgid "Saving..." msgstr "Guardando..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Modo Seleccionar" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importar" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Usar sRGB por Defecto" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Archivos" @@ -5071,9 +5083,8 @@ msgid "Got:" msgstr "Recibido:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Fallo el chequeo del hash sha256" +msgstr "Fallo el chequeo del hash SHA-256" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5176,7 +5187,6 @@ msgid "Sort:" msgstr "Ordenar:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoría:" @@ -10456,6 +10466,11 @@ msgstr "AutoLoad" msgid "Plugins" msgstr "Plugins" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Cargar Valores por Defecto" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Preseteo..." @@ -10706,14 +10721,12 @@ msgid "Instance Child Scene" msgstr "Instanciar Escena Hija" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "No se puede operar sobre los nodos de una escena externa!" +msgstr "No se puede pegar el nodo raiz en la misma escena." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Pegar Nodos" +msgstr "Pegar Nodo(s)" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10844,9 +10857,8 @@ msgid "Attach Script" msgstr "Adjuntar Script" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Cortar Nodos" +msgstr "Cortar Nodo(s)" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -12525,6 +12537,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Un CollisionPolygon2D vacío no tiene efecto en la colisión." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12845,11 +12865,6 @@ msgstr "" "Las GIProbes no están soportadas por el controlador de video GLES2.\n" "Usá un BakedLightmap en su lugar." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera ha sido deprecado y será eliminado en Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13194,6 +13209,10 @@ msgstr "Solo se pueden asignar variaciones en funciones de vértice." msgid "Constants cannot be modified." msgstr "Las constantes no pueden modificarse." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera ha sido deprecado y será eliminado en Godot 4.0." + #~ msgid "No" #~ msgstr "No" @@ -14862,9 +14881,6 @@ msgstr "Las constantes no pueden modificarse." #~ msgid "Use Default Light" #~ msgstr "Usar Luz por Defecto" -#~ msgid "Use Default sRGB" -#~ msgstr "Usar sRGB por Defecto" - #~ msgid "Default Light Normal:" #~ msgstr "Normales de Luces por Defecto:" diff --git a/editor/translations/et.po b/editor/translations/et.po index e6f2c1aac4..ba7272db84 100644 --- a/editor/translations/et.po +++ b/editor/translations/et.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" -"PO-Revision-Date: 2021-02-05 09:20+0000\n" +"PO-Revision-Date: 2021-03-07 06:04+0000\n" "Last-Translator: Kritzmensch <streef.gtx@gmail.com>\n" "Language-Team: Estonian <https://hosted.weblate.org/projects/godot-engine/" "godot/et/>\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8-bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.5-dev\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -697,7 +697,7 @@ msgstr "" #: editor/code_editor.cpp msgid "Replace" -msgstr "" +msgstr "Asenda" #: editor/code_editor.cpp msgid "Replace All" @@ -814,7 +814,7 @@ msgstr "" #: editor/connections_dialog.cpp msgid "Oneshot" -msgstr "" +msgstr "Ainulaadne" #: editor/connections_dialog.cpp msgid "Disconnects the signal after its first emission." @@ -840,7 +840,7 @@ msgstr "Sulge" #: editor/connections_dialog.cpp msgid "Connect" -msgstr "" +msgstr "Ühenda" #: editor/connections_dialog.cpp msgid "Signal:" @@ -860,12 +860,12 @@ msgstr "" #: editor/connections_dialog.cpp msgid "Connect..." -msgstr "" +msgstr "Ühenda..." #: editor/connections_dialog.cpp #: editor/plugins/animation_tree_player_editor_plugin.cpp msgid "Disconnect" -msgstr "" +msgstr "Katkesta ühendus" #: editor/connections_dialog.cpp msgid "Connect a Signal to a Method" @@ -898,7 +898,7 @@ msgstr "" #: editor/connections_dialog.cpp msgid "Edit..." -msgstr "" +msgstr "Muuda..." #: editor/connections_dialog.cpp msgid "Go To Method" @@ -910,7 +910,7 @@ msgstr "" #: editor/create_dialog.cpp editor/project_settings_editor.cpp msgid "Change" -msgstr "" +msgstr "Muuda" #: editor/create_dialog.cpp msgid "Create New %s" @@ -968,20 +968,20 @@ msgstr "" #: editor/dependency_editor.cpp #: modules/gdnative/gdnative_library_editor_plugin.cpp msgid "Dependencies" -msgstr "" +msgstr "Sõltuvused" #: editor/dependency_editor.cpp msgid "Resource" -msgstr "" +msgstr "Ressurss" #: editor/dependency_editor.cpp editor/editor_autoload_settings.cpp #: editor/project_manager.cpp editor/project_settings_editor.cpp msgid "Path" -msgstr "" +msgstr "Tee" #: editor/dependency_editor.cpp msgid "Dependencies:" -msgstr "" +msgstr "Sõltuvused:" #: editor/dependency_editor.cpp msgid "Fix Broken" @@ -1213,7 +1213,7 @@ msgstr "" #: editor/editor_asset_installer.cpp #: editor/plugins/asset_library_editor_plugin.cpp msgid "Success!" -msgstr "" +msgstr "Õnnestus!" #: editor/editor_asset_installer.cpp msgid "Package Contents:" @@ -1221,7 +1221,7 @@ msgstr "" #: editor/editor_asset_installer.cpp editor/editor_node.cpp msgid "Install" -msgstr "" +msgstr "Paigalda" #: editor/editor_asset_installer.cpp msgid "Package Installer" @@ -1285,7 +1285,7 @@ msgstr "Vaigista" #: editor/editor_audio_buses.cpp msgid "Bypass" -msgstr "" +msgstr "Jäta vahele" #: editor/editor_audio_buses.cpp msgid "Bus options" @@ -1306,7 +1306,7 @@ msgstr "" #: editor/editor_audio_buses.cpp msgid "Audio" -msgstr "" +msgstr "Heli" #: editor/editor_audio_buses.cpp msgid "Add Audio Bus" @@ -1830,8 +1830,8 @@ msgid "Open a File or Directory" msgstr "Ava kaust või kataloog" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Salvesta" @@ -2171,7 +2171,7 @@ msgstr "Imporditud ressursse ei saa salvestada." #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: scene/gui/dialogs.cpp msgid "OK" -msgstr "" +msgstr "Olgu" #: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp msgid "Error saving resource!" @@ -2427,7 +2427,7 @@ msgstr "Välju" #: editor/editor_node.cpp msgid "Yes" -msgstr "" +msgstr "Jah" #: editor/editor_node.cpp msgid "Exit the editor?" @@ -3048,7 +3048,7 @@ msgstr "Laadimisvead" #: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp msgid "Select" -msgstr "" +msgstr "Vali" #: editor/editor_node.cpp msgid "Open 2D Editor" @@ -3088,7 +3088,7 @@ msgstr "" #: editor/editor_plugin.cpp msgid "Thumbnail..." -msgstr "" +msgstr "Pisipilt..." #: editor/editor_plugin_settings.cpp msgid "Main Script:" @@ -3145,7 +3145,7 @@ msgstr "" #: editor/editor_profiler.cpp msgid "Inclusive" -msgstr "" +msgstr "Kaasav" #: editor/editor_profiler.cpp msgid "Self" @@ -3169,11 +3169,11 @@ msgstr "" #: editor/editor_properties.cpp editor/script_create_dialog.cpp msgid "On" -msgstr "" +msgstr "Sees" #: editor/editor_properties.cpp msgid "Layer" -msgstr "" +msgstr "Kiht" #: editor/editor_properties.cpp msgid "Bit %d, value %d" @@ -3181,11 +3181,11 @@ msgstr "" #: editor/editor_properties.cpp msgid "[Empty]" -msgstr "" +msgstr "[Tühi]" #: editor/editor_properties.cpp editor/plugins/root_motion_editor_plugin.cpp msgid "Assign..." -msgstr "" +msgstr "Määra..." #: editor/editor_properties.cpp msgid "Invalid RID" @@ -3243,7 +3243,7 @@ msgstr "" #: editor/plugins/tile_map_editor_plugin.cpp editor/property_editor.cpp #: editor/scene_tree_dock.cpp scene/gui/line_edit.cpp scene/gui/text_edit.cpp msgid "Paste" -msgstr "" +msgstr "Kleebi" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "Convert To %s" @@ -3255,7 +3255,7 @@ msgstr "" #: editor/editor_properties_array_dict.cpp msgid "Size: " -msgstr "" +msgstr "Suurus: " #: editor/editor_properties_array_dict.cpp msgid "Page: " @@ -3339,7 +3339,7 @@ msgstr "" #: editor/export_template_manager.cpp msgid "(Installed)" -msgstr "" +msgstr "(Paigaldatud)" #: editor/export_template_manager.cpp #: editor/plugins/asset_library_editor_plugin.cpp @@ -3352,11 +3352,11 @@ msgstr "" #: editor/export_template_manager.cpp msgid "(Missing)" -msgstr "" +msgstr "(Puudub)" #: editor/export_template_manager.cpp msgid "(Current)" -msgstr "" +msgstr "(Praegune)" #: editor/export_template_manager.cpp msgid "Retrieving mirrors, please wait..." @@ -3477,7 +3477,7 @@ msgstr "" #: editor/export_template_manager.cpp msgid "Connected" -msgstr "" +msgstr "Ühendatud" #: editor/export_template_manager.cpp #: editor/plugins/asset_library_editor_plugin.cpp @@ -3538,7 +3538,7 @@ msgstr "" #: editor/filesystem_dock.cpp msgid "Favorites" -msgstr "" +msgstr "Lemmikud" #: editor/filesystem_dock.cpp msgid "Status: Import of file failed. Please fix file and reimport manually." @@ -3922,6 +3922,21 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Valimisrežiim" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Impordi" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Laadi vaikimisi" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4973,7 +4988,6 @@ msgid "Sort:" msgstr "Sordi:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategooria:" @@ -10010,6 +10024,11 @@ msgstr "" msgid "Plugins" msgstr "Pistikprogrammid" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Laadi vaikimisi" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11345,7 +11364,7 @@ msgstr "" #: modules/visual_script/visual_script_editor.cpp msgid "Signals:" -msgstr "" +msgstr "Signaalid:" #: modules/visual_script/visual_script_editor.cpp msgid "Create a new signal." @@ -11963,6 +11982,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12219,11 +12246,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -12421,7 +12443,7 @@ msgstr "" #: scene/gui/dialogs.cpp msgid "Alert!" -msgstr "" +msgstr "Tähelepanu!" #: scene/gui/dialogs.cpp msgid "Please Confirm..." @@ -12455,7 +12477,7 @@ msgstr "" #: scene/gui/tree.cpp msgid "(Other)" -msgstr "" +msgstr "(Muu)" #: scene/main/scene_tree.cpp msgid "" diff --git a/editor/translations/eu.po b/editor/translations/eu.po index ef200e15d6..95e87167e5 100644 --- a/editor/translations/eu.po +++ b/editor/translations/eu.po @@ -1804,8 +1804,8 @@ msgid "Open a File or Directory" msgstr "Ireki fitxategia edo direktorioa" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Gorde" @@ -3886,6 +3886,20 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Hautatu inportatu nahi dituzun nodoak" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Inportatu azala" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d fitxategi" @@ -4939,7 +4953,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9977,6 +9990,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Inportatu profila(k)" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11930,6 +11948,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12185,11 +12211,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/fa.po b/editor/translations/fa.po index 29d3139e9c..910212f856 100644 --- a/editor/translations/fa.po +++ b/editor/translations/fa.po @@ -1846,8 +1846,8 @@ msgid "Open a File or Directory" msgstr "یک پرونده یا پوشه را باز کن" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "ذخیره" @@ -4001,6 +4001,21 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "انتخاب حالت" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "وارد کردن" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "بارگیری پیش فرض" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5125,7 +5140,6 @@ msgid "Sort:" msgstr "مرتبسازی:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "طبقهبندی:" @@ -10454,6 +10468,11 @@ msgstr "AutoLoad" msgid "Plugins" msgstr "افزونهها" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "بارگیری پیش فرض" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12569,6 +12588,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "یک CollisionPolygon2D خالی جلوه بر برخورد ندارد." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12859,11 +12886,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/fi.po b/editor/translations/fi.po index 16daaed9b0..36e6c631be 100644 --- a/editor/translations/fi.po +++ b/editor/translations/fi.po @@ -15,7 +15,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" "Last-Translator: Tapani Niemi <tapani.niemi@kapsi.fi>\n" "Language-Team: Finnish <https://hosted.weblate.org/projects/godot-engine/" "godot/fi/>\n" @@ -1857,8 +1857,8 @@ msgid "Open a File or Directory" msgstr "Avaa tiedosto tai hakemisto" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Tallenna" @@ -2530,9 +2530,8 @@ msgid "Unable to enable addon plugin at: '%s' parsing of config failed." msgstr "Lisäosan '%s' aktivointi epäonnistui, virheellinen asetustiedosto." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "Skriptikenttää ei löytynyt lisäosan tiedostosta: 'res://addons/%s'." +msgstr "Skriptikenttää ei löytynyt lisäosan tiedostosta: '%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4056,6 +4055,21 @@ msgstr "" msgid "Saving..." msgstr "Tallennetaan..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Valintatila" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Tuonti" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Lataa oletus" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d tiedostoa" @@ -5025,9 +5039,8 @@ msgid "Got:" msgstr "Saatiin:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "sha256-hajautusarvon tarkistus epäonnistui" +msgstr "SHA-256 hajautusarvon tarkistus epäonnistui" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5130,7 +5143,6 @@ msgid "Sort:" msgstr "Lajittele:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategoria:" @@ -10396,6 +10408,11 @@ msgstr "Automaattilataus" msgid "Plugins" msgstr "Liitännäiset" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Lataa oletus" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Esiasetus..." @@ -10645,14 +10662,12 @@ msgid "Instance Child Scene" msgstr "Luo aliskenen ilmentymä" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "Ei voida suorittaa ulkopuolisen skenen solmuille!" +msgstr "Juurisolmua ei voida liittää samaan skeneen." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Liitä solmut" +msgstr "Liitä solmu(t)" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10784,9 +10799,8 @@ msgid "Attach Script" msgstr "Liitä skripti" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Leikkaa solmut" +msgstr "Leikkaa solmu(t)" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -12449,6 +12463,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Tyhjällä CollisionPolygon2D solmulla ei ole vaikutusta törmäyksessä." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12767,11 +12789,6 @@ msgstr "" "GIProbe ei ole tuettu GLES2 näyttöajurissa.\n" "Käytä sen sijaan BakedLightmap resurssia." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera on vanhentunut ja poistetaan Godot 4.0 versiossa." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13115,6 +13132,11 @@ msgstr "Varying tyypin voi sijoittaa vain vertex-funktiossa." msgid "Constants cannot be modified." msgstr "Vakioita ei voi muokata." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "InterpolatedCamera on vanhentunut ja poistetaan Godot 4.0 versiossa." + #~ msgid "No" #~ msgstr "Ei" diff --git a/editor/translations/fil.po b/editor/translations/fil.po index dc84dd744f..e9c24cf0f2 100644 --- a/editor/translations/fil.po +++ b/editor/translations/fil.po @@ -1804,8 +1804,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3884,6 +3884,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4936,7 +4948,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9972,6 +9983,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11928,6 +11943,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12183,11 +12206,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/fr.po b/editor/translations/fr.po index 44002bf560..7b9d411e6d 100644 --- a/editor/translations/fr.po +++ b/editor/translations/fr.po @@ -1938,8 +1938,8 @@ msgid "Open a File or Directory" msgstr "Ouvrir un fichier ou un répertoire" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Enregistrer" @@ -2624,8 +2624,7 @@ msgstr "" #: editor/editor_node.cpp msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "" -"Impossible de trouver le champ de script pour le plugin dans : « %s »." +msgstr "Impossible de trouver le champ de script pour le plugin dans : « %s »." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4168,17 +4167,29 @@ msgstr "" msgid "Saving..." msgstr "Enregistrement…" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "Sélectionnez un importeur" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "Importeur :" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "Réinitialiser" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d fichiers" #: editor/import_dock.cpp msgid "Set as Default for '%s'" -msgstr "Définir comme défaut pour « %s »" +msgstr "Définir comme préréglage pour « %s »" #: editor/import_dock.cpp msgid "Clear Default for '%s'" -msgstr "Effacer le préréglage par défaut pour « %s »" +msgstr "Effacer le préréglage pour « %s »" #: editor/import_dock.cpp msgid "Import As:" @@ -4186,7 +4197,7 @@ msgstr "Importer comme :" #: editor/import_dock.cpp msgid "Preset" -msgstr "Pré-réglage" +msgstr "Préréglage" #: editor/import_dock.cpp msgid "Reimport" @@ -5247,7 +5258,6 @@ msgid "Sort:" msgstr "Trier :" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Catégorie :" @@ -6030,7 +6040,7 @@ msgstr "Modifier la tangente de courbes" #: editor/plugins/curve_editor_plugin.cpp msgid "Load Curve Preset" -msgstr "Charger un pré-réglage de courbe" +msgstr "Charger un préréglage de courbe" #: editor/plugins/curve_editor_plugin.cpp msgid "Add Point" @@ -9700,7 +9710,7 @@ msgstr "Exécutable" #: editor/project_export.cpp msgid "Delete preset '%s'?" -msgstr "Supprimer le pré-réglage « %s » ?" +msgstr "Supprimer le préréglage « %s » ?" #: editor/project_export.cpp msgid "" @@ -9738,7 +9748,7 @@ msgstr "Modèles d'exportation manquants ou corrompus pour cette plateforme :" #: editor/project_export.cpp msgid "Presets" -msgstr "Pré-réglages" +msgstr "Préréglages" #: editor/project_export.cpp editor/project_settings_editor.cpp msgid "Add..." @@ -9749,9 +9759,9 @@ msgid "" "If checked, the preset will be available for use in one-click deploy.\n" "Only one preset per platform may be marked as runnable." msgstr "" -"Si cette option est activée, le pré-réglage sera disponible pour le " +"Si cette option est activée, le préréglage sera disponible pour le " "déploiement en un clic.\n" -"Un seul pré-réglage par plateforme peut être marqué comme exécutable." +"Un seul préréglage par plateforme peut être marqué comme exécutable." #: editor/project_export.cpp msgid "Export Path" @@ -10551,9 +10561,13 @@ msgstr "AutoLoad" msgid "Plugins" msgstr "Extensions" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "Préréglage des importeurs" + #: editor/property_editor.cpp msgid "Preset..." -msgstr "Pré-réglage…" +msgstr "Préréglage…" #: editor/property_editor.cpp msgid "Zero" @@ -12631,6 +12645,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Un CollisionPolygon2D vide n'a pas d'effet sur les collisions." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12955,11 +12977,6 @@ msgstr "" "Les GIProps ne sont pas supporter par le pilote de vidéos GLES2.\n" "A la place utilisez une BakedLightMap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera a été déprécié et sera supprimé dans Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13163,7 +13180,7 @@ msgid "" msgstr "" "Couleur : #%s\n" "Clic gauche : Définir la couleur\n" -"Clic droit : Supprimer le pré-réglage" +"Clic droit : Supprimer le préréglage" #: scene/gui/color_picker.cpp msgid "Pick a color from the editor window." @@ -13183,7 +13200,7 @@ msgstr "Alterner entre les valeurs hexadécimales ou brutes." #: scene/gui/color_picker.cpp msgid "Add current color as a preset." -msgstr "Ajouter la couleur courante comme pré-réglage." +msgstr "Ajouter la couleur courante comme préréglage." #: scene/gui/container.cpp msgid "" @@ -13313,6 +13330,10 @@ msgstr "Les variations ne peuvent être affectées que dans la fonction vertex." msgid "Constants cannot be modified." msgstr "Les constantes ne peuvent être modifiées." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera a été déprécié et sera supprimé dans Godot 4.0." + #~ msgid "No" #~ msgstr "Non" diff --git a/editor/translations/ga.po b/editor/translations/ga.po index 6bddf1e53c..4e537d9882 100644 --- a/editor/translations/ga.po +++ b/editor/translations/ga.po @@ -1798,8 +1798,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3879,6 +3879,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -4933,7 +4945,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9967,6 +9978,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11923,6 +11938,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12178,11 +12201,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/gl.po b/editor/translations/gl.po index 323fc16ec4..5559444f0c 100644 --- a/editor/translations/gl.po +++ b/editor/translations/gl.po @@ -1852,8 +1852,8 @@ msgid "Open a File or Directory" msgstr "Abrir un Arquivo ou Directorio" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Gardar" @@ -4044,6 +4044,21 @@ msgstr "" msgid "Saving..." msgstr "Gardando..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Elixir Modo" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importación" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Cargar Valores por Defecto" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Arquivos" @@ -5101,7 +5116,6 @@ msgid "Sort:" msgstr "Ordenar:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoría:" @@ -10264,6 +10278,11 @@ msgstr "AutoCargador" msgid "Plugins" msgstr "Características Adicionais (Plugins)" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Cargar Valores por Defecto" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12236,6 +12255,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12521,11 +12548,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/he.po b/editor/translations/he.po index 7b3e8815ec..ab97d97c0a 100644 --- a/editor/translations/he.po +++ b/editor/translations/he.po @@ -1871,8 +1871,8 @@ msgid "Open a File or Directory" msgstr "פתיחת קובץ או תיקייה" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "שמירה" @@ -4055,6 +4055,21 @@ msgstr "" msgid "Saving..." msgstr "שמירה…" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "נא לבחור מפרקים לייצוא" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "ייבוא" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "טעינת בררת המחדל" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d קבצים" @@ -5143,7 +5158,6 @@ msgid "Sort:" msgstr "מיון:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "קטגוריה:" @@ -10439,6 +10453,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "טעינת בררת המחדל" + #: editor/property_editor.cpp msgid "Preset..." msgstr "ערכה מוגדרת…" @@ -12470,6 +12489,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "ל־CollisionPolygon2D ריק אין השפעה על התנגשות." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12767,11 +12794,6 @@ msgstr "" "מנהל הווידאו GLES2 אינו תומך ב- GIProbes.\n" "השתמש ב-BakedLightmap במקום." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight עם זווית רחבה מ-90 מעלות אינו יכול להטיל צללים." diff --git a/editor/translations/hi.po b/editor/translations/hi.po index a4d46d6147..034451542b 100644 --- a/editor/translations/hi.po +++ b/editor/translations/hi.po @@ -1852,8 +1852,8 @@ msgid "Open a File or Directory" msgstr "फ़ाइल या डायरेक्टरी खोलिये" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "सेव कीजिये" @@ -4035,6 +4035,21 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "आयात करने के लिए नोड (एस) का चयन करें" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "इंपोर्ट" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "प्रायिक लोड कीजिये" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -5086,7 +5101,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10214,6 +10228,11 @@ msgstr "" msgid "Plugins" msgstr "प्लगइन्स" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "प्रायिक लोड कीजिये" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12217,6 +12236,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12474,11 +12501,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/hr.po b/editor/translations/hr.po index 4803018028..047363db63 100644 --- a/editor/translations/hr.po +++ b/editor/translations/hr.po @@ -1812,8 +1812,8 @@ msgid "Open a File or Directory" msgstr "Otvori datoteku ili direktorij" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Spremi" @@ -3893,6 +3893,21 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Odaberi Sve/Ništa" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Uvoz" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Učitaj Zadano" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Fajlovi" @@ -4944,7 +4959,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9985,6 +9999,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Učitaj Zadano" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11944,6 +11963,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12199,11 +12226,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/hu.po b/editor/translations/hu.po index db3403fdf1..3966959f91 100644 --- a/editor/translations/hu.po +++ b/editor/translations/hu.po @@ -1855,8 +1855,8 @@ msgid "Open a File or Directory" msgstr "Fájl vagy Könyvtár Megnyitása" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Mentés" @@ -4047,6 +4047,21 @@ msgstr "" msgid "Saving..." msgstr "Mentés..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Kiválasztó Mód" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importálás" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Alapértelmezett Betöltése" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d fájl" @@ -5110,7 +5125,6 @@ msgid "Sort:" msgstr "Rendezés:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategória:" @@ -10215,6 +10229,11 @@ msgstr "" msgid "Plugins" msgstr "Bővítmények" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Alapértelmezett Betöltése" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Beépített Beállítások..." @@ -12187,6 +12206,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12447,11 +12474,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/id.po b/editor/translations/id.po index 91e4392ab4..5dc5b9751a 100644 --- a/editor/translations/id.po +++ b/editor/translations/id.po @@ -28,12 +28,13 @@ # Richard Urban <redasuio1@gmail.com>, 2020. # yusuf afandi <afandi.yusuf.04@gmail.com>, 2020. # Habib Rohman <revolusi147id@gmail.com>, 2020. +# Hanz <hanzhaxors@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-11-13 22:59+0000\n" -"Last-Translator: Habib Rohman <revolusi147id@gmail.com>\n" +"PO-Revision-Date: 2021-03-08 15:33+0000\n" +"Last-Translator: Hanz <hanzhaxors@gmail.com>\n" "Language-Team: Indonesian <https://hosted.weblate.org/projects/godot-engine/" "godot/id/>\n" "Language: id\n" @@ -41,7 +42,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.4-dev\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -57,7 +58,8 @@ msgstr "String dengan panjang 1 (karakter) yang diharapkan." #: modules/mono/glue/gd_glue.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp msgid "Not enough bytes for decoding bytes, or invalid format." -msgstr "Tidak cukup bytes untuk mendekode bytes, atau format tidak valid." +msgstr "" +"Tidak cukup bytes untuk merubah bytes ke nilai asal, atau format tidak valid." #: core/math/expression.cpp msgid "Invalid input %i (not passed) in expression" @@ -65,8 +67,7 @@ msgstr "Masukkan tidak sah %i (tidak diberikan) dalam ekspresi" #: core/math/expression.cpp msgid "self can't be used because instance is null (not passed)" -msgstr "" -"self tidak dapat digunakan karena tidak memiliki instance (tidak lolos)" +msgstr "self tidak dapat digunakan karena instance adalah null" #: core/math/expression.cpp msgid "Invalid operands to operator %s, %s and %s." @@ -74,7 +75,7 @@ msgstr "operan salah untuk operator %s, %s dan %s." #: core/math/expression.cpp msgid "Invalid index of type %s for base type %s" -msgstr "Tipe index %s tidak valid untuk tipe dasar %s" +msgstr "Tipe indeks %s tidak valid untuk tipe dasar %s" #: core/math/expression.cpp msgid "Invalid named index '%s' for base type %s" @@ -1052,14 +1053,14 @@ msgid "Owners Of:" msgstr "Pemilik Dari:" #: editor/dependency_editor.cpp -#, fuzzy msgid "" "Remove selected files from the project? (no undo)\n" "You can find the removed files in the system trash to restore them." -msgstr "Hapus berkas yang dipilih dari proyek? (tidak bisa dibatalkan)" +msgstr "" +"Hapus berkas yang dipilih dari proyek? (tidak bisa dibatalkan)\n" +"Anda bisa menemukan berkas yang telah dihapus di tong sampah." #: editor/dependency_editor.cpp -#, fuzzy msgid "" "The files being removed are required by other resources in order for them to " "work.\n" @@ -1068,7 +1069,8 @@ msgid "" msgstr "" "File-file yang telah dihapus diperlukan oleh resource lain agar mereka dapat " "bekerja.\n" -"Hapus saja? (tidak bisa dibatalkan/undo)" +"Hapus saja? (tidak bisa dibatalkan)\n" +"Anda bisa menemukan berkas yang telah dihapus di tong sampah." #: editor/dependency_editor.cpp msgid "Cannot remove:" @@ -1621,34 +1623,31 @@ msgstr "" "Enabled'." #: editor/editor_export.cpp -#, fuzzy msgid "" "Target platform requires 'PVRTC' texture compression for GLES2. Enable " "'Import Pvrtc' in Project Settings." msgstr "" -"Platform target membutuhkan kompresi tekstur 'ETC' untuk GLES2. Aktifkan " -"'Impor Lainnya' di Pengaturan Proyek." +"Platform target membutuhkan kompresi tekstur 'PVRTC' untuk GLES2. Aktifkan " +"'Impor Pvrtc' di Pengaturan Proyek." #: editor/editor_export.cpp -#, fuzzy msgid "" "Target platform requires 'ETC2' or 'PVRTC' texture compression for GLES3. " "Enable 'Import Etc 2' or 'Import Pvrtc' in Project Settings." msgstr "" -"Platform target membutuhkan kompresi tekstur 'ETC2' untuk GLES3. Aktifkan " -"'Impor Lainnya 2' di Pengaturan Proyek." +"Platform target membutuhkan kompresi tekstur 'ETC2' atau 'PVRTC' untuk " +"GLES3. Aktifkan 'Impor Lainnya 2' atau 'Import Pvrtc' di Pengaturan Proyek." #: editor/editor_export.cpp -#, fuzzy msgid "" "Target platform requires 'PVRTC' texture compression for the driver fallback " "to GLES2.\n" "Enable 'Import Pvrtc' in Project Settings, or disable 'Driver Fallback " "Enabled'." msgstr "" -"Platform target membutuhkan kompressi tekstur 'ETC' untuk mengembalikan " +"Platform target membutuhkan kompressi tekstur 'PVRTC' untuk mengembalikan " "driver ke GLES2. \n" -"Aktifkan 'Impor Lainnya' di Pengaturan Proyek, atau matikan 'Driver Fallback " +"Aktifkan 'Impor Pvrtc' di Pengaturan Proyek, atau matikan 'Driver Fallback " "Enabled'." #: editor/editor_export.cpp platform/android/export/export.cpp @@ -1877,8 +1876,8 @@ msgid "Open a File or Directory" msgstr "Buka sebuah File atau Direktori" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Simpan" @@ -2330,6 +2329,8 @@ msgid "" "An error occurred while trying to save the editor layout.\n" "Make sure the editor's user data path is writable." msgstr "" +"Terjadi kesalahan ketika mencoba menyimpan layout editor.\n" +"Pastikan jalur data pengguna editor dapat ditulis." #: editor/editor_node.cpp msgid "" @@ -2337,13 +2338,15 @@ msgid "" "To restore the Default layout to its base settings, use the Delete Layout " "option and delete the Default layout." msgstr "" +"Penataan editor default telah dirubah.\n" +"Untuk mengembalikan penataan editor default ke asalnya, gunakan opsi Hapus " +"Penataan dan hapus Penataan Default." #: editor/editor_node.cpp msgid "Layout name not found!" msgstr "Nama layout tidak ditemukan!" #: editor/editor_node.cpp -#, fuzzy msgid "Restored the Default layout to its base settings." msgstr "Mengembalikan semula layout default ke pengaturan-pengaturan awal." @@ -2402,7 +2405,7 @@ msgstr "Tidak ada skena yang didefinisikan untuk dijalankan." #: editor/editor_node.cpp msgid "Save scene before running..." -msgstr "" +msgstr "Simpan skena sebelum menjalankan..." #: editor/editor_node.cpp msgid "Could not start subprocess!" @@ -2481,7 +2484,6 @@ msgid "Reload Saved Scene" msgstr "Muat ulang scene yang sudah disimpan" #: editor/editor_node.cpp -#, fuzzy msgid "" "The current scene has unsaved changes.\n" "Reload the saved scene anyway? This action cannot be undone." @@ -2548,10 +2550,9 @@ msgstr "" "gagal." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." msgstr "" -"Tidak dapat mencari bidang script untuk addon plugin pada: 'res://addons/%s'." +"Tidak dapat mencari bidang skrip untuk addon plugin pada: 'res://addons/%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -2855,12 +2856,10 @@ msgstr "" "lokal." #: editor/editor_node.cpp -#, fuzzy msgid "Small Deploy with Network Filesystem" -msgstr "Deploy Kecil dengan Jaringan FS" +msgstr "Deploy Kecil dengan Jaringan Berkas" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, using one-click deploy for Android will only " "export an executable without the project data.\n" @@ -2869,9 +2868,9 @@ msgid "" "On Android, deploying will use the USB cable for faster performance. This " "option speeds up testing for projects with large assets." msgstr "" -"Ketika opsi ini aktif, ekspor atau deploy akan menghasilkan minimal " -"executable.\n" -"Berkas sistem akan tersedia dari proyek dari editor melalui jaringan.\n" +"Ketika opsi ini aktif, menggunakan 'one-click deploy' hanya akan mengekspor " +"executable tanpa data proyek.\n" +"Berkas sistem akan tersedia dari proyek oleh editor melalui jaringan.\n" "Pada Android, deploy akan menggunakan kabel USB untuk performa yang lebih " "cepat. Opsi ini mempercepat pengujian dengan jejak kaki yang besar." @@ -2880,34 +2879,29 @@ msgid "Visible Collision Shapes" msgstr "Collision Shapes Terlihat" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, collision shapes and raycast nodes (for 2D and " "3D) will be visible in the running project." msgstr "" "Collision shapes dan raycast nodes (untuk 2D dan 3D) akan terlihat pada saat " -"permainan berjalan jika opsi ini aktif." +"proyek berjalan jika opsi ini aktif." #: editor/editor_node.cpp msgid "Visible Navigation" msgstr "Navigasi Terlihat" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, navigation meshes and polygons will be visible " "in the running project." msgstr "" -"Navigasi meshes dan poligon akan terlihat saat game berjalan jika opsi ini " -"aktif." +"Navigasi dan poligon akan terlihat saat game berjalan jika opsi ini aktif." #: editor/editor_node.cpp -#, fuzzy msgid "Synchronize Scene Changes" msgstr "Sinkronkan Perubahan Skena" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, any changes made to the scene in the editor " "will be replicated in the running project.\n" @@ -2915,17 +2909,15 @@ msgid "" "filesystem option is enabled." msgstr "" "Ketika opsi ini aktif, perubahan yang dibuat pada skena melalui editor akan " -"direplika pada gim yang sedang berjalan.\n" +"direplika pada proyek yang sedang berjalan.\n" "Ketika penggunaan remote pada sebuah perangkat, akan lebih efisien dengan " -"berkas sistem jaringan." +"opsi berkas sistem jaringan." #: editor/editor_node.cpp -#, fuzzy msgid "Synchronize Script Changes" -msgstr "Sinkronkan Perubahan Script" +msgstr "Sinkronkan Perubahan skrip" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, any script that is saved will be reloaded in " "the running project.\n" @@ -2934,8 +2926,8 @@ msgid "" msgstr "" "Ketika opsi ini aktif, perubahan script yang tersimpan akan di muat kembali " "pada permainan yang sedang berjalan.\n" -"Ketika penggunaan remote pada sebuah perngakat, akan lebih efisien jika " -"jaringan filesystem." +"Ketika penggunaan remote pada sebuah perangakat, akan lebih efisien dengan " +"opsi jaringan berkas-berkas." #: editor/editor_node.cpp editor/script_create_dialog.cpp msgid "Editor" @@ -3154,13 +3146,12 @@ msgid "Open & Run a Script" msgstr "Buka & Jalankan Skrip" #: editor/editor_node.cpp -#, fuzzy msgid "" "The following files are newer on disk.\n" "What action should be taken?" msgstr "" -"Berkas berikut lebih baru dalam diska.\n" -"Aksi apa yang ingin diambil?:" +"Berkas berikut lebih baru dalam disk.\n" +"Aksi apa yang ingin diambil?" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp @@ -3422,7 +3413,6 @@ msgid "Add Key/Value Pair" msgstr "Tambahkan pasangan Key/Value" #: editor/editor_run_native.cpp -#, fuzzy msgid "" "No runnable export preset found for this platform.\n" "Please add a runnable preset in the Export menu or define an existing preset " @@ -3456,11 +3446,10 @@ msgid "Did you forget the '_run' method?" msgstr "Apakah anda lupa dengan fungsi '_run' ?" #: editor/editor_spin_slider.cpp -#, fuzzy msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes." msgstr "" -"Tahan Ctrl untuk meletakkan Getter. Tahan Shift untuk meletakkan generic " -"signature." +"Tahan Ctrl untuk membulatkan bilangan. Tahan Shift untuk meletakkan bilangan " +"yang lebih presisi." #: editor/editor_sub_scene.cpp msgid "Select Node(s) to Import" @@ -3744,6 +3733,11 @@ msgid "" "\n" "Do you wish to overwrite them?" msgstr "" +"file dan/atau berkas-berkas berikut mempunyai konflik di '%s':\n" +"\n" +"%s\n" +"\n" +"Apakah Anda ingin melanjutkan (overwrite)?" #: editor/filesystem_dock.cpp msgid "Renaming file:" @@ -3775,7 +3769,7 @@ msgstr "Buka Skena" #: editor/filesystem_dock.cpp msgid "Instance" -msgstr "Instansi" +msgstr "hal" #: editor/filesystem_dock.cpp msgid "Add to Favorites" @@ -3824,9 +3818,8 @@ msgid "Duplicate..." msgstr "Gandakan..." #: editor/filesystem_dock.cpp -#, fuzzy msgid "Move to Trash" -msgstr "Pindahkan Autoload" +msgstr "Pindahkan ke tong sampah" #: editor/filesystem_dock.cpp editor/plugins/animation_player_editor_plugin.cpp msgid "Rename..." @@ -3937,12 +3930,10 @@ msgid "Searching..." msgstr "Mencari..." #: editor/find_in_files.cpp -#, fuzzy msgid "%d match in %d file." msgstr "Ditemukan %d kecocokan." #: editor/find_in_files.cpp -#, fuzzy msgid "%d matches in %d file." msgstr "Ditemukan %d kecocokan." @@ -4085,6 +4076,21 @@ msgstr "" msgid "Saving..." msgstr "Menyimpan..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Mode Seleksi" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Impor" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Muat Default" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Berkas" @@ -5153,7 +5159,6 @@ msgid "Sort:" msgstr "Sortir:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategori:" @@ -10444,6 +10449,11 @@ msgstr "Muat Otomatis" msgid "Plugins" msgstr "Pengaya" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Muat Default" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Prasetel..." @@ -12504,6 +12514,14 @@ msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" "Sebuah CollisionPolygon2D yang kosong tidak memiliki efek pada collision." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12824,11 +12842,6 @@ msgstr "" "GIProbes tidak didukung oleh driver video GLES2.\n" "Gunakan BakedLightmap sebagai gantinya." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/is.po b/editor/translations/is.po index 6de37d39fb..8d36556c04 100644 --- a/editor/translations/is.po +++ b/editor/translations/is.po @@ -1835,8 +1835,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3923,6 +3923,19 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Afrita val" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4988,7 +5001,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10079,6 +10091,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12050,6 +12066,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12305,11 +12329,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/it.po b/editor/translations/it.po index 2daa387575..1d399091c3 100644 --- a/editor/translations/it.po +++ b/editor/translations/it.po @@ -60,8 +60,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:50+0000\n" -"Last-Translator: Micila Micillotto <micillotto@gmail.com>\n" +"PO-Revision-Date: 2021-03-07 06:04+0000\n" +"Last-Translator: Riteo Siuga <lorenzocerqua@tutanota.com>\n" "Language-Team: Italian <https://hosted.weblate.org/projects/godot-engine/" "godot/it/>\n" "Language: it\n" @@ -69,7 +69,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.5\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -192,7 +192,7 @@ msgstr "Elimina delle chiavi d'animazione" #: editor/animation_track_editor.cpp msgid "Anim Change Keyframe Time" -msgstr "Cambia Intervallo Fotogramma Principale Animazione" +msgstr "Cambia il tempo di un fotogramma chiave" #: editor/animation_track_editor.cpp msgid "Anim Change Transition" @@ -204,7 +204,7 @@ msgstr "Cambia la trasformazione di un'animazione" #: editor/animation_track_editor.cpp msgid "Anim Change Keyframe Value" -msgstr "Cambia Valore Fotogramma Principale Animazione" +msgstr "Cambia il valore del fotogramma chiave di un'animazione" #: editor/animation_track_editor.cpp msgid "Anim Change Call" @@ -212,32 +212,32 @@ msgstr "Cambia la chiamata di un'animazione" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Keyframe Time" -msgstr "Cambia Multipli Intervalli Fotogramma Principale Animazione" +msgstr "Cambia il tempo di più fotogrammi chiave" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Transition" -msgstr "Cambi Multipli Transizione Animazione" +msgstr "Cambia la transizione di più animazioni" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Transform" -msgstr "Cambi Multipli Trasformazione Animazione" +msgstr "Cambia le trasformazioni di più animazioni" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Keyframe Value" -msgstr "Cambia Multipli Valori Fotogramma Principale Animazione" +msgstr "Cambia il valore di più fotogrammi chiave di un'Animazione" #: editor/animation_track_editor.cpp msgid "Anim Multi Change Call" -msgstr "Cambi Multipli Chiamata Animazione" +msgstr "Cambia la chiamata di metodo di più animazioni" #: editor/animation_track_editor.cpp msgid "Change Animation Length" -msgstr "Cambia Lunghezza Animazione" +msgstr "Cambia la durata dell'animazione" #: editor/animation_track_editor.cpp #: editor/plugins/sprite_frames_editor_plugin.cpp msgid "Change Animation Loop" -msgstr "Cambia Loop Animazione" +msgstr "Commuta ciclicità animazione" #: editor/animation_track_editor.cpp msgid "Property Track" @@ -253,7 +253,7 @@ msgstr "Traccia di chiamate di metodo" #: editor/animation_track_editor.cpp msgid "Bezier Curve Track" -msgstr "Traccia di curve di Bézier" +msgstr "Traccia curva di Bézier" #: editor/animation_track_editor.cpp msgid "Audio Playback Track" @@ -273,11 +273,11 @@ msgstr "Durata dell'animazione (secondi)" #: editor/animation_track_editor.cpp msgid "Add Track" -msgstr "Aggiungi una traccia" +msgstr "Aggiungi Traccia" #: editor/animation_track_editor.cpp msgid "Animation Looping" -msgstr "Ciclicità animazione" +msgstr "Ciclicità Animazione" #: editor/animation_track_editor.cpp #: modules/visual_script/visual_script_editor.cpp @@ -286,15 +286,15 @@ msgstr "Funzioni:" #: editor/animation_track_editor.cpp msgid "Audio Clips:" -msgstr "Clip audio:" +msgstr "Clip Audio:" #: editor/animation_track_editor.cpp msgid "Anim Clips:" -msgstr "Clip animazione:" +msgstr "Clip Animazione:" #: editor/animation_track_editor.cpp msgid "Change Track Path" -msgstr "Cambia il percorso della traccia" +msgstr "Cambia Percorso Traccia" #: editor/animation_track_editor.cpp msgid "Toggle this track on/off." @@ -302,11 +302,11 @@ msgstr "Attiva/Disattiva questa traccia." #: editor/animation_track_editor.cpp msgid "Update Mode (How this property is set)" -msgstr "Modalità di aggiornamento (come viene impostata questa proprietà)" +msgstr "Modalità Aggiornamento (come viene impostata questa proprietà)" #: editor/animation_track_editor.cpp msgid "Interpolation Mode" -msgstr "Modalità d'interpolazione" +msgstr "Modalità Interpolazione" #: editor/animation_track_editor.cpp msgid "Loop Wrap Mode (Interpolate end with beginning on loop)" @@ -322,7 +322,7 @@ msgstr "Tempo (s): " #: editor/animation_track_editor.cpp msgid "Toggle Track Enabled" -msgstr "Abilita/Disabilita una traccia" +msgstr "Abilita/DisabilitaTraccia" #: editor/animation_track_editor.cpp msgid "Continuous" @@ -376,23 +376,24 @@ msgstr "Elimina Fotogrammi Chiave Selezionati" #: editor/animation_track_editor.cpp msgid "Change Animation Update Mode" -msgstr "Cambia la modalità d'aggiornamento di un'animazione" +msgstr "Cambia Modalità Aggiornamento Animazione" #: editor/animation_track_editor.cpp msgid "Change Animation Interpolation Mode" -msgstr "Cambia la modalità d'interpolazione di un'animazione" +msgstr "Cambia Modalità Interpolazione Animazione" #: editor/animation_track_editor.cpp msgid "Change Animation Loop Mode" -msgstr "Cambia la modalità del ciclo di un'animazione" +msgstr "Cambia Modalità Loop Animazione" #: editor/animation_track_editor.cpp msgid "Remove Anim Track" -msgstr "Rimuovi la traccia di un'animazione" +msgstr "Rimuovi una traccia d'animazione" #: editor/animation_track_editor.cpp +#, fuzzy msgid "Create NEW track for %s and insert key?" -msgstr "Crea NUOVA traccia per %s ed inserire fotogramma chiave?" +msgstr "Creare una NUOVA traccia per %s e inserirci la chiave?" #: editor/animation_track_editor.cpp msgid "Create %d NEW tracks and insert keys?" @@ -520,11 +521,11 @@ msgstr "Gli appunti sono vuoti" #: editor/animation_track_editor.cpp msgid "Paste Tracks" -msgstr "Incolla delle tracce" +msgstr "Incolla Tracce" #: editor/animation_track_editor.cpp msgid "Anim Scale Keys" -msgstr "Scala delle chiavi d'animazione" +msgstr "Scala Chiavi Animazione" #: editor/animation_track_editor.cpp msgid "" @@ -656,15 +657,15 @@ msgstr "Ottimizzatore anim." #: editor/animation_track_editor.cpp msgid "Max. Linear Error:" -msgstr "Max errore lineare:" +msgstr "Max Errore Lineare:" #: editor/animation_track_editor.cpp msgid "Max. Angular Error:" -msgstr "Max errore angolare:" +msgstr "Max Errore Angolare:" #: editor/animation_track_editor.cpp msgid "Max Optimizable Angle:" -msgstr "Max angolo ottimizzabile:" +msgstr "Max Angolo Ottimizzabile:" #: editor/animation_track_editor.cpp msgid "Optimize" @@ -709,7 +710,7 @@ msgstr "Copia" #: editor/animation_track_editor.cpp msgid "Select All/None" -msgstr "Seleziona tutto/nulla" +msgstr "De/Seleziona Tutto" #: editor/animation_track_editor_plugins.cpp msgid "Add Audio Track Clip" @@ -725,23 +726,23 @@ msgstr "Cambia Offset Fine Clip Traccia Audio" #: editor/array_property_edit.cpp msgid "Resize Array" -msgstr "Ridimensiona lista" +msgstr "Ridimensiona Array" #: editor/array_property_edit.cpp msgid "Change Array Value Type" -msgstr "Cambia il tipo del valore della lista" +msgstr "Cambia Tipo Valore Array" #: editor/array_property_edit.cpp msgid "Change Array Value" -msgstr "Cambia il valore della lista" +msgstr "Cambia Valore Array" #: editor/code_editor.cpp msgid "Go to Line" -msgstr "Vai alla linea" +msgstr "Vai alla Linea" #: editor/code_editor.cpp msgid "Line Number:" -msgstr "Numero della linea:" +msgstr "Numero Linea:" #: editor/code_editor.cpp msgid "%d replaced." @@ -757,11 +758,11 @@ msgstr "%d corrispondenze." #: editor/code_editor.cpp editor/find_in_files.cpp msgid "Match Case" -msgstr "Distingui le maiuscole" +msgstr "Distingui Maiuscole" #: editor/code_editor.cpp editor/find_in_files.cpp msgid "Whole Words" -msgstr "Parole intere" +msgstr "Parole Intere" #: editor/code_editor.cpp msgid "Replace" @@ -769,11 +770,11 @@ msgstr "Sostituisci" #: editor/code_editor.cpp msgid "Replace All" -msgstr "Rimpiazza tutti" +msgstr "Rimpiazza Tutti" #: editor/code_editor.cpp msgid "Selection Only" -msgstr "Solo nella selezione" +msgstr "Solo Selezione" #: editor/code_editor.cpp editor/plugins/script_text_editor.cpp #: editor/plugins/text_editor.cpp @@ -810,7 +811,7 @@ msgstr "Numeri di riga e di colonna." #: editor/connections_dialog.cpp msgid "Method in target node must be specified." -msgstr "Il metodo del nodo designato deve essere specificato." +msgstr "Il metodo del nodo selezionato deve essere specificato." #: editor/connections_dialog.cpp msgid "Method name must be a valid identifier." @@ -1912,8 +1913,8 @@ msgid "Open a File or Directory" msgstr "Apri un file o una cartella" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Salva" @@ -2593,11 +2594,9 @@ msgstr "" "configurazione fallita." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." msgstr "" -"Impossibile trovare il campo dello script per il componente aggiuntivo in: " -"'res://addons/%s'." +"Impossibile trovare il campo script per il plugin addon in posizione: '%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -3158,13 +3157,13 @@ msgid "" "the \"Use Custom Build\" option should be enabled in the Android export " "preset." msgstr "" -"Questo imposterà il tuo progetto per le build custom per Android, " -"installando i source templates in \"res://android/build\".\n" -"Puoi, allora, applicare le modifiche e costruire il tuo APK custom durante " -"l'esportazione (aggiungere moduli, cambiare il AndroidManifest.xml, ed " -"altro).\n" -"Nota che, in ordine per creare le build custom invece di usare gli APK pre-" -"costruiti, l'opzione \"Use Custom Build\" sarà abilitata nel preset " +"Questo predisporrà il progetto per le build personalizzate per Android " +"installando i template sorgente in \"res://android/build\".\n" +"Potrai allora applicare le modifiche e costruire il tuo APK personalizzato " +"durante l'esportazione (aggiungere moduli, cambiare l'AndroidManifest.xml, " +"eccetera).\n" +"Nota che per creare delle build personalizzate, invece di usare gli APK pre-" +"costruiti, l'opzione \"Use Custom Build\" va attivata nella preimpostazione " "d'esportazione per Android." #: editor/editor_node.cpp @@ -3174,30 +3173,30 @@ msgid "" "Remove the \"res://android/build\" directory manually before attempting this " "operation again." msgstr "" -"Il modello della build Android è già installato in questo progetto e non " -"sarà sovrascritto.\n" -"Rimuovi la cartella \"res://android/build\" manualmente prima di ritentare " +"Il template della build Android è già installato in questo progetto e non " +"verrà sovrascritto.\n" +"Rimuovi manualmente la cartella \"res://android/build\" prima di ritentare " "questa operazione." #: editor/editor_node.cpp msgid "Import Templates From ZIP File" -msgstr "Importa template da un file ZIP" +msgstr "Importa Template Da File ZIP" #: editor/editor_node.cpp msgid "Template Package" -msgstr "Pacchetto Modello" +msgstr "Pacchetto Template" #: editor/editor_node.cpp msgid "Export Library" -msgstr "Esporta libreria" +msgstr "Esporta Libreria" #: editor/editor_node.cpp msgid "Merge With Existing" -msgstr "Unisci con esistente" +msgstr "Unisci Con Esistente" #: editor/editor_node.cpp msgid "Open & Run a Script" -msgstr "Apri ed esegui uno script" +msgstr "Apri ed Esegui uno Script" #: editor/editor_node.cpp msgid "" @@ -4135,6 +4134,21 @@ msgstr "" msgid "Saving..." msgstr "Salvataggio..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Modalità di selezione" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importare" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Usa sRGB Default" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d File" @@ -5107,9 +5121,8 @@ msgid "Got:" msgstr "Ottenuto:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Check hash sha256 fallito" +msgstr "Check has SHA-256 fallito" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5212,7 +5225,6 @@ msgid "Sort:" msgstr "Ordina:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoria:" @@ -10510,6 +10522,11 @@ msgstr "AutoLoad" msgid "Plugins" msgstr "Plugins" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Carica Predefiniti" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Preset…" @@ -10760,14 +10777,12 @@ msgid "Instance Child Scene" msgstr "Istanzia Scena Figlia" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "Impossibile operare su nodi da scena esterna!" +msgstr "Non si può incollare il noto root nella stessa scena." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Incolla nodi" +msgstr "Incolla Nodo(i)" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10896,9 +10911,8 @@ msgid "Attach Script" msgstr "Allega Script" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Taglia nodi" +msgstr "Taglia Nodo(i)" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -12579,6 +12593,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Un CollisionPolygon2D vuoto non ha effetti sulla collisione." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12903,11 +12925,6 @@ msgstr "" "Le GIProbes non sono supportate dal driver video GLES2.\n" "In alternativa, usa una BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "\"InterpolatedCamera\" è stata deprecata e sarà rimossa in Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13166,9 +13183,9 @@ msgid "" "functions. Making them visible for editing is fine, but they will hide upon " "running." msgstr "" -"I popup saranno nascosti di predefinita finchè non chiami popup() o una " -"delle qualsiasi funzioni popup*(). Farli diventare visibili per modificarli " -"va bene, ma scompariranno all'esecuzione." +"I popup saranno nascosti di default finchè non chiami popup(), o una delle " +"qualsiasi funzioni popup*(). Farli diventare visibili per modificarli va " +"bene, ma scompariranno durante l'esecuzione." #: scene/gui/range.cpp msgid "If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0." @@ -13251,6 +13268,11 @@ msgstr "" msgid "Constants cannot be modified." msgstr "Le constanti non possono essere modificate." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "\"InterpolatedCamera\" è stata deprecata e sarà rimossa in Godot 4.0." + #~ msgid "No" #~ msgstr "No" @@ -14914,9 +14936,6 @@ msgstr "Le constanti non possono essere modificate." #~ msgid "Use Default Light" #~ msgstr "Usa Luce Default" -#~ msgid "Use Default sRGB" -#~ msgstr "Usa sRGB Default" - #~ msgid "Default Light Normal:" #~ msgstr "Normale Luce di Default:" diff --git a/editor/translations/ja.po b/editor/translations/ja.po index 6c7ce36693..8afa2de349 100644 --- a/editor/translations/ja.po +++ b/editor/translations/ja.po @@ -36,8 +36,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:50+0000\n" -"Last-Translator: nitenook <admin@alterbaum.net>\n" +"PO-Revision-Date: 2021-03-08 15:33+0000\n" +"Last-Translator: Wataru Onuki <bettawat@yahoo.co.jp>\n" "Language-Team: Japanese <https://hosted.weblate.org/projects/godot-engine/" "godot/ja/>\n" "Language: ja\n" @@ -45,7 +45,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.5\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1881,8 +1881,8 @@ msgid "Open a File or Directory" msgstr "ファイルまたはディレクトリを開く" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "保存" @@ -2554,11 +2554,8 @@ msgid "Unable to enable addon plugin at: '%s' parsing of config failed." msgstr "アドオンプラグインを有効にできません: '%s' 設定の解析に失敗しました。" #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "" -"アドオンプラグインのスクリプトフィールドが 'res://addons/%s' から見つかりませ" -"ん。" +msgstr "アドオンプラグインのスクリプトフィールドが '%s' で見つかりません。" #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4082,6 +4079,21 @@ msgstr "" msgid "Saving..." msgstr "保存中..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "選択モード" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "インポート" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "デフォルトを読込む" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d ファイル" @@ -5046,9 +5058,8 @@ msgid "Got:" msgstr "取得:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "sha256 ハッシュチェック失敗" +msgstr "SHA-256 ハッシュチェック失敗" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5151,7 +5162,6 @@ msgid "Sort:" msgstr "ソート:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "カテゴリー:" @@ -10409,6 +10419,11 @@ msgstr "自動読み込み" msgid "Plugins" msgstr "プラグイン" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "デフォルトを読込む" + #: editor/property_editor.cpp msgid "Preset..." msgstr "プリセット..." @@ -10658,12 +10673,10 @@ msgid "Instance Child Scene" msgstr "子シーンをインスタンス化" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "別のシーンからノードを操作することはできません!" +msgstr "ルートノードは同じシーンに貼り付けできません。" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" msgstr "ノードを貼り付け" @@ -10793,9 +10806,8 @@ msgid "Attach Script" msgstr "スクリプトをアタッチ" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "ノードを切り取る" +msgstr "ノードを切り取り" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -11618,19 +11630,16 @@ msgid "Generate buffers" msgstr "バッファを生成" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Direct lighting" -msgstr "方向" +msgstr "直接光" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Indirect lighting" -msgstr "右インデント" +msgstr "間接光" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Post processing" -msgstr "ポストプロセス" +msgstr "後処理" #: modules/lightmapper_cpu/lightmapper_cpu.cpp #, fuzzy @@ -12460,6 +12469,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "空の CollisionPolygon2D は、衝突判定を持ちません。" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12781,11 +12798,6 @@ msgstr "" "GIProbesはGLES2ビデオドライバではサポートされていません。\n" "代わりにBakedLightmapを使用してください。" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera は廃止予定であり、Godot 4.0で除去されます。" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "90度を超える角度のスポットライトは、シャドウを投影できません。" @@ -13124,6 +13136,10 @@ msgstr "Varying変数は頂点関数にのみ割り当てることができま msgid "Constants cannot be modified." msgstr "定数は変更できません。" +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera は廃止予定であり、Godot 4.0で除去されます。" + #~ msgid "No" #~ msgstr "いいえ" diff --git a/editor/translations/ka.po b/editor/translations/ka.po index b9f4a92e47..6828baf211 100644 --- a/editor/translations/ka.po +++ b/editor/translations/ka.po @@ -1900,8 +1900,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -4028,6 +4028,19 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "წავშალოთ მონიშნული ფაილები?" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -5113,7 +5126,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10287,6 +10299,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12295,6 +12311,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12550,11 +12574,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ko.po b/editor/translations/ko.po index 872cb1550c..b898f397f4 100644 --- a/editor/translations/ko.po +++ b/editor/translations/ko.po @@ -16,7 +16,7 @@ # Jiyoon Kim <kimjiy@dickinson.edu>, 2019. # Ervin <zetsmart@gmail.com>, 2019. # Tilto_ <tilto0822@develable.xyz>, 2020. -# Myeongjin Lee <aranet100@gmail.com>, 2020. +# Myeongjin Lee <aranet100@gmail.com>, 2020, 2021. # Doyun Kwon <caen4516@gmail.com>, 2020. # Jun Hyung Shin <shmishmi79@gmail.com>, 2020. # Yongjin Jo <wnrhd114@gmail.com>, 2020. @@ -25,8 +25,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-10-31 23:15+0000\n" -"Last-Translator: Yungjoong Song <yungjoong.song@gmail.com>\n" +"PO-Revision-Date: 2021-03-08 15:33+0000\n" +"Last-Translator: Myeongjin Lee <aranet100@gmail.com>\n" "Language-Team: Korean <https://hosted.weblate.org/projects/godot-engine/" "godot/ko/>\n" "Language: ko\n" @@ -34,7 +34,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.3.2-dev\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -704,7 +704,7 @@ msgstr "행 번호:" #: editor/code_editor.cpp msgid "%d replaced." -msgstr "%d개가 바뀌었습니다." +msgstr "%d개 찾아 바꿈." #: editor/code_editor.cpp editor/editor_help.cpp msgid "%d match." @@ -1044,22 +1044,23 @@ msgid "Owners Of:" msgstr "소유자:" #: editor/dependency_editor.cpp -#, fuzzy msgid "" "Remove selected files from the project? (no undo)\n" "You can find the removed files in the system trash to restore them." -msgstr "프로젝트에서 선택한 파일을 삭제할까요? (되돌릴 수 없습니다)" +msgstr "" +"프로젝트에서 선택된 파일을 제거하시겠습니다? (되돌릴 수 없음)\n" +"시스템 휴지통에서 제거된 파일을 찾고 복원할 수 있습니다." #: editor/dependency_editor.cpp -#, fuzzy msgid "" "The files being removed are required by other resources in order for them to " "work.\n" "Remove them anyway? (no undo)\n" "You can find the removed files in the system trash to restore them." msgstr "" -"삭제하려는 파일은 다른 리소스가 동작하기 위해 필요한 파일입니다.\n" -"무시하고 삭제할까요? (되돌릴 수 없습니다)" +"제거하려는 파일은 다른 리소스가 동작하기 위해 필요합니다.\n" +"무시하고 제거하시겠습니까? (되돌릴 수 없음)\n" +"시스템 휴지통에서 제거된 파일을 찾고 복원할 수 있습니다." #: editor/dependency_editor.cpp msgid "Cannot remove:" @@ -1864,8 +1865,8 @@ msgid "Open a File or Directory" msgstr "디렉토리 또는 파일 열기" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "저장" @@ -2314,6 +2315,8 @@ msgid "" "An error occurred while trying to save the editor layout.\n" "Make sure the editor's user data path is writable." msgstr "" +"편집기 레이아웃의 저장을 하려는 동안 오류가 발생했습니다.\n" +"편집기의 사용자 데이터 경로가 쓰기 가능한지 확인해주세요." #: editor/editor_node.cpp msgid "" @@ -2321,15 +2324,17 @@ msgid "" "To restore the Default layout to its base settings, use the Delete Layout " "option and delete the Default layout." msgstr "" +"기본 편집기 레이아웃이 덮어 쓰여져 있습니디.\n" +"기본 레이아웃을 원래 설정으로 복구하려면, 레이아웃 삭제 옵션을 사용하여 기본 " +"레이아웃을 삭제하세요." #: editor/editor_node.cpp msgid "Layout name not found!" msgstr "레이아웃 이름을 찾을 수 없습니다!" #: editor/editor_node.cpp -#, fuzzy msgid "Restored the Default layout to its base settings." -msgstr "기본 레이아웃을 초기화하였습니다." +msgstr "기본 레이아웃을 원래 설정으로 복구하였습니다." #: editor/editor_node.cpp msgid "" @@ -2384,7 +2389,7 @@ msgstr "실행할 씬이 설정되지 않았습니다." #: editor/editor_node.cpp msgid "Save scene before running..." -msgstr "" +msgstr "씬을 실행하기 전에 저장..." #: editor/editor_node.cpp msgid "Could not start subprocess!" @@ -2507,8 +2512,8 @@ msgid "" "This option is deprecated. Situations where refresh must be forced are now " "considered a bug. Please report." msgstr "" -"이 설정은 제거되었습니다. 강제로 새로고침해야 하는 상황은 이제 버그입니다. 신" -"고해주세요." +"이 옵션은 사용되지 않습니다. 강제로 새로 고침해야 하는 상황은 이제 버그로 간" +"주됩니다. 신고해주세요." #: editor/editor_node.cpp msgid "Pick a Main Scene" @@ -2529,9 +2534,9 @@ msgstr "" "실패했습니다." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "다음 경로에서 애드온 플러그인을 찾을 수 없음: 'res://addons/%s'." +msgstr "" +"다음 경로에서 애드온 플러그인을 위한 스크립트 필드를 찾을 수 없습니다: '%s'." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -2894,17 +2899,16 @@ msgid "Synchronize Script Changes" msgstr "스크립트 변경사항 동기화" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, any script that is saved will be reloaded in " "the running project.\n" "When used remotely on a device, this is more efficient when the network " "filesystem option is enabled." msgstr "" -"이 설정이 활성화된 경우, 어떤 스크립트든 저장하면 실행중인 게임에도 새로고침" -"되어 반영됩니다.\n" -"원격 장치에서 사용중인 경우 네트워크 파일 시스템 기능을 활성화하면 더욱 효율" -"적입니다." +"이 옵션이 활성화된 경우, 어떤 스크립트든지 저장되면 실행 중인 프로젝트를 다" +"시 불러오게 됩니다.\n" +"기기에서 원격으로 사용 중인 경우, 네트워크 파일 시스템 옵션이 활성화되어 있다" +"면 더욱 효율적입니다." #: editor/editor_node.cpp editor/script_create_dialog.cpp msgid "Editor" @@ -3120,13 +3124,12 @@ msgid "Open & Run a Script" msgstr "스크립트 열기 & 실행" #: editor/editor_node.cpp -#, fuzzy msgid "" "The following files are newer on disk.\n" "What action should be taken?" msgstr "" -"해당 파일은 디스크에 있는 게 더 최신입니다.\n" -"어떻게 할 건가요?:" +"다음 파일은 디스크에 있는 게 더 최신입니다.\n" +"조치을 어떻게 취해야 합니까?" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp @@ -3385,14 +3388,14 @@ msgid "Add Key/Value Pair" msgstr "키/값 쌍 추가" #: editor/editor_run_native.cpp -#, fuzzy msgid "" "No runnable export preset found for this platform.\n" "Please add a runnable preset in the Export menu or define an existing preset " "as runnable." msgstr "" -"이 플랫폼으로 실행할 수 있는 내보내기 프리셋이 없습니다.\n" -"내보내기 메뉴에서 실행할 수 있는 프리셋을 추가해주세요." +"이 플랫폼을 위한 실행할 수 있는 내보내기 프리셋이 없습니다.\n" +"내보내기 메뉴에서 실행할 수 있는 프리셋을 추가하거나 기존 프리셋을 실행할 수 " +"있도록 지정해주세요." #: editor/editor_run_script.cpp msgid "Write your logic in the _run() method." @@ -3705,6 +3708,11 @@ msgid "" "\n" "Do you wish to overwrite them?" msgstr "" +"다음 파일이나 폴더가 대상 위치 '%s'의 항목과 충돌합니다:\n" +"\n" +"%s\n" +"\n" +"이를 덮어쓰시겠습니까?" #: editor/filesystem_dock.cpp msgid "Renaming file:" @@ -3785,9 +3793,8 @@ msgid "Duplicate..." msgstr "복제..." #: editor/filesystem_dock.cpp -#, fuzzy msgid "Move to Trash" -msgstr "오토로드 이동" +msgstr "휴지통으로 이동" #: editor/filesystem_dock.cpp editor/plugins/animation_player_editor_plugin.cpp msgid "Rename..." @@ -3898,19 +3905,16 @@ msgid "Searching..." msgstr "검색 중..." #: editor/find_in_files.cpp -#, fuzzy msgid "%d match in %d file." -msgstr "%d개 일치." +msgstr "파일 %d$2개 중 %d$1개 일치." #: editor/find_in_files.cpp -#, fuzzy msgid "%d matches in %d file." -msgstr "%d개 일치." +msgstr "파일 %d$2개 중 %d$1개 일치." #: editor/find_in_files.cpp -#, fuzzy msgid "%d matches in %d files." -msgstr "%d개 일치." +msgstr "파일 %d$2개 중 %d$1개 일치." #: editor/groups_editor.cpp msgid "Add to Group" @@ -4046,6 +4050,21 @@ msgstr "`post_import()` 메소드에서 Node에서 상속받은 객체를 반환 msgid "Saving..." msgstr "저장 중..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "모드 선택" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "가져오기" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "기본 sRGB 사용" + #: editor/import_dock.cpp msgid "%d Files" msgstr "파일 %d개" @@ -5009,9 +5028,8 @@ msgid "Got:" msgstr "받음:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "sha256 해시 확인 실패" +msgstr "SHA-256 해시 확인 실패" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5114,7 +5132,6 @@ msgid "Sort:" msgstr "정렬:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "카테고리:" @@ -5143,14 +5160,12 @@ msgid "Assets ZIP File" msgstr "애셋 ZIP 파일" #: editor/plugins/baked_lightmap_editor_plugin.cpp -#, fuzzy msgid "" "Can't determine a save path for lightmap images.\n" "Save your scene and try again." msgstr "" -"라이트맵 이미지의 저장 경로를 파악할 수 없습니다.\n" -"(같은 경로에 이미지를 저장할 수 있도록) 씬을 저장하거나, BakedLightmap 속성에" -"서 저장 경로를 지정하세요." +"라이트맵 이미지를 위한 저장 경로를 결정할 수 없습니다.\n" +"당신의 씬을 저장하고 다시 시도하세요." #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" @@ -5167,26 +5182,30 @@ msgstr "라이트맵 이미지 생성 실패. 작성 가능한 경로인지 확 #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "Failed determining lightmap size. Maximum lightmap size too small?" msgstr "" +"라이트맵 크기를 결정하는 데 실패했습니다. 최대 라이트맵 크기가 너무 작나요?" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" "Some mesh is invalid. Make sure the UV2 channel values are contained within " "the [0.0,1.0] square region." msgstr "" +"일부 메시가 잘못되었습니다. UV2 채널 값이 [0.0,1.0] 정사각형 영역 안에 포함되" +"어 있는지 확인해주세요." #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" "Godot editor was built without ray tracing support, lightmaps can't be baked." msgstr "" +"Godot 편집기가 레이 트레이싱 지원 없이 빌드되어 있어, 라이트맵이 구워질 수 없" +"습니다." #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "Bake Lightmaps" msgstr "라이트맵 굽기" #: editor/plugins/baked_lightmap_editor_plugin.cpp -#, fuzzy msgid "Select lightmap bake file:" -msgstr "템플릿 파일 선택" +msgstr "라이트맵을 구울 파일 선택:" #: editor/plugins/camera_editor_plugin.cpp #: editor/plugins/spatial_editor_plugin.cpp @@ -5255,50 +5274,43 @@ msgstr "수평 및 수직 가이드 만들기" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Set CanvasItem \"%s\" Pivot Offset to (%d, %d)" -msgstr "CanvasItem \"%s\" Pivot Offset (%d, %d)로 설정" +msgstr "CanvasItem \"%s\"의 피벗 오프셋을 (%d, %d)로 설정" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Rotate %d CanvasItems" -msgstr "CanvasItem 회전" +msgstr "CanvasItem %d개 회전" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Rotate CanvasItem \"%s\" to %d degrees" -msgstr "CanvasItem 회전" +msgstr "CanvasItem \"%s\"를 %d도로 회전" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Move CanvasItem \"%s\" Anchor" -msgstr "CanvasItem 이동" +msgstr "CanvasItem \"%s\" 앵커 이동" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Scale Node2D \"%s\" to (%s, %s)" -msgstr "" +msgstr "Node2D \"%s\"를 (%s, %s)로 크기 조절" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Resize Control \"%s\" to (%d, %d)" -msgstr "" +msgstr "컨트롤 \"%s\"를 (%d, %d)로 크기 조절" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Scale %d CanvasItems" -msgstr "CanvasItem 규모" +msgstr "CanvasItem %d개 크기 조절" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Scale CanvasItem \"%s\" to (%s, %s)" -msgstr "CanvasItem 규모" +msgstr "CanvasItem \"%s\"를 (%s, %s)로 크기 조절" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Move %d CanvasItems" -msgstr "CanvasItem 이동" +msgstr "CanvasItem %d개 이동" #: editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Move CanvasItem \"%s\" to (%d, %d)" -msgstr "CanvasItem 이동" +msgstr "CanvasItem \"%s\"를 (%d, %d)로 이동" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "" @@ -5504,7 +5516,7 @@ msgstr "회전모드" #: editor/plugins/canvas_item_editor_plugin.cpp #: editor/plugins/spatial_editor_plugin.cpp msgid "Scale Mode" -msgstr "크기조절 모드" +msgstr "크기 조절 모드" #: editor/plugins/canvas_item_editor_plugin.cpp #: editor/plugins/spatial_editor_plugin.cpp @@ -5553,7 +5565,7 @@ msgstr "회전 스냅 사용" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Use Scale Snap" -msgstr "스마트 스냅 사용" +msgstr "크기 조절 스냅 사용" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Snap Relative" @@ -5671,11 +5683,11 @@ msgstr "선택 항목 중앙으로" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Frame Selection" -msgstr "선택 항목 전체 화면으로" +msgstr "프레임 선택" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Preview Canvas Scale" -msgstr "캔버스 규모 미리 보기" +msgstr "캔버스 크기 조절 미리 보기" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Translation mask for inserting keys." @@ -5937,7 +5949,7 @@ msgstr "기울기 편집됨" #: editor/plugins/item_list_editor_plugin.cpp msgid "Item %d" -msgstr "항목 %d" +msgstr "항목 %d개" #: editor/plugins/item_list_editor_plugin.cpp msgid "Items" @@ -6277,9 +6289,8 @@ msgid "Can only set point into a ParticlesMaterial process material" msgstr "ParticlesMaterial 프로세스 머티리얼 안에만 점을 설정할 수 있습니다" #: editor/plugins/particles_2d_editor_plugin.cpp -#, fuzzy msgid "Convert to CPUParticles2D" -msgstr "CPU파티클로 변환" +msgstr "CPUParticles2D로 변환" #: editor/plugins/particles_2d_editor_plugin.cpp #: editor/plugins/particles_editor_plugin.cpp @@ -6567,18 +6578,16 @@ msgid "Move Points" msgstr "점 이동" #: editor/plugins/polygon_2d_editor_plugin.cpp -#, fuzzy msgid "Command: Rotate" -msgstr "드래그: 회전" +msgstr "Command: 회전" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Shift: Move All" msgstr "Shift: 모두 이동" #: editor/plugins/polygon_2d_editor_plugin.cpp -#, fuzzy msgid "Shift+Command: Scale" -msgstr "Shift+Ctrl: 크기 조절" +msgstr "Shift+Command: 크기 조절" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Ctrl: Rotate" @@ -6625,14 +6634,12 @@ msgid "Radius:" msgstr "반지름:" #: editor/plugins/polygon_2d_editor_plugin.cpp -#, fuzzy msgid "Copy Polygon to UV" -msgstr "폴리곤 & UV 만들기" +msgstr "폴리곤을 UV로 복사" #: editor/plugins/polygon_2d_editor_plugin.cpp -#, fuzzy msgid "Copy UV to Polygon" -msgstr "Polygon2D로 변환" +msgstr "UV를 폴리곤으로 복사" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Clear UV" @@ -6891,7 +6898,7 @@ msgstr "모두 저장" #: editor/plugins/script_editor_plugin.cpp msgid "Soft Reload Script" -msgstr "스크립트 새로고침" +msgstr "스크립트 일반 새로고침" #: editor/plugins/script_editor_plugin.cpp msgid "Copy Script Path" @@ -7118,7 +7125,7 @@ msgstr "주석 토글" #: editor/plugins/script_text_editor.cpp msgid "Fold/Unfold Line" -msgstr "행 펼치기/접기" +msgstr "행 접기/펼치기" #: editor/plugins/script_text_editor.cpp msgid "Fold All Lines" @@ -7162,7 +7169,7 @@ msgstr "파일에서 찾기..." #: editor/plugins/script_text_editor.cpp msgid "Contextual Help" -msgstr "상황에 맞는 도움" +msgstr "상황에 맞는 도움말" #: editor/plugins/script_text_editor.cpp msgid "Toggle Bookmark" @@ -7178,7 +7185,7 @@ msgstr "이전 북마크로 이동" #: editor/plugins/script_text_editor.cpp msgid "Remove All Bookmarks" -msgstr "모든 북마크 삭제" +msgstr "모든 북마크 제거" #: editor/plugins/script_text_editor.cpp msgid "Go to Function..." @@ -7195,7 +7202,7 @@ msgstr "중단점 토글" #: editor/plugins/script_text_editor.cpp msgid "Remove All Breakpoints" -msgstr "중단점 모두 삭제" +msgstr "중단점 모두 제거" #: editor/plugins/script_text_editor.cpp msgid "Go to Next Breakpoint" @@ -7314,9 +7321,8 @@ msgid "Yaw" msgstr "요" #: editor/plugins/spatial_editor_plugin.cpp -#, fuzzy msgid "Size" -msgstr "크기: " +msgstr "크기" #: editor/plugins/spatial_editor_plugin.cpp msgid "Objects Drawn" @@ -7544,7 +7550,7 @@ msgstr "" #: editor/plugins/spatial_editor_plugin.cpp msgid "Use Local Space" -msgstr "로컬 스페이스 사용" +msgstr "로컬 공간 사용" #: editor/plugins/spatial_editor_plugin.cpp msgid "Use Snap" @@ -7601,7 +7607,7 @@ msgstr "변형" #: editor/plugins/spatial_editor_plugin.cpp msgid "Snap Object to Floor" -msgstr "객체를 바닥에 스냅" +msgstr "개체를 바닥에 스냅" #: editor/plugins/spatial_editor_plugin.cpp msgid "Transform Dialog..." @@ -7814,7 +7820,7 @@ msgstr "선택한 프레임 없음" #: editor/plugins/sprite_frames_editor_plugin.cpp msgid "Add %d Frame(s)" -msgstr "%d개의 프레임 추가" +msgstr "프레임 %d개 추가" #: editor/plugins/sprite_frames_editor_plugin.cpp msgid "Add Frame" @@ -7861,9 +7867,8 @@ msgid "New Animation" msgstr "새 애니메이션" #: editor/plugins/sprite_frames_editor_plugin.cpp -#, fuzzy msgid "Speed:" -msgstr "속도 (FPS):" +msgstr "속도:" #: editor/plugins/sprite_frames_editor_plugin.cpp msgid "Loop" @@ -8121,7 +8126,7 @@ msgstr "테마 파일" #: editor/plugins/tile_map_editor_plugin.cpp msgid "Erase Selection" -msgstr "선택 지우기" +msgstr "선택 항목 지우기" #: editor/plugins/tile_map_editor_plugin.cpp msgid "Fix Invalid Tiles" @@ -8181,13 +8186,12 @@ msgid "Paint Tile" msgstr "타일 칠하기" #: editor/plugins/tile_map_editor_plugin.cpp -#, fuzzy msgid "" "Shift+LMB: Line Draw\n" "Shift+Command+LMB: Rectangle Paint" msgstr "" -"Shift+우클릭: 선 그리기\n" -"Shift+Ctrl+우클릭: 사각 영역 페인트" +"Shift+좌클릭: 선 그리기\n" +"Shift+Command+좌클릭: 사각 영역 페인트" #: editor/plugins/tile_map_editor_plugin.cpp msgid "" @@ -8227,7 +8231,7 @@ msgstr "TileSet에 텍스처를 추가합니다." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Remove selected Texture from TileSet." -msgstr "선택한 텍스처를 TileSet에서 삭제." +msgstr "선택한 텍스처를 TileSet에서 제거합니다." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Create from Scene" @@ -8342,23 +8346,20 @@ msgid "Create a new rectangle." msgstr "새로운 사각형을 만듭니다." #: editor/plugins/tile_set_editor_plugin.cpp -#, fuzzy msgid "New Rectangle" -msgstr "사각 영역 칠하기" +msgstr "새 사각 영역" #: editor/plugins/tile_set_editor_plugin.cpp msgid "Create a new polygon." msgstr "새로운 폴리곤을 만듭니다." #: editor/plugins/tile_set_editor_plugin.cpp -#, fuzzy msgid "New Polygon" -msgstr "폴리곤 이동" +msgstr "새 폴리곤" #: editor/plugins/tile_set_editor_plugin.cpp -#, fuzzy msgid "Delete Selected Shape" -msgstr "선택 항목 삭제" +msgstr "선택된 모양 삭제" #: editor/plugins/tile_set_editor_plugin.cpp msgid "Keep polygon inside region Rect." @@ -8719,7 +8720,6 @@ msgid "Add Node to Visual Shader" msgstr "노드를 비주얼 셰이더에 추가" #: editor/plugins/visual_shader_editor_plugin.cpp -#, fuzzy msgid "Node(s) Moved" msgstr "노드 이동됨" @@ -8741,9 +8741,8 @@ msgid "Visual Shader Input Type Changed" msgstr "비주얼 셰이더 입력 유형 변경됨" #: editor/plugins/visual_shader_editor_plugin.cpp -#, fuzzy msgid "UniformRef Name Changed" -msgstr "Uniform 이름 설정" +msgstr "UniformRef 이름 변경됨" #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Vertex" @@ -8924,7 +8923,7 @@ msgstr "꼭짓점과 프래그먼트 셰이더 모드에 대한 '%s' 입력 매 #: editor/plugins/visual_shader_editor_plugin.cpp msgid "'%s' input parameter for fragment and light shader modes." -msgstr "꼭짓점과 프래그먼트 셰이더 모드에 대한 '%s' 입력 매개변수." +msgstr "프래그먼트과 조명 셰이더 모드에 대한 '%s' 입력 매개변수." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "'%s' input parameter for fragment shader mode." @@ -9017,7 +9016,7 @@ msgstr "매개변수의 역쌍곡탄젠트 값을 반환합니다." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "" "Finds the nearest integer that is greater than or equal to the parameter." -msgstr "매개변수보다 크거나 같은 가장 가까운 정수를 찾아요." +msgstr "매개변수보다 크거나 같은 가장 가까운 정수를 찾습니다." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Constrains a value to lie between two further values." @@ -9045,7 +9044,7 @@ msgstr "2가 밑인 지수 함수." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Finds the nearest integer less than or equal to the parameter." -msgstr "매개변수보다 적거나 같은 가장 가까운 정수를 찾아요." +msgstr "매개변수보다 적거나 같은 가장 가까운 정수를 찾습니다." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Computes the fractional part of the argument." @@ -9098,11 +9097,11 @@ msgstr "1.0 / 스칼라" #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Finds the nearest integer to the parameter." -msgstr "매개변수에서 가장 가까운 정수를 찾아요." +msgstr "매개변수에서 가장 가까운 정수를 찾습니다." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Finds the nearest even integer to the parameter." -msgstr "매개변수에서 가장 가까운 짝수 정수를 찾아요." +msgstr "매개변수에서 가장 가까운 짝수 정수를 찾습니다." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Clamps the value between 0.0 and 1.0." @@ -9741,8 +9740,8 @@ msgid "" "Couldn't load project.godot in project path (error %d). It may be missing or " "corrupted." msgstr "" -"프로젝트 경로에서 project.godot을 불러올 수 없습니다 (error %d). 누락되거나 " -"손상된 모양입니다." +"프로젝트 경로에서 project.godot을 불러올 수 없습니다 (오류 %d). 누락되거나 손" +"상된 모양입니다." #: editor/project_manager.cpp msgid "Couldn't edit project.godot in project path." @@ -9802,7 +9801,7 @@ msgstr "OpenGL ES 3.0" #: editor/project_manager.cpp msgid "Not supported by your GPU drivers." -msgstr "" +msgstr "당신의 GPU 드라이버에 의해 지원되지 않습니다." #: editor/project_manager.cpp msgid "" @@ -9974,9 +9973,8 @@ msgid "Projects" msgstr "프로젝트" #: editor/project_manager.cpp -#, fuzzy msgid "Loading, please wait..." -msgstr "미러를 검색 중입니다. 기다려주세요..." +msgstr "로드 중, 기다려 주세요..." #: editor/project_manager.cpp msgid "Last Modified" @@ -10348,6 +10346,11 @@ msgstr "오토로드" msgid "Plugins" msgstr "플러그인(Plugin)" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "기본값 불러오기" + #: editor/property_editor.cpp msgid "Preset..." msgstr "프리셋..." @@ -10426,7 +10429,7 @@ msgstr "정규 표현식 사용" #: editor/rename_dialog.cpp msgid "Advanced Options" -msgstr "고급 설정" +msgstr "고급 옵션" #: editor/rename_dialog.cpp msgid "Substitute" @@ -10458,7 +10461,7 @@ msgid "" "Compare counter options." msgstr "" "순차 정수 카운터.\n" -"카운터 설정과 비교합니다." +"카운터 옵션과 비교합니다." #: editor/rename_dialog.cpp msgid "Per-level Counter" @@ -10595,12 +10598,10 @@ msgid "Instance Child Scene" msgstr "자식 씬 인스턴스화" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "다른 씬에서 수행할 수 없는 작업입니다!" +msgstr "루트 노드를 같은 씬 안으로 붙여넣을 수 없습니다." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" msgstr "노드 붙여넣기" @@ -10730,7 +10731,6 @@ msgid "Attach Script" msgstr "스크립트 붙이기" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" msgstr "노드 잘라내기" @@ -11539,36 +11539,31 @@ msgstr "메시를 사용하려면 이 GridMap에 MeshLibrary 리소스를 주세 #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Begin Bake" -msgstr "" +msgstr "굽기 시작" #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Preparing data structures" -msgstr "" +msgstr "데이터 구조 준비 중" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Generate buffers" -msgstr "AABB 만들기" +msgstr "버퍼 생성" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Direct lighting" -msgstr "방향" +msgstr "조명 방향" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Indirect lighting" -msgstr "들여쓰기" +msgstr "간접 조명" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Post processing" msgstr "후처리" #: modules/lightmapper_cpu/lightmapper_cpu.cpp -#, fuzzy msgid "Plotting lightmaps" -msgstr "구분하는 조명:" +msgstr "구분하는 조명" #: modules/mono/csharp_script.cpp msgid "Class name can't be a reserved keyword" @@ -11580,11 +11575,11 @@ msgstr "내부 예외 스택 추적의 끝" #: modules/recast/navigation_mesh_editor_plugin.cpp msgid "Bake NavMesh" -msgstr "NavMesh 베이크" +msgstr "NavMesh 굽기" #: modules/recast/navigation_mesh_editor_plugin.cpp msgid "Clear the navigation mesh." -msgstr "내비게이션 메시 지우기." +msgstr "내비게이션 메시를 지웁니다." #: modules/recast/navigation_mesh_generator.cpp msgid "Setting up Configuration..." @@ -12082,15 +12077,15 @@ msgstr "목록에서 기기 선택" #: platform/android/export/export.cpp msgid "Unable to find the 'apksigner' tool." -msgstr "" +msgstr "'apksigner' 도구를 찾을 수 없습니다." #: platform/android/export/export.cpp msgid "" "Android build template not installed in the project. Install it from the " "Project menu." msgstr "" -"프로젝트에 안드로이드 빌드 템플릿을 설치하지 않았습니다. 프로젝트 메뉴에서 설" -"치하세요." +"프로젝트에 Android 빌드 템플릿을 설치하지 않았습니다. 프로젝트 메뉴에서 설치" +"하세요." #: platform/android/export/export.cpp msgid "Debug keystore not configured in the Editor Settings nor in the preset." @@ -12101,35 +12096,32 @@ msgid "Release keystore incorrectly configured in the export preset." msgstr "내보내기 프리셋에 배포 keystorke가 잘못 설정되어 있습니다." #: platform/android/export/export.cpp -#, fuzzy msgid "A valid Android SDK path is required in Editor Settings." -msgstr "편집기 설정에서 맞춤 빌드에 잘못된 안드로이드 SDK 경로입니다." +msgstr "편집기 설정에서 올바른 Android SDK 경로가 필요합니다." #: platform/android/export/export.cpp -#, fuzzy msgid "Invalid Android SDK path in Editor Settings." -msgstr "편집기 설정에서 맞춤 빌드에 잘못된 안드로이드 SDK 경로입니다." +msgstr "편집기 설정에서 잘못된 Android SDK 경로입니다." #: platform/android/export/export.cpp msgid "Missing 'platform-tools' directory!" -msgstr "" +msgstr "'platform-tools' 디렉터리가 없습니다!" #: platform/android/export/export.cpp msgid "Unable to find Android SDK platform-tools' adb command." -msgstr "" +msgstr "Android SDK platform-tools의 adb 명령을 찾을 수 없습니다." #: platform/android/export/export.cpp -#, fuzzy msgid "Please check in the Android SDK directory specified in Editor Settings." -msgstr "편집기 설정에서 맞춤 빌드에 잘못된 안드로이드 SDK 경로입니다." +msgstr "편집기 설정에서 지정된 Android SDK 디렉터리를 확인해주세요." #: platform/android/export/export.cpp msgid "Missing 'build-tools' directory!" -msgstr "" +msgstr "'build-tools' 디렉터리가 없습니다!" #: platform/android/export/export.cpp msgid "Unable to find Android SDK build-tools' apksigner command." -msgstr "" +msgstr "Android SDK build-tools의 apksigner 명령을 찾을 수 없습니다." #: platform/android/export/export.cpp msgid "Invalid public key for APK expansion." @@ -12193,8 +12185,8 @@ msgid "" "Trying to build from a custom built template, but no version info for it " "exists. Please reinstall from the 'Project' menu." msgstr "" -"맞춤 빌드 템플릿으로 빌드하려 했으나, 버전 정보가가 없습니다. '프로젝트' 메뉴" -"에서 다시 설치해주세요." +"맞춤 빌드 템플릿으로 빌드하려 했으나, 버전 정보가 없습니다. '프로젝트' 메뉴에" +"서 다시 설치해주세요." #: platform/android/export/export.cpp msgid "" @@ -12203,32 +12195,34 @@ msgid "" " Godot Version: %s\n" "Please reinstall Android build template from 'Project' menu." msgstr "" -"안드로이드 빌드 버전이 맞지 않음:\n" -" 설치한 템플릿: %s\n" +"Android 빌드 버전이 맞지 않음:\n" +" 설치된 템플릿: %s\n" " Godot 버전: %s\n" -"'프로젝트' 메뉴에서 안드로이드 빌드 템플릿을 다시 설치해주세요." +"'프로젝트' 메뉴에서 Android 빌드 템플릿을 다시 설치해주세요." #: platform/android/export/export.cpp msgid "Building Android Project (gradle)" -msgstr "안드로이드 프로젝트 빌드 중 (gradle)" +msgstr "Android 프로젝트 빌드 중 (gradle)" #: platform/android/export/export.cpp msgid "" "Building of Android project failed, check output for the error.\n" "Alternatively visit docs.godotengine.org for Android build documentation." msgstr "" -"안드로이드 프로젝트의 빌드에 실패했, 출력한 오류를 확인하세요.\n" -"또는 docs.godotengine.org에서 안드로이드 빌드 문서를 찾아 보세요." +"Android 프로젝트의 빌드에 실패했습니다, 출력된 오류를 확인하세요.\n" +"또는 docs.godotengine.org에서 Andoid 빌드 문서를 찾아보세요." #: platform/android/export/export.cpp msgid "Moving output" -msgstr "" +msgstr "출력 이동 중" #: platform/android/export/export.cpp msgid "" "Unable to copy and rename export file, check gradle project directory for " "outputs." msgstr "" +"내보내기 파일을 복사하고 이름을 바꿀 수 없습니다, 출력에 대한 gradle 프로젝" +"트 디렉터리를 확인하세요." #: platform/iphone/export/export.cpp msgid "Identifier is missing." @@ -12378,6 +12372,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "빈 CollisionPolygon2D는 충돌에 영향을 주지 않습니다." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12414,23 +12416,23 @@ msgstr "" #: scene/2d/joints_2d.cpp msgid "Node A and Node B must be PhysicsBody2Ds" -msgstr "" +msgstr "노드 A와 노드 B는 PhysicsBody2D여야 합니다" #: scene/2d/joints_2d.cpp msgid "Node A must be a PhysicsBody2D" -msgstr "" +msgstr "노드 A는 PhysicsBody2D여야 합니다" #: scene/2d/joints_2d.cpp msgid "Node B must be a PhysicsBody2D" -msgstr "" +msgstr "노드 B는 PhysicsBody2D여야 합니다" #: scene/2d/joints_2d.cpp msgid "Joint is not connected to two PhysicsBody2Ds" -msgstr "" +msgstr "관절이 PhysicsBody2D 두 곳과 연결되어 있지 않습니다" #: scene/2d/joints_2d.cpp msgid "Node A and Node B must be different PhysicsBody2Ds" -msgstr "" +msgstr "노드 A와 노드 B는 서로 다른 PhysicsBody2D여야 합니다" #: scene/2d/light_2d.cpp msgid "" @@ -12579,27 +12581,23 @@ msgstr "ARVROrigin은 자식으로 ARVRCamera 노드가 필요합니다." #: scene/3d/baked_lightmap.cpp msgid "Finding meshes and lights" -msgstr "" +msgstr "메시 및 조명 찾는 중" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Preparing geometry (%d/%d)" -msgstr "형태 분석 중..." +msgstr "형태 준비 중 (%d/%d)" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Preparing environment" -msgstr "환경 보기" +msgstr "환경 준비 중" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Generating capture" -msgstr "라이트맵 생성 중" +msgstr "캡처 생성 중" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Saving lightmaps" -msgstr "라이트맵 생성 중" +msgstr "라이트맵 저장 중" #: scene/3d/baked_lightmap.cpp msgid "Done" @@ -12690,11 +12688,6 @@ msgstr "" "GIProbe는 GLES2 비디오 드라이버에서 지원하지 않습니다.\n" "대신 BakedLightmap을 사용하세요." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera는 더 이상 사용되지 않으며 Godot 4.0에서 제거됩니다." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight의 각도를 90도 이상으로 잡게되면 그림자를 투영할 수 없습니다." @@ -12759,23 +12752,23 @@ msgstr "" #: scene/3d/physics_joint.cpp msgid "Node A and Node B must be PhysicsBodies" -msgstr "" +msgstr "노드 A와 노드 B는 PhysicsBody여야 합니다" #: scene/3d/physics_joint.cpp msgid "Node A must be a PhysicsBody" -msgstr "" +msgstr "노드 A는 PhysicsBody여야 합니다" #: scene/3d/physics_joint.cpp msgid "Node B must be a PhysicsBody" -msgstr "" +msgstr "노드 B는 PhysicsBodies여야 합니다" #: scene/3d/physics_joint.cpp msgid "Joint is not connected to any PhysicsBodies" -msgstr "" +msgstr "관절이 어떠한 PhysicsBody에도 연결되어 있지 않습니다" #: scene/3d/physics_joint.cpp msgid "Node A and Node B must be different PhysicsBodies" -msgstr "" +msgstr "노드 A와 노드 B는 서로 다른 PhysicsBody여야 합니다" #: scene/3d/remote_transform.cpp msgid "" @@ -12940,9 +12933,8 @@ msgid "Must use a valid extension." msgstr "올바른 확장자를 사용해야 합니다." #: scene/gui/graph_edit.cpp -#, fuzzy msgid "Enable grid minimap." -msgstr "스냅 켜기" +msgstr "그리드 미니맵을 활성화합니다." #: scene/gui/popup.cpp msgid "" @@ -13000,6 +12992,8 @@ msgid "" "The sampler port is connected but not used. Consider changing the source to " "'SamplerPort'." msgstr "" +"샘플러 포트가 연결되어 있지만 사용되지 않습이다. 소스를 'SamplerPort'로 변경" +"하는 것을 고려해주세요." #: scene/resources/visual_shader_nodes.cpp msgid "Invalid source for preview." @@ -13029,6 +13023,11 @@ msgstr "Varying은 꼭짓점 함수에만 지정할 수 있습니다." msgid "Constants cannot be modified." msgstr "상수는 수정할 수 없습니다." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "InterpolatedCamera는 더 이상 사용되지 않으며 Godot 4.0에서 제거됩니다." + #~ msgid "No" #~ msgstr "아니오" @@ -14815,9 +14814,6 @@ msgstr "상수는 수정할 수 없습니다." #~ msgid "Use Default Light" #~ msgstr "기본 Light 사용" -#~ msgid "Use Default sRGB" -#~ msgstr "기본 sRGB 사용" - #~ msgid "Default Light Normal:" #~ msgstr "기본 라이트 노말:" diff --git a/editor/translations/lt.po b/editor/translations/lt.po index 313d6144e3..585e4d4447 100644 --- a/editor/translations/lt.po +++ b/editor/translations/lt.po @@ -1854,8 +1854,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3986,6 +3986,20 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Pasirinkite Nodus, kuriuos norite importuoti" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importuoti Animacijas..." + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5080,7 +5094,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategorija:" @@ -10257,6 +10270,10 @@ msgstr "" msgid "Plugins" msgstr "Priedai" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12263,6 +12280,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12518,11 +12543,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/lv.po b/editor/translations/lv.po index 8f70ed94f7..5512d59238 100644 --- a/editor/translations/lv.po +++ b/editor/translations/lv.po @@ -1841,8 +1841,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3923,6 +3923,20 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Izvēlēties Šablona Failu" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Ielādēt Noklusējumu" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Failā" @@ -4974,7 +4988,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10082,6 +10095,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Ielādēt Noklusējumu" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12065,6 +12083,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12320,11 +12346,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/mi.po b/editor/translations/mi.po index 301383d787..260543a475 100644 --- a/editor/translations/mi.po +++ b/editor/translations/mi.po @@ -1788,8 +1788,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3865,6 +3865,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4916,7 +4928,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9944,6 +9955,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11893,6 +11908,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12148,11 +12171,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/mk.po b/editor/translations/mk.po index 1b01a6f792..cd72ecd259 100644 --- a/editor/translations/mk.po +++ b/editor/translations/mk.po @@ -1795,8 +1795,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3872,6 +3872,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4923,7 +4935,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9951,6 +9962,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11900,6 +11915,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12155,11 +12178,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ml.po b/editor/translations/ml.po index 71693f68dd..fb9de4a419 100644 --- a/editor/translations/ml.po +++ b/editor/translations/ml.po @@ -1798,8 +1798,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3877,6 +3877,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4931,7 +4943,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9961,6 +9972,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11911,6 +11926,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12166,11 +12189,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/mr.po b/editor/translations/mr.po index a07cd2a007..cf3a24a739 100644 --- a/editor/translations/mr.po +++ b/editor/translations/mr.po @@ -1795,8 +1795,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3872,6 +3872,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4923,7 +4935,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9952,6 +9963,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11901,6 +11916,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12156,11 +12179,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ms.po b/editor/translations/ms.po index 9019b6b0e4..c0a7f7cea2 100644 --- a/editor/translations/ms.po +++ b/editor/translations/ms.po @@ -1865,8 +1865,8 @@ msgid "Open a File or Directory" msgstr "Buka Fail atau Direktori" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Simpan" @@ -4192,6 +4192,21 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Pilih Nod(Nod-nod) untuk Diimport" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Import" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Muatkan Lalai" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -5248,7 +5263,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10302,6 +10316,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Muatkan Lalai" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12263,6 +12282,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12518,11 +12545,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/nb.po b/editor/translations/nb.po index 1289275b3d..9e69510739 100644 --- a/editor/translations/nb.po +++ b/editor/translations/nb.po @@ -3,24 +3,25 @@ # Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). # This file is distributed under the same license as the Godot source code. # Allan Nordhøy <epost@anotheragency.no>, 2017-2018, 2019, 2020, 2021. -# Anonymous <GentleSaucepan@protonmail.com>, 2017. +# Anonymous <GentleSaucepan@protonmail.com>, 2017, 2021. # Elias <eliasnykrem@gmail.com>, 2018. # flesk <eivindkn@gmail.com>, 2017, 2019. -# Frank T. Rambol <frank@d-fect.com>, 2018. +# Frank T. Rambol <frank@d-fect.com>, 2018, 2021. # Jørgen Aarmo Lund <jorgen.aarmo@gmail.com>, 2016, 2019. -# NicolaiF <nico-fre@hotmail.com>, 2017-2018, 2019. +# NicolaiF <nico-fre@hotmail.com>, 2017-2018, 2019, 2021. # Norwegian Disaster <stian.furu.overbye@gmail.com>, 2017. # passeride <lukas@passeride.com>, 2017. # Byzantin <kasper-hoel@hotmail.com>, 2018. # Hans-Marius Øverås <hansmariusoveras@gmail.com>, 2019. # Revolution <revosw@gmail.com>, 2019. # Petter Reinholdtsen <pere-weblate@hungry.com>, 2019, 2020. +# Patrick Sletvold <patricksletvold@hotmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-01-12 13:32+0000\n" -"Last-Translator: Allan Nordhøy <epost@anotheragency.no>\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" +"Last-Translator: Anonymous <GentleSaucepan@protonmail.com>\n" "Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/godot-" "engine/godot/nb_NO/>\n" "Language: nb\n" @@ -28,7 +29,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.4.1-dev\n" +"X-Generator: Weblate 4.5\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -200,7 +201,6 @@ msgid "Change Animation Loop" msgstr "Endre Animasjonssløyfe" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Property Track" msgstr "Egenskapsspor" @@ -209,24 +209,20 @@ msgid "3D Transform Track" msgstr "3D transformasjonsspor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Call Method Track" msgstr "Kall metode-spor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Bezier Curve Track" -msgstr "Bezier-kurvespor" +msgstr "Bézier-kurvespor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Audio Playback Track" msgstr "Lydavspillingsspor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Animation Playback Track" -msgstr "Stopp avspilling av animasjon. (S)" +msgstr "Animasjonavspillingspor" #: editor/animation_track_editor.cpp msgid "Animation length (frames)" @@ -241,7 +237,6 @@ msgid "Add Track" msgstr "Legg til Spor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Animation Looping" msgstr "Animasjonsløkke" @@ -260,23 +255,20 @@ msgid "Anim Clips:" msgstr "Anim-klipp:" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Change Track Path" -msgstr "Endre Array-verdi" +msgstr "Endre sporsti" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Toggle this track on/off." -msgstr "Vis/skjul distraksjonsfri modus." +msgstr "Slå spor på/av." #: editor/animation_track_editor.cpp msgid "Update Mode (How this property is set)" msgstr "Oppdateringsmodus (Hvordan denne egenskapen settes)" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Interpolation Mode" -msgstr "Animasjonsnode" +msgstr "Interpolasjonsmodus" #: editor/animation_track_editor.cpp msgid "Loop Wrap Mode (Interpolate end with beginning on loop)" @@ -334,7 +326,7 @@ msgstr "Pakk Inn Sløyfeinterp" #: editor/animation_track_editor.cpp #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Insert Key" -msgstr "Sett inn Nøkkel" +msgstr "Sett inn nøkkel" #: editor/animation_track_editor.cpp msgid "Duplicate Key(s)" @@ -345,19 +337,16 @@ msgid "Delete Key(s)" msgstr "Fjern Nøkler" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Change Animation Update Mode" -msgstr "Endre Animasjonsnavn:" +msgstr "Endre oppdateringsmetode for animasjon" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Change Animation Interpolation Mode" -msgstr "Animasjonsnode" +msgstr "Endre interpolasjonsmodus for animasjon" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Change Animation Loop Mode" -msgstr "Endre Anim-Løkke" +msgstr "Endre løkkemodus for animasjon" #: editor/animation_track_editor.cpp msgid "Remove Anim Track" @@ -412,9 +401,8 @@ msgid "Rearrange Tracks" msgstr "Omorganiser Spor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Transform tracks only apply to Spatial-based nodes." -msgstr "Transformasjonsspor kan kun brukes på Spatial-baserte noder." +msgstr "Transformeringsspor virker kun på Spatial-baserte noder." #: editor/animation_track_editor.cpp msgid "" @@ -438,47 +426,40 @@ msgstr "" "En animansjonsavspiller kan ikke animere seg selv, kun andre avspillere." #: editor/animation_track_editor.cpp -#, fuzzy msgid "Not possible to add a new track without a root" msgstr "Ikke mulig å legge til et nytt spor uten en rot" #: editor/animation_track_editor.cpp msgid "Invalid track for Bezier (no suitable sub-properties)" -msgstr "" +msgstr "Ugyldig spor for Bézier (ingen passende underegenskaper)" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Add Bezier Track" -msgstr "Anim Legg til Spor" +msgstr "Legg til Bézier-spor" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Track path is invalid, so can't add a key." msgstr "Sporsti er ugyldig, så kan ikke legge til en nøkkel." #: editor/animation_track_editor.cpp -#, fuzzy msgid "Track is not of type Spatial, can't insert key" -msgstr "Spor er ikke av type Spatial, kan ikke legge til nøkkel" +msgstr "Spor er ikke av typen Spatial, kan ikke sette inn nøkkel" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Add Transform Track Key" -msgstr "3D transformasjonsspor" +msgstr "Legg til transformasjons-spornøkkel" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Add Track Key" -msgstr "Anim Legg til Spor" +msgstr "Legg til spornøkkel" #: editor/animation_track_editor.cpp msgid "Track path is invalid, so can't add a method key." msgstr "Sporsti er ugyldig, så kan ikke legge til en metodenøkkel." #: editor/animation_track_editor.cpp -#, fuzzy msgid "Add Method Track Key" -msgstr "Kall metode-spor" +msgstr "Legg til metode-spornøkkel" #: editor/animation_track_editor.cpp msgid "Method not found in object: " @@ -489,26 +470,22 @@ msgid "Anim Move Keys" msgstr "Anim Flytt Nøkler" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Clipboard is empty" -msgstr "Ressurs-utklippstavle er tom!" +msgstr "Utklippstavlen er tom" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Paste Tracks" -msgstr "Lim inn Parametre" +msgstr "Sett in spor" #: editor/animation_track_editor.cpp msgid "Anim Scale Keys" msgstr "Anim Skalér Nøkler" #: editor/animation_track_editor.cpp -#, fuzzy msgid "" "This option does not work for Bezier editing, as it's only a single track." msgstr "" -"Dette valget virker ikke på Bezier-redigering, siden det kun er ett enkelt " -"spor." +"Dette valget virker ikke på Bézier-redigering, da det kun er ett enkelt spor." #: editor/animation_track_editor.cpp msgid "" @@ -522,10 +499,19 @@ msgid "" "Alternatively, use an import preset that imports animations to separate " "files." msgstr "" +"Denne animasjonen hører til en importert scene, så endringer på importerte " +"spor vil ikke bli lagret.\n" +"\n" +"For å legge til egendefinerte spor, gå til scenens importinstillinger og " +"sett\n" +"\"Animasjon > Lagring\" til \"Filer\", aktiver \"Animasjon > Behold egne spor" +"\", og importer på nytt.\n" +"Alternativt, bruk et importoppsett som importerer animasjonen som separate " +"filer." #: editor/animation_track_editor.cpp msgid "Warning: Editing imported animation" -msgstr "" +msgstr "Advarsel: Redigerer importert animasjon" #: editor/animation_track_editor.cpp #, fuzzy @@ -570,9 +556,8 @@ msgid "Edit" msgstr "Rediger" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Animation properties." -msgstr "Animasjon" +msgstr "Animasjon egenskaper." #: editor/animation_track_editor.cpp #, fuzzy @@ -589,26 +574,23 @@ msgstr "Skaler Fra Peker" #: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp msgid "Duplicate Selection" -msgstr "Dupliser Utvalg" +msgstr "Dupliser utvalg" #: editor/animation_track_editor.cpp msgid "Duplicate Transposed" -msgstr "Dupliser Transponert" +msgstr "Dupliser transponert" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Delete Selection" -msgstr "Slett Valgte" +msgstr "Slett valgte" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Go to Next Step" -msgstr "Gå til Neste Steg" +msgstr "Gå til neste steg" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Go to Previous Step" -msgstr "Gå til Forrige Steg" +msgstr "Gå til forrige steg" #: editor/animation_track_editor.cpp msgid "Optimize Animation" @@ -671,9 +653,8 @@ msgid "Scale Ratio:" msgstr "Skaler Størrelsesforhold:" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Select Tracks to Copy" -msgstr "Velg spor å kopiere:" +msgstr "Velg spor å kopiere" #: editor/animation_track_editor.cpp editor/editor_log.cpp #: editor/editor_properties.cpp @@ -690,9 +671,8 @@ msgid "Select All/None" msgstr "Kutt Noder" #: editor/animation_track_editor_plugins.cpp -#, fuzzy msgid "Add Audio Track Clip" -msgstr "Lydklipp:" +msgstr "Legg til lyd-spor klipp" #: editor/animation_track_editor_plugins.cpp msgid "Change Audio Track Clip Start Offset" @@ -723,19 +703,16 @@ msgid "Line Number:" msgstr "Linjenummer:" #: editor/code_editor.cpp -#, fuzzy msgid "%d replaced." -msgstr "Erstatt..." +msgstr "%d erstattet." #: editor/code_editor.cpp editor/editor_help.cpp -#, fuzzy msgid "%d match." -msgstr "%d samsvar." +msgstr "%d samsvarer." #: editor/code_editor.cpp editor/editor_help.cpp -#, fuzzy msgid "%d matches." -msgstr "Ingen Treff" +msgstr "%d sammsvarer." #: editor/code_editor.cpp editor/find_in_files.cpp msgid "Match Case" @@ -760,7 +737,7 @@ msgstr "Kun Valgte" #: editor/code_editor.cpp editor/plugins/script_text_editor.cpp #: editor/plugins/text_editor.cpp msgid "Standard" -msgstr "" +msgstr "Standard" #: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp msgid "Toggle Scripts Panel" @@ -791,9 +768,8 @@ msgid "Line and column numbers." msgstr "Linje- og kolonnenummer." #: editor/connections_dialog.cpp -#, fuzzy msgid "Method in target node must be specified." -msgstr "Metode i mål-Node må spesifiseres!" +msgstr "Metode i målnoden må spesifiseres." #: editor/connections_dialog.cpp #, fuzzy @@ -820,13 +796,12 @@ msgid "Connect to Script:" msgstr "Kan ikke koble til tjener:" #: editor/connections_dialog.cpp -#, fuzzy msgid "From Signal:" -msgstr "Signaler:" +msgstr "Fra signal:" #: editor/connections_dialog.cpp msgid "Scene does not contain any script." -msgstr "" +msgstr "Scenen inneholder ikke noen skript." #: editor/connections_dialog.cpp editor/editor_autoload_settings.cpp #: editor/groups_editor.cpp editor/plugins/item_list_editor_plugin.cpp @@ -854,14 +829,12 @@ msgid "Extra Call Arguments:" msgstr "Ekstra Call Argumenter:" #: editor/connections_dialog.cpp -#, fuzzy msgid "Receiver Method:" -msgstr "Lim inn Noder" +msgstr "Mottakermetode:" #: editor/connections_dialog.cpp -#, fuzzy msgid "Advanced" -msgstr "Snapping innstillinger" +msgstr "Avansert" #: editor/connections_dialog.cpp msgid "Deferred" @@ -1064,9 +1037,8 @@ msgid "Fix Broken" msgstr "Reparer Ødelagt" #: editor/dependency_editor.cpp -#, fuzzy msgid "Dependency Editor" -msgstr "Avhengighetsredigeringsverktøy" +msgstr "Redigeringsverktøy for avhengigheter" #: editor/dependency_editor.cpp msgid "Search Replacement Resource:" @@ -1087,14 +1059,15 @@ msgid "Owners Of:" msgstr "Eiere Av:" #: editor/dependency_editor.cpp -#, fuzzy msgid "" "Remove selected files from the project? (no undo)\n" "You can find the removed files in the system trash to restore them." -msgstr "Fjerne valgte filer fra prosjektet? (kan ikke angres)" +msgstr "" +"Fjerne valgte filer fra prosjektet? (kan ikke angres)\n" +"Du kan finne de fjernede filene i systemets papirkurv, og gjenopprette dem " +"derfra." #: editor/dependency_editor.cpp -#, fuzzy msgid "" "The files being removed are required by other resources in order for them to " "work.\n" @@ -1102,7 +1075,9 @@ msgid "" "You can find the removed files in the system trash to restore them." msgstr "" "Filene som fjernes kreves for at andre ressurser skal virke.\n" -"Fjern dem likevel? (kan ikke angres)" +"Fjerne dem likevel? (kan ikke angres)\n" +"Du kan finne de fjernede filene i systemets papirkurv, og gjenopprette dem " +"derfra." #: editor/dependency_editor.cpp msgid "Cannot remove:" @@ -1163,14 +1138,12 @@ msgid "Resources Without Explicit Ownership:" msgstr "Ressurser uten eksplisitt eierskap:" #: editor/dictionary_property_edit.cpp -#, fuzzy msgid "Change Dictionary Key" -msgstr "Endre Ordboksnøkkel" +msgstr "Endre listenøkkel" #: editor/dictionary_property_edit.cpp -#, fuzzy msgid "Change Dictionary Value" -msgstr "Endre Ordboksverdi" +msgstr "Endre listeverdi" #: editor/editor_about.cpp msgid "Thanks from the Godot community!" @@ -1444,7 +1417,6 @@ msgid "There is no '%s' file." msgstr "Det finnes ingen «%s»-fil" #: editor/editor_audio_buses.cpp editor/plugins/canvas_item_editor_plugin.cpp -#, fuzzy msgid "Layout" msgstr "Layout" @@ -1453,9 +1425,8 @@ msgid "Invalid file, not an audio bus layout." msgstr "Ugyldig fil, ikke et audio bus oppsett." #: editor/editor_audio_buses.cpp -#, fuzzy msgid "Error saving file: %s" -msgstr "Error ved lagring av TileSet!" +msgstr "Feil ved lagring av filen: %s" #: editor/editor_audio_buses.cpp msgid "Add Bus" @@ -1643,7 +1614,6 @@ msgid "Storing File:" msgstr "Lagrer Fil:" #: editor/editor_export.cpp -#, fuzzy msgid "No export template found at the expected path:" msgstr "Ingen eksportmal funnet på forventet søkesti:" @@ -1770,7 +1740,7 @@ msgstr "Erstatt Alle" #: editor/editor_feature_profile.cpp msgid "Profile must be a valid filename and must not contain '.'" -msgstr "" +msgstr "Profil må være et gyldig filnavn, og kan ikke inneholde '.'" #: editor/editor_feature_profile.cpp #, fuzzy @@ -1797,9 +1767,8 @@ msgid "Class Options:" msgstr "Beskrivelse:" #: editor/editor_feature_profile.cpp -#, fuzzy msgid "Enable Contextual Editor" -msgstr "Åpne den neste Editoren" +msgstr "Aktiver kontekstavhengig redigeringsverktøy" #: editor/editor_feature_profile.cpp #, fuzzy @@ -1817,7 +1786,7 @@ msgstr "Søk i klasser" #: editor/editor_feature_profile.cpp msgid "File '%s' format is invalid, import aborted." -msgstr "" +msgstr "Filformatet til '%s' er ugyldig, importen ble avbrutt." #: editor/editor_feature_profile.cpp msgid "" @@ -1826,9 +1795,8 @@ msgid "" msgstr "" #: editor/editor_feature_profile.cpp -#, fuzzy msgid "Error saving profile to path: '%s'." -msgstr "Error ved lagring av TileSet!" +msgstr "Feil ved lagring av profilen til stien: '%s'." #: editor/editor_feature_profile.cpp msgid "Unset" @@ -1961,8 +1929,8 @@ msgid "Open a File or Directory" msgstr "Åpne ei fil eller mappe" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Lagre" @@ -2252,9 +2220,8 @@ msgid "Set" msgstr "Sett" #: editor/editor_inspector.cpp -#, fuzzy msgid "Set Multiple:" -msgstr "Sett Mange:" +msgstr "Sett mange:" #: editor/editor_log.cpp msgid "Output:" @@ -2286,9 +2253,8 @@ msgstr "Stopp" #: editor/editor_network_profiler.cpp editor/editor_profiler.cpp #: editor/plugins/animation_state_machine_editor.cpp editor/rename_dialog.cpp -#, fuzzy msgid "Start" -msgstr "Start!" +msgstr "Start" #: editor/editor_network_profiler.cpp msgid "%s/s" @@ -2370,7 +2336,7 @@ msgstr "Kan ikke åpne '%s'. Filen kan ha blitt flyttet eller slettet." #: editor/editor_node.cpp msgid "Error while parsing '%s'." -msgstr "Error ved parsing av '%s'." +msgstr "Feil ved parsing av '%s'." #: editor/editor_node.cpp msgid "Unexpected end of file '%s'." @@ -2401,7 +2367,6 @@ msgid "This operation can't be done without a tree root." msgstr "Denne operasjonen kan ikke gjennomføres uten en trerot." #: editor/editor_node.cpp -#, fuzzy msgid "" "This scene can't be saved because there is a cyclic instancing inclusion.\n" "Please resolve it and then attempt to save again." @@ -2428,7 +2393,7 @@ msgstr "Kan ikke laste MeshLibrary for sammenslåing!" #: editor/editor_node.cpp msgid "Error saving MeshLibrary!" -msgstr "Error ved lagring av MeshLibrary!" +msgstr "Feil ved lagring av MeshLibrary!" #: editor/editor_node.cpp msgid "Can't load TileSet for merging!" @@ -2436,7 +2401,7 @@ msgstr "Kan ikke laste TileSet for sammenslåing!" #: editor/editor_node.cpp msgid "Error saving TileSet!" -msgstr "Error ved lagring av TileSet!" +msgstr "Feil ved lagring av TileSet!" #: editor/editor_node.cpp msgid "" @@ -2619,7 +2584,7 @@ msgstr "Ja" #: editor/editor_node.cpp msgid "Exit the editor?" -msgstr "Avslutt editoren?" +msgstr "Avslutt redigeringsverktøyet?" #: editor/editor_node.cpp msgid "Open Project Manager?" @@ -2686,7 +2651,8 @@ msgstr "" msgid "" "Unable to load addon script from path: '%s' Base type is not EditorPlugin." msgstr "" -"Kan ikke laste addon skript fra bane: Basistype '%s' er ikke en EditorPlugin." +"Kan ikke laste addon-skript fra stien: Basistypen '%s' er ikke en " +"EditorPlugin." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s' Script is not in tool mode." @@ -2924,7 +2890,7 @@ msgstr "Versjon:" #: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp msgid "Set Up Version Control" -msgstr "" +msgstr "Sett opp versjonskontroll" #: editor/editor_node.cpp msgid "Shut Down Version Control" @@ -2940,9 +2906,8 @@ msgid "Install Android Build Template..." msgstr "" #: editor/editor_node.cpp -#, fuzzy msgid "Open Project Data Folder" -msgstr "Åpne ProsjektManager?" +msgstr "Åpne prosjektdatamappe" #: editor/editor_node.cpp editor/plugins/tile_set_editor_plugin.cpp msgid "Tools" @@ -3029,17 +2994,16 @@ msgid "Synchronize Scene Changes" msgstr "Synkroniser Sceneendringer" #: editor/editor_node.cpp -#, fuzzy msgid "" "When this option is enabled, any changes made to the scene in the editor " "will be replicated in the running project.\n" "When used remotely on a device, this is more efficient when the network " "filesystem option is enabled." msgstr "" -"Når denne innstillingen er aktivert, alle endringer gjort til scenen i " -"editoren vil bli replikert i det kjørende spillet.\n" -"Når det brukes eksternt på en enhet, dette er mer effektivt med et " -"nettverksfilsystem." +"Når denne innstillingen er aktivert, vil alle endringer gjort i scenen i " +"redigeringsverktøyet bli gjenspeilet i det kjørende spillet.\n" +"Når det brukes eksternt på en enhet, er dette mer effektivt med et " +"nettverksfilsystem aktivert." #: editor/editor_node.cpp #, fuzzy @@ -3189,9 +3153,8 @@ msgid "Save & Restart" msgstr "Lagre & Avslutt" #: editor/editor_node.cpp -#, fuzzy msgid "Spins when the editor window redraws." -msgstr "Snurrer når editorvinduet rendrer om!" +msgstr "Snurrer når redigeringsvinduet tegner opp på nytt." #: editor/editor_node.cpp #, fuzzy @@ -3279,11 +3242,12 @@ msgid "Open & Run a Script" msgstr "Åpne & Kjør et Skript" #: editor/editor_node.cpp -#, fuzzy msgid "" "The following files are newer on disk.\n" "What action should be taken?" -msgstr "De følgende filene feilet ekstrahering fra pakke:" +msgstr "" +"Følgende filer er nyere på disken.\n" +"Hvilken handling skal utføres?" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp @@ -3302,7 +3266,7 @@ msgstr "Ny Arvet" #: editor/editor_node.cpp msgid "Load Errors" -msgstr "Last Errors" +msgstr "Last feil" #: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp msgid "Select" @@ -3310,11 +3274,11 @@ msgstr "Velg" #: editor/editor_node.cpp msgid "Open 2D Editor" -msgstr "Åpne 2D Editor" +msgstr "Åpne 2D-redigeringsverktøy" #: editor/editor_node.cpp msgid "Open 3D Editor" -msgstr "Åpne 3D Editor" +msgstr "Åpne 3D-redigeringsverktøy" #: editor/editor_node.cpp msgid "Open Script Editor" @@ -3326,16 +3290,15 @@ msgstr "Åpne Assets-Bibliotek" #: editor/editor_node.cpp msgid "Open the next Editor" -msgstr "Åpne den neste Editoren" +msgstr "Åpne det neste redigeringsverktøyet" #: editor/editor_node.cpp msgid "Open the previous Editor" -msgstr "Åpne den forrige Editoren" +msgstr "Åpne det forrige redigeringsverktøy" #: editor/editor_node.h -#, fuzzy msgid "Warning!" -msgstr "Advarsler" +msgstr "Advarsel!" #: editor/editor_path.cpp #, fuzzy @@ -3399,9 +3362,8 @@ msgid "Average Time (sec)" msgstr "Gjennomsnittstid (sek)" #: editor/editor_profiler.cpp -#, fuzzy msgid "Frame %" -msgstr "Frame %" +msgstr "Bilde %" #: editor/editor_profiler.cpp msgid "Physics Frame %" @@ -3416,9 +3378,8 @@ msgid "Self" msgstr "Selv" #: editor/editor_profiler.cpp -#, fuzzy msgid "Frame #:" -msgstr "Frame #:" +msgstr "Bilde #:" #: editor/editor_profiler.cpp #, fuzzy @@ -3595,7 +3556,7 @@ msgstr "" #: editor/editor_sub_scene.cpp msgid "Select Node(s) to Import" -msgstr "Velg Node(r) for Importering" +msgstr "Velg node(r) som skal importeres" #: editor/editor_sub_scene.cpp editor/project_manager.cpp #, fuzzy @@ -3645,9 +3606,8 @@ msgid "Retrieving mirrors, please wait..." msgstr "Henter fillager, vennligst vent..." #: editor/export_template_manager.cpp -#, fuzzy msgid "Remove template version '%s'?" -msgstr "Fjern mal versjon '%s'?" +msgstr "Fjern malversjon '%s'?" #: editor/export_template_manager.cpp msgid "Can't open export templates zip." @@ -3663,9 +3623,8 @@ msgid "No version.txt found inside templates." msgstr "Ingen version.txt funnet i mal." #: editor/export_template_manager.cpp -#, fuzzy msgid "Error creating path for templates:" -msgstr "Feil ved laging av sti for mal:\n" +msgstr "Feil ved laging av sti for maler:" #: editor/export_template_manager.cpp msgid "Extracting Export Templates" @@ -3850,14 +3809,12 @@ msgid "Cannot move/rename resources root." msgstr "Kan ikke flytte/endre navn ressursrot" #: editor/filesystem_dock.cpp -#, fuzzy msgid "Cannot move a folder into itself." -msgstr "Kan ikke flytte mappe inn i seg selv.\n" +msgstr "Kan ikke flytte en mappe inn i seg selv." #: editor/filesystem_dock.cpp -#, fuzzy msgid "Error moving:" -msgstr "Error ved flytting:\n" +msgstr "Feil ved flytting:" #: editor/filesystem_dock.cpp #, fuzzy @@ -3865,9 +3822,8 @@ msgid "Error duplicating:" msgstr "Feil ved innlasting:" #: editor/filesystem_dock.cpp -#, fuzzy msgid "Unable to update dependencies:" -msgstr "Kan ikke oppdatere av avhengigheter:\n" +msgstr "Kan ikke oppdatere avhengigheter:" #: editor/filesystem_dock.cpp editor/scene_tree_editor.cpp msgid "No name provided." @@ -4133,9 +4089,8 @@ msgid "Remove from Group" msgstr "Fjern fra Gruppe" #: editor/groups_editor.cpp -#, fuzzy msgid "Group name already exists." -msgstr "ERROR: Animasjonsnavnet finnes allerede!" +msgstr "Gruppenavnet finnes allerede." #: editor/groups_editor.cpp #, fuzzy @@ -4177,9 +4132,8 @@ msgid "Empty groups will be automatically removed." msgstr "" #: editor/groups_editor.cpp -#, fuzzy msgid "Group Editor" -msgstr "Åpne SkriptEditor" +msgstr "Redigeringsverktøy for grupper" #: editor/groups_editor.cpp #, fuzzy @@ -4237,7 +4191,7 @@ msgstr "Importerer Scene..." #: editor/import/resource_importer_scene.cpp msgid "Generating Lightmaps" -msgstr "Genererer Lyskart" +msgstr "Genererer lyskart" #: editor/import/resource_importer_scene.cpp msgid "Generating for Mesh: " @@ -4258,7 +4212,7 @@ msgstr "Ugyldig/ødelagt skript for post-import (sjekk konsoll):" #: editor/import/resource_importer_scene.cpp msgid "Error running post-import script:" -msgstr "Error ved kjøring av post-import script:" +msgstr "Feil ved kjøring av post-import script:" #: editor/import/resource_importer_scene.cpp msgid "Did you return a Node-derived object in the `post_import()` method?" @@ -4268,6 +4222,21 @@ msgstr "" msgid "Saving..." msgstr "Lagrer..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Velg Modus" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importer" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Last Standard" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Filer" @@ -4334,9 +4303,8 @@ msgid "Copy Params" msgstr "Kopier Parametre" #: editor/inspector_dock.cpp -#, fuzzy msgid "Edit Resource Clipboard" -msgstr "Ressurs-utklippstavle er tom!" +msgstr "Rediger ressurs-utklippstavlen" #: editor/inspector_dock.cpp msgid "Copy Resource" @@ -4447,16 +4415,14 @@ msgid "Create points." msgstr "Slett punkter" #: editor/plugins/abstract_polygon_2d_editor.cpp -#, fuzzy msgid "" "Edit points.\n" "LMB: Move Point\n" "RMB: Erase Point" msgstr "" -"Endre eksisterende polygon:\n" -"Venstreklikk: Flytt Punkt.\n" -"Ctrl+Venstreklikk: Splitt Segment.\n" -"Høyreklikk: Fjern Punkt." +"Rediger punkter.\n" +"Venstreklikk: Flytt punkt\n" +"Høyreklikk: Fjern punkt" #: editor/plugins/abstract_polygon_2d_editor.cpp #: editor/plugins/animation_blend_space_1d_editor.cpp @@ -4471,7 +4437,7 @@ msgstr "Rediger Poly" #: editor/plugins/abstract_polygon_2d_editor.cpp msgid "Insert Point" -msgstr "Sett inn Punkt" +msgstr "Sett inn punkt" #: editor/plugins/abstract_polygon_2d_editor.cpp #, fuzzy @@ -4588,9 +4554,8 @@ msgid "Open Animation Node" msgstr "Animasjonsnode" #: editor/plugins/animation_blend_space_2d_editor.cpp -#, fuzzy msgid "Triangle already exists." -msgstr "ERROR: Animasjonsnavnet finnes allerede!" +msgstr "Triangelet finnes allerede." #: editor/plugins/animation_blend_space_2d_editor.cpp #, fuzzy @@ -4792,14 +4757,12 @@ msgid "Remove Animation" msgstr "Fjern Animasjon" #: editor/plugins/animation_player_editor_plugin.cpp -#, fuzzy msgid "Invalid animation name!" -msgstr "ERROR: Ugyldig animasjonsnavn!" +msgstr "Ugyldig animasjonsnavn!" #: editor/plugins/animation_player_editor_plugin.cpp -#, fuzzy msgid "Animation name already exists!" -msgstr "ERROR: Animasjonsnavnet finnes allerede!" +msgstr "Animasjonsnavnet finnes allerede!" #: editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/sprite_frames_editor_plugin.cpp @@ -4824,14 +4787,12 @@ msgid "Duplicate Animation" msgstr "Dupliser Animasjon" #: editor/plugins/animation_player_editor_plugin.cpp -#, fuzzy msgid "No animation to copy!" -msgstr "ERROR: Ingen animasjon å kopiere!" +msgstr "Ingen animasjon å kopiere!" #: editor/plugins/animation_player_editor_plugin.cpp -#, fuzzy msgid "No animation resource on clipboard!" -msgstr "ERROR: Ingen animasjonsressurs på utklippstavlen!" +msgstr "Ingen animasjonsressurs på utklippstavlen!" #: editor/plugins/animation_player_editor_plugin.cpp msgid "Pasted Animation" @@ -4842,9 +4803,8 @@ msgid "Paste Animation" msgstr "Lim inn Animasjon" #: editor/plugins/animation_player_editor_plugin.cpp -#, fuzzy msgid "No animation to edit!" -msgstr "ERROR: Ingen animasjon å endre!" +msgstr "Ingen animasjon å redigere!" #: editor/plugins/animation_player_editor_plugin.cpp msgid "Play selected animation backwards from current pos. (A)" @@ -4968,7 +4928,7 @@ msgstr "Animasjonsnavn:" #: editor/plugins/script_editor_plugin.cpp #: editor/plugins/sprite_frames_editor_plugin.cpp editor/property_editor.cpp msgid "Error!" -msgstr "Error!" +msgstr "Feil!" #: editor/plugins/animation_player_editor_plugin.cpp msgid "Blend Times:" @@ -4990,9 +4950,8 @@ msgid "Move Node" msgstr "Flytt Modus" #: editor/plugins/animation_state_machine_editor.cpp -#, fuzzy msgid "Transition exists!" -msgstr "Overgang" +msgstr "Overgang eksisterer!" #: editor/plugins/animation_state_machine_editor.cpp #, fuzzy @@ -5002,7 +4961,7 @@ msgstr "Overgang" #: editor/plugins/animation_state_machine_editor.cpp #: modules/visual_script/visual_script_editor.cpp msgid "Add Node" -msgstr "" +msgstr "Legg til node" #: editor/plugins/animation_state_machine_editor.cpp msgid "End" @@ -5313,6 +5272,7 @@ msgid "Failed SHA-256 hash check" msgstr "Feilet sha256 hash-sjekk" #: editor/plugins/asset_library_editor_plugin.cpp +#, fuzzy msgid "Asset Download Error:" msgstr "Asset Nedlasting Error:" @@ -5350,7 +5310,7 @@ msgstr "Prøv på nytt" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Download Error" -msgstr "Nedlastningserror" +msgstr "Nedlastningsfeil" #: editor/plugins/asset_library_editor_plugin.cpp #, fuzzy @@ -5424,7 +5384,6 @@ msgid "Sort:" msgstr "Sorter:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategori:" @@ -6026,7 +5985,7 @@ msgstr "Plasser Utvalg I Midten" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Frame Selection" -msgstr "" +msgstr "Bildeutvalg" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Preview Canvas Scale" @@ -6112,7 +6071,7 @@ msgstr "Lag Node" #: editor/plugins/canvas_item_editor_plugin.cpp #: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp msgid "Error instancing scene from %s" -msgstr "Error ved instansiering av scene fra %s" +msgstr "Feil ved instansiering av scene fra %s" #: editor/plugins/canvas_item_editor_plugin.cpp #, fuzzy @@ -6138,7 +6097,7 @@ msgstr "Rediger Poly" #: editor/plugins/collision_polygon_editor_plugin.cpp msgid "Edit Poly (Remove Point)" -msgstr "Rediger Poly (Fjern Punkt)" +msgstr "Rediger Poly (fjern punkt)" #: editor/plugins/collision_shape_2d_editor_plugin.cpp #, fuzzy @@ -6498,11 +6457,12 @@ msgid "Remove item %d?" msgstr "Fjern element %d?" #: editor/plugins/mesh_library_editor_plugin.cpp -#, fuzzy msgid "" "Update from existing scene?:\n" "%s" -msgstr "Oppdater fra Scene" +msgstr "" +"Oppdater fra eksisterende scene?:\n" +"%s" #: editor/plugins/mesh_library_editor_plugin.cpp #, fuzzy @@ -6915,9 +6875,8 @@ msgid "Paint Bone Weights" msgstr "" #: editor/plugins/polygon_2d_editor_plugin.cpp -#, fuzzy msgid "Open Polygon 2D UV editor." -msgstr "Åpne 2D Editor" +msgstr "Åpne 2D-redigeringsverktøy for polygon-UV" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Polygon 2D UV Editor" @@ -7069,7 +7028,7 @@ msgstr "Skaler Polygon" #: editor/plugins/resource_preloader_editor_plugin.cpp msgid "ERROR: Couldn't load resource!" -msgstr "ERROR: Kunne ikke laste ressurs!" +msgstr "FEIL: Kunne ikke laste ressurs!" #: editor/plugins/resource_preloader_editor_plugin.cpp msgid "Add Resource" @@ -7132,16 +7091,12 @@ msgid "Clear Recent Files" msgstr "Fjern Nylige Filer" #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Close and save changes?" -msgstr "" -"Lukk og lagre endringer?\n" -"\"" +msgstr "Lukke og lagre endringer?" #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Error writing TextFile:" -msgstr "Error ved lagring av TileSet!" +msgstr "Feil ved lagring av TextFile:" #: editor/plugins/script_editor_plugin.cpp #, fuzzy @@ -7149,29 +7104,24 @@ msgid "Could not load file at:" msgstr "Kunne ikke opprette mappe." #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Error saving file!" -msgstr "Error ved lagring av TileSet!" +msgstr "Feil ved lagring av filen!" #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Error while saving theme." -msgstr "Error ved lasting av tema" +msgstr "Feil ved lagring av tema" #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Error Saving" -msgstr "Error ved lagring" +msgstr "Feil ved lagring" #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Error importing theme." -msgstr "Error ved importering av tema" +msgstr "Feil ved importering av tema." #: editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Error Importing" -msgstr "Error ved importering" +msgstr "Feil ved importering" #: editor/plugins/script_editor_plugin.cpp #, fuzzy @@ -7211,11 +7161,11 @@ msgstr "Importer Tema" #: editor/plugins/script_editor_plugin.cpp msgid "Error while saving theme" -msgstr "Error ved lasting av tema" +msgstr "Feil ved lagring av tema" #: editor/plugins/script_editor_plugin.cpp msgid "Error saving" -msgstr "Error ved lagring" +msgstr "Feil ved lagring" #: editor/plugins/script_editor_plugin.cpp msgid "Save Theme As..." @@ -7741,9 +7691,8 @@ msgid "Yaw" msgstr "" #: editor/plugins/spatial_editor_plugin.cpp -#, fuzzy msgid "Size" -msgstr "Størrelse: " +msgstr "Størrelse" #: editor/plugins/spatial_editor_plugin.cpp msgid "Objects Drawn" @@ -8904,11 +8853,12 @@ msgid "Delete selected Rect." msgstr "Slett valgte filer?" #: editor/plugins/tile_set_editor_plugin.cpp -#, fuzzy msgid "" "Select current edited sub-tile.\n" "Click on another Tile to edit it." -msgstr "Velg Gjeldende Mappe" +msgstr "" +"Velg gjeldende redigerte underflis.\n" +"Klikk på en annen flis for å redigere den." #: editor/plugins/tile_set_editor_plugin.cpp #, fuzzy @@ -8916,13 +8866,16 @@ msgid "Delete polygon." msgstr "Slett punkter" #: editor/plugins/tile_set_editor_plugin.cpp -#, fuzzy msgid "" "LMB: Set bit on.\n" "RMB: Set bit off.\n" "Shift+LMB: Set wildcard bit.\n" "Click on another Tile to edit it." -msgstr "Velg Gjeldende Mappe" +msgstr "" +"Venstreklikk: Sett bit på.\n" +"Høyreklikk: Sett bit av.\n" +"Skift+venstreklikk: Sett jokertegn-bit.\n" +"Klikk på en annen flis for å redigere den." #: editor/plugins/tile_set_editor_plugin.cpp msgid "" @@ -8938,11 +8891,12 @@ msgid "" msgstr "" #: editor/plugins/tile_set_editor_plugin.cpp -#, fuzzy msgid "" "Select sub-tile to change its z index.\n" "Click on another Tile to edit it." -msgstr "Velg Gjeldende Mappe" +msgstr "" +"Velg underflis for å endre z-indeksen.\n" +"Klikk på en annen flis for å redigere den." #: editor/plugins/tile_set_editor_plugin.cpp msgid "Set Tile Region" @@ -10143,9 +10097,8 @@ msgid "Export Project" msgstr "Eksporter Prosjekt" #: editor/project_export.cpp -#, fuzzy msgid "Export mode?" -msgstr "Eksporter Prosjekt" +msgstr "Eksportmodus?" #: editor/project_export.cpp #, fuzzy @@ -10235,8 +10188,8 @@ msgid "" "Couldn't load project.godot in project path (error %d). It may be missing or " "corrupted." msgstr "" -"Kunne ikke laste project.godot i prosjekt sti (error %d). Den kan være " -"manglet eller korruptert." +"Kunne ikke laste project.godot i prosjektstien (feil %d). Den kan mangle " +"eller være korrupt." #: editor/project_manager.cpp msgid "Couldn't edit project.godot in project path." @@ -10407,25 +10360,28 @@ msgid "Are you sure to run %d projects at once?" msgstr "Er du sikker på at du vil kjøre mer enn ett prosjekt?" #: editor/project_manager.cpp -#, fuzzy msgid "" "Remove %d projects from the list?\n" "The project folders' contents won't be modified." -msgstr "Fjern prosjekt fra listen? (Mappeinnhold vil ikke bli modifisert)" +msgstr "" +"Fjern %s prosjekter fra listen?\n" +"Innhold i prosjektmappene vil ikke påvirkes." #: editor/project_manager.cpp -#, fuzzy msgid "" "Remove this project from the list?\n" "The project folder's contents won't be modified." -msgstr "Fjern prosjekt fra listen? (Mappeinnhold vil ikke bli modifisert)" +msgstr "" +"Fjern dette prosjektet fra listen?\n" +"Innhold i prosjektmappen vil ikke påvirkes." #: editor/project_manager.cpp -#, fuzzy msgid "" "Remove all missing projects from the list?\n" "The project folders' contents won't be modified." -msgstr "Fjern prosjekt fra listen? (Mappeinnhold vil ikke bli modifisert)" +msgstr "" +"Fjern alle manglende prosjekter fra listen?\n" +"Innhold i prosjektmappene vil ikke påvirkes." #: editor/project_manager.cpp msgid "" @@ -10525,9 +10481,8 @@ msgid "" msgstr "" #: editor/project_settings_editor.cpp -#, fuzzy msgid "An action with the name '%s' already exists." -msgstr "ERROR: Animasjonsnavnet finnes allerede!" +msgstr "En handling med navnet '%s' finnes allerede." #: editor/project_settings_editor.cpp msgid "Rename Input Action Event" @@ -10828,10 +10783,14 @@ msgstr "" msgid "Plugins" msgstr "Innstikkmoduler" -#: editor/property_editor.cpp +#: editor/project_settings_editor.cpp #, fuzzy +msgid "Import Defaults" +msgstr "Last Standard" + +#: editor/property_editor.cpp msgid "Preset..." -msgstr "Preset..." +msgstr "Forhåndsinnstilt..." #: editor/property_editor.cpp msgid "Zero" @@ -10892,9 +10851,8 @@ msgid "Batch Rename" msgstr "Endre navn" #: editor/rename_dialog.cpp -#, fuzzy msgid "Replace:" -msgstr "Erstatt: " +msgstr "Erstatt:" #: editor/rename_dialog.cpp msgid "Prefix:" @@ -10933,9 +10891,8 @@ msgid "Node type" msgstr "Finn Node Type" #: editor/rename_dialog.cpp -#, fuzzy msgid "Current scene name" -msgstr "Gjeldende scene er ikke lagret. Åpne likevel?" +msgstr "Navn på gjeldende scene" #: editor/rename_dialog.cpp #, fuzzy @@ -11134,14 +11091,12 @@ msgid "Make node as Root" msgstr "Lagre Scene" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Delete %d nodes and any children?" -msgstr "Kutt Noder" +msgstr "Slett %d noder og eventuelle barn?" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Delete %d nodes?" -msgstr "Kutt Noder" +msgstr "Slett %d noder?" #: editor/scene_tree_dock.cpp msgid "Delete the root node \"%s\"?" @@ -11152,9 +11107,8 @@ msgid "Delete node \"%s\" and its children?" msgstr "" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Delete node \"%s\"?" -msgstr "Kutt Noder" +msgstr "Slett noden \"%s\"?" #: editor/scene_tree_dock.cpp msgid "Can not perform with the root node." @@ -11446,19 +11400,16 @@ msgid "Select a Node" msgstr "" #: editor/script_create_dialog.cpp -#, fuzzy msgid "Path is empty." -msgstr "Ressurs-utklippstavle er tom!" +msgstr "Stien er tom." #: editor/script_create_dialog.cpp -#, fuzzy msgid "Filename is empty." -msgstr "Ressurs-utklippstavle er tom!" +msgstr "Filnavnet er tomt." #: editor/script_create_dialog.cpp -#, fuzzy msgid "Path is not local." -msgstr "Sti leder ikke Node!" +msgstr "Stien er ikke lokal." #: editor/script_create_dialog.cpp #, fuzzy @@ -11505,9 +11456,8 @@ msgid "N/A" msgstr "" #: editor/script_create_dialog.cpp -#, fuzzy msgid "Open Script / Choose Location" -msgstr "Åpne SkriptEditor" +msgstr "Åpne skript / Velg plassering" #: editor/script_create_dialog.cpp #, fuzzy @@ -11602,19 +11552,16 @@ msgid "Warning:" msgstr "Advarsler:" #: editor/script_editor_debugger.cpp -#, fuzzy msgid "Error:" -msgstr "Error!" +msgstr "Feil:" #: editor/script_editor_debugger.cpp -#, fuzzy msgid "C++ Error" -msgstr "Last Errors" +msgstr "C++-feil" #: editor/script_editor_debugger.cpp -#, fuzzy msgid "C++ Error:" -msgstr "Last Errors" +msgstr "C++-feil:" #: editor/script_editor_debugger.cpp #, fuzzy @@ -11645,9 +11592,8 @@ msgid "Child process connected." msgstr "Frakoblet" #: editor/script_editor_debugger.cpp -#, fuzzy msgid "Copy Error" -msgstr "Last Errors" +msgstr "Kopier feil" #: editor/script_editor_debugger.cpp msgid "Video RAM" @@ -11912,7 +11858,7 @@ msgstr "" #: modules/gdscript/gdscript_functions.cpp msgid "Not a script with an instance" -msgstr "" +msgstr "Ikke et skript med en instans" #: modules/gdscript/gdscript_functions.cpp msgid "Not based on a script" @@ -12278,25 +12224,24 @@ msgid "Name is not a valid identifier:" msgstr "Navn er ikke en gyldig identifikator:" #: modules/visual_script/visual_script_editor.cpp -#, fuzzy msgid "Name already in use by another func/var/signal:" -msgstr "Navn er allerede i bruk av en annen func/var/signal:" +msgstr "Navnet er allerede i bruk av annen funk/var/signal:" #: modules/visual_script/visual_script_editor.cpp msgid "Rename Function" -msgstr "" +msgstr "Endre navn på funksjonen" #: modules/visual_script/visual_script_editor.cpp msgid "Rename Variable" -msgstr "" +msgstr "Endre navn på variabelen" #: modules/visual_script/visual_script_editor.cpp msgid "Rename Signal" -msgstr "" +msgstr "Endre navn på signalet" #: modules/visual_script/visual_script_editor.cpp msgid "Add Function" -msgstr "" +msgstr "Legg til funksjon" #: modules/visual_script/visual_script_editor.cpp #, fuzzy @@ -12305,11 +12250,11 @@ msgstr "Fjern punkt" #: modules/visual_script/visual_script_editor.cpp msgid "Add Variable" -msgstr "" +msgstr "Legg til variabel" #: modules/visual_script/visual_script_editor.cpp msgid "Add Signal" -msgstr "" +msgstr "Legg til signal" #: modules/visual_script/visual_script_editor.cpp #, fuzzy @@ -12323,7 +12268,7 @@ msgstr "Fjern punkt" #: modules/visual_script/visual_script_editor.cpp msgid "Change Expression" -msgstr "" +msgstr "Endre uttrykk" #: modules/visual_script/visual_script_editor.cpp msgid "Remove VisualScript Nodes" @@ -12343,6 +12288,8 @@ msgstr "" #: modules/visual_script/visual_script_editor.cpp msgid "Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature." msgstr "" +"Hold Ctrl for å slippe en Getter. Hold Skift for å slippe en generisk " +"signatur." #: modules/visual_script/visual_script_editor.cpp #, fuzzy @@ -12351,7 +12298,7 @@ msgstr "Hold Meta for å slippe en enkel referanse til noden." #: modules/visual_script/visual_script_editor.cpp msgid "Hold Ctrl to drop a simple reference to the node." -msgstr "Hold Ctrl for å slippe en simpel referanse til noden." +msgstr "Hold Ctrl for å slippe en enkel referanse til noden." #: modules/visual_script/visual_script_editor.cpp #, fuzzy @@ -12471,19 +12418,19 @@ msgstr "Fjern Funksjon" #: modules/visual_script/visual_script_editor.cpp msgid "Remove Variable" -msgstr "" +msgstr "Fjern variabel" #: modules/visual_script/visual_script_editor.cpp msgid "Editing Variable:" -msgstr "" +msgstr "Redigerer variabel:" #: modules/visual_script/visual_script_editor.cpp msgid "Remove Signal" -msgstr "" +msgstr "Fjern signal" #: modules/visual_script/visual_script_editor.cpp msgid "Editing Signal:" -msgstr "" +msgstr "Redigerer signal:" #: modules/visual_script/visual_script_editor.cpp #, fuzzy @@ -12577,7 +12524,7 @@ msgstr "Sti leder ikke Node!" #: modules/visual_script/visual_script_func_nodes.cpp msgid "Invalid index property name '%s' in node %s." -msgstr "Ugyldig indeks egenskap navn '%s' i node %s." +msgstr "Ugyldig navn for indeksegenskap '%s' i noden %s." #: modules/visual_script/visual_script_nodes.cpp msgid ": Invalid argument of type: " @@ -12927,6 +12874,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -13115,9 +13070,8 @@ msgid "Saving lightmaps" msgstr "Genererer Lyskart" #: scene/3d/baked_lightmap.cpp -#, fuzzy msgid "Done" -msgstr "Ferdig!" +msgstr "Ferdig" #: scene/3d/collision_object.cpp msgid "" @@ -13185,11 +13139,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" @@ -13319,9 +13268,8 @@ msgid "In node '%s', invalid animation: '%s'." msgstr "" #: scene/animation/animation_tree.cpp -#, fuzzy msgid "Invalid animation: '%s'." -msgstr "ERROR: Ugyldig animasjonsnavn!" +msgstr "Ugyldig animasjon: '%s'." #: scene/animation/animation_tree.cpp #, fuzzy diff --git a/editor/translations/nl.po b/editor/translations/nl.po index 1202219ee6..52c63ffa85 100644 --- a/editor/translations/nl.po +++ b/editor/translations/nl.po @@ -1899,8 +1899,8 @@ msgid "Open a File or Directory" msgstr "Bestand of map openen" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Opslaan" @@ -4113,6 +4113,21 @@ msgstr "" msgid "Saving..." msgstr "Opslaan..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Selecteermodus" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importeren" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Laad standaard" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Bestanden" @@ -5185,7 +5200,6 @@ msgid "Sort:" msgstr "Sorteren op:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categorie:" @@ -10471,6 +10485,11 @@ msgstr "Automatisch Laden" msgid "Plugins" msgstr "Plugins" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Laad standaard" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Voorinstelling..." @@ -12523,6 +12542,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Lege CollisionPolygon2D hebben geen botsingsfunctie." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12840,11 +12867,6 @@ msgstr "" "GIProbes worden niet ondersteund door het GLES2 grafische stuurprogramma.\n" "Gebruik in plaats daarvan een BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/or.po b/editor/translations/or.po index 269276221d..19b87260d6 100644 --- a/editor/translations/or.po +++ b/editor/translations/or.po @@ -1794,8 +1794,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3871,6 +3871,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4922,7 +4934,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9950,6 +9961,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11899,6 +11914,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12154,11 +12177,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/pl.po b/editor/translations/pl.po index 3cf039dd3b..173e86753f 100644 --- a/editor/translations/pl.po +++ b/editor/translations/pl.po @@ -51,7 +51,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" "Last-Translator: Tomek <kobewi4e@gmail.com>\n" "Language-Team: Polish <https://hosted.weblate.org/projects/godot-engine/" "godot/pl/>\n" @@ -1891,8 +1891,8 @@ msgid "Open a File or Directory" msgstr "Otwórz plik lub katalog" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Zapisz" @@ -2563,9 +2563,8 @@ msgstr "" "Nie można włączyć dodatku: \"%s\" - parsowanie konfiguracji nie powiodło się." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "Nie można odnaleźć pola skryptu w dodatku: \"res://addons/%s\"." +msgstr "Nie można odnaleźć pola skryptu w dodatku: \"%s\"." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4092,6 +4091,21 @@ msgstr "Czy zwracasz obiekt dziedziczący po Node w metodzie `post_import()`?" msgid "Saving..." msgstr "Zapisywanie..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Tryb zaznaczenia" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importuj" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Użyj domyślnie sRGB" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d plików" @@ -5060,9 +5074,8 @@ msgid "Got:" msgstr "Otrzymano:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Nie udało się przeprowadzić testu integralności sha256" +msgstr "Test SHA-256 nieudany" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5165,7 +5178,6 @@ msgid "Sort:" msgstr "Sortuj:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategoria:" @@ -8551,7 +8563,7 @@ msgstr "Edytuj wielokąt nawigacji" #: editor/plugins/tile_set_editor_plugin.cpp msgid "Paste Tile Bitmask" -msgstr "Wklej maskę bitową Kafelka" +msgstr "Wklej maskę bitową kafelka" #: editor/plugins/tile_set_editor_plugin.cpp msgid "Clear Tile Bitmask" @@ -10435,6 +10447,11 @@ msgstr "Autoładowanie" msgid "Plugins" msgstr "Wtyczki" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Wczytaj domyślny" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Ustawienie predefiniowane..." @@ -10684,14 +10701,12 @@ msgid "Instance Child Scene" msgstr "Dodaj instancję sceny" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "Nie można operować węzłami z innej sceny!" +msgstr "Nie można wkleić korzenia do tej samej sceny." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Wklej węzły" +msgstr "Wklej węzeł/y" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10820,9 +10835,8 @@ msgid "Attach Script" msgstr "Dołącz skrypt" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Wytnij węzły" +msgstr "Wytnij węzeł/y" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -12486,6 +12500,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Pusty CollisionPolygon2D nie ma wpływu na kolizje." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12807,12 +12829,6 @@ msgstr "" "GIProbes nie są obsługiwane przez sterownik wideo GLES2.\n" "Zamiast tego użyj BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" -"Węzeł InterpolatedCamera jest przestarzały i będzie usunięty w Godocie 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight z kątem szerszym niż 90 stopni nie może rzucać cieni." @@ -13152,6 +13168,12 @@ msgstr "Varying może być przypisane tylko w funkcji wierzchołków." msgid "Constants cannot be modified." msgstr "Stałe nie mogą być modyfikowane." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "Węzeł InterpolatedCamera jest przestarzały i będzie usunięty w Godocie " +#~ "4.0." + #~ msgid "No" #~ msgstr "Nie" @@ -14772,9 +14794,6 @@ msgstr "Stałe nie mogą być modyfikowane." #~ msgid "Use Default Light" #~ msgstr "Użyj domyślnego światła" -#~ msgid "Use Default sRGB" -#~ msgstr "Użyj domyślnie sRGB" - #~ msgid "Ambient Light Color:" #~ msgstr "Kolor światła otoczenia:" diff --git a/editor/translations/pr.po b/editor/translations/pr.po index ca53ec3af2..09d967e01d 100644 --- a/editor/translations/pr.po +++ b/editor/translations/pr.po @@ -1862,8 +1862,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -4004,6 +4004,19 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Slit th' Node" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5091,7 +5104,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10291,6 +10303,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12346,6 +12362,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12601,11 +12625,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/pt.po b/editor/translations/pt.po index 939735e8da..28325d59bc 100644 --- a/editor/translations/pt.po +++ b/editor/translations/pt.po @@ -1867,8 +1867,8 @@ msgid "Open a File or Directory" msgstr "Abrir um Ficheiro ou Diretoria" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Guardar" @@ -4076,6 +4076,21 @@ msgstr "Devolveu um objeto derivado de Nó no método `post_import()`?" msgid "Saving..." msgstr "A guardar..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Modo Seleção" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importar" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Carregar Predefinição" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Ficheiros" @@ -5147,7 +5162,6 @@ msgid "Sort:" msgstr "Ordenar:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoria:" @@ -10404,6 +10418,11 @@ msgstr "Carregamento automático" msgid "Plugins" msgstr "Plugins" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Carregar Predefinição" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Predefinição..." @@ -12459,6 +12478,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Um CollisionPolygon2D vazio não tem efeito na colisão." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12772,11 +12799,6 @@ msgstr "" "Sondas GI não são suportadas pelo driver vídeo GLES2.\n" "Em vez disso, use um BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamerda foi descontinuada e será removida no Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "Uma SpotLight com ângulo superior a 90 graus não cria sombras." @@ -13117,6 +13139,10 @@ msgstr "Variações só podem ser atribuídas na função vértice." msgid "Constants cannot be modified." msgstr "Constantes não podem ser modificadas." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamerda foi descontinuada e será removida no Godot 4.0." + #~ msgid "No" #~ msgstr "Não" diff --git a/editor/translations/pt_BR.po b/editor/translations/pt_BR.po index f4535819c2..4270648266 100644 --- a/editor/translations/pt_BR.po +++ b/editor/translations/pt_BR.po @@ -1959,8 +1959,8 @@ msgid "Open a File or Directory" msgstr "Abrir Arquivo ou Diretório" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Salvar" @@ -4173,6 +4173,21 @@ msgstr "Você retornou um objeto derivado de Nó no método `post_import()`?" msgid "Saving..." msgstr "Salvando..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Modo de Seleção" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importar" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Usar sRGB Padrão" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Arquivos" @@ -5250,7 +5265,6 @@ msgid "Sort:" msgstr "Ordenar:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categoria:" @@ -10519,6 +10533,11 @@ msgstr "O AutoLoad" msgid "Plugins" msgstr "Plugins" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Carregar Padrão" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Predefinição..." @@ -12576,6 +12595,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Um nó CollisionPolygon2D vazio não é efetivo para colisão." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12895,11 +12922,6 @@ msgstr "" "GIProbes não são suportados pelo driver de vídeo GLES2.\n" "Use um BakedLightmap em vez disso." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "IntepolatedCamera foi depreciada e será removida no Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "Um SpotLight com um ângulo maior que 90 graus não pode criar sombras." @@ -13243,6 +13265,10 @@ msgstr "Variáveis só podem ser atribuídas na função de vértice." msgid "Constants cannot be modified." msgstr "Constantes não podem serem modificadas." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "IntepolatedCamera foi depreciada e será removida no Godot 4.0." + #~ msgid "No" #~ msgstr "Não" @@ -14902,9 +14928,6 @@ msgstr "Constantes não podem serem modificadas." #~ msgid "Use Default Light" #~ msgstr "Usar Luz Padrão" -#~ msgid "Use Default sRGB" -#~ msgstr "Usar sRGB Padrão" - #~ msgid "Default Light Normal:" #~ msgstr "Luz Normal Padrão:" diff --git a/editor/translations/ro.po b/editor/translations/ro.po index 1843f25bf0..33f5264d71 100644 --- a/editor/translations/ro.po +++ b/editor/translations/ro.po @@ -1874,8 +1874,8 @@ msgid "Open a File or Directory" msgstr "Deschideți un Fişier sau Director" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Salvați" @@ -4056,6 +4056,21 @@ msgstr "" msgid "Saving..." msgstr "Se Salvează..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Selectare mod" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importare" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Încărcați Implicit" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Fișiere" @@ -5153,7 +5168,6 @@ msgid "Sort:" msgstr "Sorare:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Categorie:" @@ -10451,6 +10465,11 @@ msgstr "" msgid "Plugins" msgstr "Plugin-uri" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Încărcați Implicit" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Presetare..." @@ -12477,6 +12496,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12737,11 +12764,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ru.po b/editor/translations/ru.po index a38646e2e8..eec73e585a 100644 --- a/editor/translations/ru.po +++ b/editor/translations/ru.po @@ -96,7 +96,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" "Last-Translator: Danil Alexeev <danil@alexeev.xyz>\n" "Language-Team: Russian <https://hosted.weblate.org/projects/godot-engine/" "godot/ru/>\n" @@ -1939,8 +1939,8 @@ msgid "Open a File or Directory" msgstr "Открыть каталог или файл" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Сохранить" @@ -2615,9 +2615,8 @@ msgstr "" "конфигурации." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "Не удаётся найти поле script для плагина: «res://addons/%s»." +msgstr "Не удаётся найти поле script для плагина: «%s»." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4144,6 +4143,21 @@ msgstr "Вы вернули производный от Node объект в м msgid "Saving..." msgstr "Сохранение..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Режим выделения" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Импорт" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Использовать sRGB" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d файлов" @@ -5100,7 +5114,7 @@ msgstr "Время ожидания." #: editor/plugins/asset_library_editor_plugin.cpp msgid "Bad download hash, assuming file has been tampered with." -msgstr "Несовпадение хэша загрузки, возможно файл был изменён." +msgstr "Несовпадение хеша загрузки, возможно файл был изменён." #: editor/plugins/asset_library_editor_plugin.cpp msgid "Expected:" @@ -5111,9 +5125,8 @@ msgid "Got:" msgstr "Получено:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Не удалось проверить sha256 хэш" +msgstr "Не удалось проверить хеш SHA-256" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5216,7 +5229,6 @@ msgid "Sort:" msgstr "Сортировка:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Категория:" @@ -10479,6 +10491,11 @@ msgstr "Автозагрузка" msgid "Plugins" msgstr "Плагины" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Загрузить по умолчанию" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Предустановка..." @@ -10730,14 +10747,12 @@ msgid "Instance Child Scene" msgstr "Добавить дочернюю сцену" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "Не могу работать с узлами из внешней сцены!" +msgstr "Невозможно вставить корневой узел в ту же сцену." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" -msgstr "Вставить узлы" +msgstr "Вставить узел(узлы)" #: editor/scene_tree_dock.cpp msgid "Detach Script" @@ -10867,9 +10882,8 @@ msgid "Attach Script" msgstr "Прикрепить скрипт" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" -msgstr "Вырезать узлы" +msgstr "Вырезать узел(узлы)" #: editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -12526,6 +12540,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Пустой CollisionPolygon2D не влияет на столкновения." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12848,11 +12870,6 @@ msgstr "" "GIProbes не поддерживаются видеодрайвером GLES2.\n" "Вместо этого используйте BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera устарела и будет удалена в Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight с углом более 90 градусов не может отбрасывать тени." @@ -13193,6 +13210,10 @@ msgstr "Изменения могут быть назначены только msgid "Constants cannot be modified." msgstr "Константы не могут быть изменены." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera устарела и будет удалена в Godot 4.0." + #~ msgid "No" #~ msgstr "Нет" @@ -14856,9 +14877,6 @@ msgstr "Константы не могут быть изменены." #~ msgid "Use Default Light" #~ msgstr "Использовать стандартный свет" -#~ msgid "Use Default sRGB" -#~ msgstr "Использовать sRGB" - #~ msgid "Default Light Normal:" #~ msgstr "Образец стандартного освещения:" diff --git a/editor/translations/si.po b/editor/translations/si.po index 062cf64646..0c3a01f0e4 100644 --- a/editor/translations/si.po +++ b/editor/translations/si.po @@ -1818,8 +1818,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3900,6 +3900,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4962,7 +4974,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10029,6 +10040,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11997,6 +12012,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12252,11 +12275,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/sk.po b/editor/translations/sk.po index 9c179f743b..68da1b1221 100644 --- a/editor/translations/sk.po +++ b/editor/translations/sk.po @@ -1851,8 +1851,8 @@ msgid "Open a File or Directory" msgstr "Otvoriť súbor / priečinok" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Uložiť" @@ -4040,6 +4040,21 @@ msgstr "Vrátili ste Node-derived objekt v `post_import()` metóde?" msgid "Saving..." msgstr "Ukladám..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Vybrať Režim" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Import" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Načítať predvolené" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Súbory" @@ -5109,7 +5124,6 @@ msgid "Sort:" msgstr "Zoradiť:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategória:" @@ -10346,6 +10360,11 @@ msgstr "" msgid "Plugins" msgstr "Pluginy" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Načítať predvolené" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12371,6 +12390,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Prázdny CollisionPolygon2D nemá žiaden efekt na kolíziu." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12642,11 +12669,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/sl.po b/editor/translations/sl.po index 1c6d1c566b..69819f0a36 100644 --- a/editor/translations/sl.po +++ b/editor/translations/sl.po @@ -1936,8 +1936,8 @@ msgid "Open a File or Directory" msgstr "Odpri Datoteko ali Mapo" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Shrani" @@ -4209,6 +4209,21 @@ msgstr "" msgid "Saving..." msgstr "Shranjevanje..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Izberi Način" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Uvozi" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Naložite Prevzeto" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5349,7 +5364,6 @@ msgid "Sort:" msgstr "Razvrsti:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategorija:" @@ -10687,6 +10701,11 @@ msgstr "" msgid "Plugins" msgstr "Vtičniki" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Naložite Prevzeto" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Prednastavitev..." @@ -12767,6 +12786,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Prazen CollisionPolygon2D nima vpliva na collision." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -13033,11 +13060,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/sq.po b/editor/translations/sq.po index 09b3b2af2e..f53d0b630a 100644 --- a/editor/translations/sq.po +++ b/editor/translations/sq.po @@ -1887,8 +1887,8 @@ msgid "Open a File or Directory" msgstr "Hap një Skedar ose Direktori" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Ruaj" @@ -4132,6 +4132,21 @@ msgstr "" msgid "Saving..." msgstr "Duke Ruajtur..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Zgjidh Nyjet Për ti Importuar" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importo" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Ngarko të Parazgjedhur" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5205,7 +5220,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10337,6 +10351,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Ngarko të Parazgjedhur" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12350,6 +12369,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12607,11 +12634,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/sr_Cyrl.po b/editor/translations/sr_Cyrl.po index 26c5abcbc8..4fe901f414 100644 --- a/editor/translations/sr_Cyrl.po +++ b/editor/translations/sr_Cyrl.po @@ -2030,8 +2030,8 @@ msgid "Open a File or Directory" msgstr "Отвори датотеку или директоријум" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Сачувај" @@ -4415,6 +4415,21 @@ msgstr "" msgid "Saving..." msgstr "Чување..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Одабери режим" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Увоз" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Учитај уобичајено" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5612,7 +5627,6 @@ msgid "Sort:" msgstr "Сортирање:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Категорија:" @@ -11617,6 +11631,11 @@ msgstr "Ауто-Учитавање" msgid "Plugins" msgstr "Прикључци" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Учитај уобичајено" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Поставке..." @@ -14013,6 +14032,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Непријатењ СударниМногоугао2Д нема утицаја на судар." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp #, fuzzy msgid "" @@ -14367,11 +14394,6 @@ msgstr "" " \n" "Као замену користи ИспеченеСенкеМапу." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp #, fuzzy msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." diff --git a/editor/translations/sr_Latn.po b/editor/translations/sr_Latn.po index 47cb13691e..3d979c3fc6 100644 --- a/editor/translations/sr_Latn.po +++ b/editor/translations/sr_Latn.po @@ -1827,8 +1827,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3916,6 +3916,19 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Uduplaj Selekciju" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4985,7 +4998,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10110,6 +10122,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12088,6 +12104,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12343,11 +12367,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/sv.po b/editor/translations/sv.po index 420918548f..a7bc3d6288 100644 --- a/editor/translations/sv.po +++ b/editor/translations/sv.po @@ -1899,8 +1899,8 @@ msgid "Open a File or Directory" msgstr "Öppna en Fil eller Katalog" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Spara" @@ -4152,6 +4152,21 @@ msgstr "" msgid "Saving..." msgstr "Sparar..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Välj Node" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Importera" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Ladda Standard" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Filer" @@ -5266,7 +5281,6 @@ msgid "Sort:" msgstr "Sortera:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategori:" @@ -10576,6 +10590,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Ladda Standard" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12646,6 +12665,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "En tom CollisionPolygon2D har ingen effekt på kollision." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12924,11 +12951,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/ta.po b/editor/translations/ta.po index d1bc762e93..9f9f40b54b 100644 --- a/editor/translations/ta.po +++ b/editor/translations/ta.po @@ -1823,8 +1823,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3907,6 +3907,19 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "அனைத்து தேர்வுகள்" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4970,7 +4983,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10029,6 +10041,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11996,6 +12012,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12251,11 +12275,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/te.po b/editor/translations/te.po index 02a7a33269..50c0fb5a4b 100644 --- a/editor/translations/te.po +++ b/editor/translations/te.po @@ -1797,8 +1797,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3874,6 +3874,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4925,7 +4937,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9954,6 +9965,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11903,6 +11918,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12158,11 +12181,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/th.po b/editor/translations/th.po index 2026248122..76a2d3c125 100644 --- a/editor/translations/th.po +++ b/editor/translations/th.po @@ -1836,8 +1836,8 @@ msgid "Open a File or Directory" msgstr "เปิดไฟล์หรือโฟลเดอร์" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "บันทึก" @@ -3987,6 +3987,21 @@ msgstr "คุณส่งคืนออบเจกต์โหนดย่อ msgid "Saving..." msgstr "กำลังบันทึก..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "โหมดเลือก" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "นำเข้า" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "โหลดค่าเริ่มต้น" + #: editor/import_dock.cpp msgid "%d Files" msgstr "ไฟล์ %d" @@ -5047,7 +5062,6 @@ msgid "Sort:" msgstr "เรียงตาม:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "หมวดหมู่:" @@ -10231,6 +10245,11 @@ msgstr "ออโต้โหลด" msgid "Plugins" msgstr "ปลั๊กอิน" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "โหลดค่าเริ่มต้น" + #: editor/property_editor.cpp msgid "Preset..." msgstr "พรีเซ็ต..." @@ -12240,6 +12259,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "CollisionPolygon2D ที่ว่างเปล่าจะไม่มีผลทางกายภาพ" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12529,11 +12556,6 @@ msgstr "" "ไดรเวอร์วีดีโอ GLES2 ไม่สนับสนุน GIProbe\n" "ใช้ BakedLightmap แทน" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera เลิกใช้งานแล้วและจะถูกลบออกใน Godot 4.0" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight ที่มีมุมมากกว่า 90 ไม่สามารถสร้างเงา" @@ -12854,6 +12876,10 @@ msgstr "Varyings สามารถกำหนดในังก์ชันเ msgid "Constants cannot be modified." msgstr "ค่าคงที่ไม่สามารถแก้ไขได้" +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera เลิกใช้งานแล้วและจะถูกลบออกใน Godot 4.0" + #~ msgid "No" #~ msgstr "ไม่" diff --git a/editor/translations/tr.po b/editor/translations/tr.po index 568265764b..ecd57ee2cd 100644 --- a/editor/translations/tr.po +++ b/editor/translations/tr.po @@ -61,8 +61,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" -"Last-Translator: Cem Eren Fukara <cefukara@hotmail.com>\n" +"PO-Revision-Date: 2021-03-03 15:50+0000\n" +"Last-Translator: Oğuz Ersen <oguzersen@protonmail.com>\n" "Language-Team: Turkish <https://hosted.weblate.org/projects/godot-engine/" "godot/tr/>\n" "Language: tr\n" @@ -70,7 +70,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.5\n" +"X-Generator: Weblate 4.5.1-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1721,7 +1721,7 @@ msgstr "Dock Nod" #: editor/editor_feature_profile.cpp msgid "FileSystem Dock" -msgstr "Dosya sistemi" +msgstr "Dosya Sistemi" #: editor/editor_feature_profile.cpp msgid "Import Dock" @@ -1904,8 +1904,8 @@ msgid "Open a File or Directory" msgstr "Bir Dosya ya da Dizin Aç" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Kaydet" @@ -4111,6 +4111,21 @@ msgstr "`Post_import ()` yönteminde Node türevi bir nesne döndürdünüz mü? msgid "Saving..." msgstr "Kaydediliyor..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Kip Seç" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "İçe Aktar" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Önyüklü sRGB'yi Kullan" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d Dosya" @@ -5183,7 +5198,6 @@ msgid "Sort:" msgstr "Sırala:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Kategori:" @@ -10439,6 +10453,11 @@ msgstr "Otomatik Yükle" msgid "Plugins" msgstr "Eklentiler" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Varsayılanı Yükle" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Ön ayar..." @@ -12480,6 +12499,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Boş bir CollisionPolygon2D'nin çarpışmaya hiçbir etkisi yoktur." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12799,13 +12826,6 @@ msgstr "" "GIProbes GLES2 video sürücüsü tarafından desteklenmez.\n" "Bunun yerine bir BakedLightmap kullanın." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" -"InterpolatedCamera kullanımdan kaldırılmıştır ve Godot 4.0'da " -"kaldırılacaktır." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "90 dereceden geniş açılı SpotIşık gölge oluşturamaz." @@ -13149,6 +13169,12 @@ msgstr "varyings yalnızca vertex işlevinde atanabilir." msgid "Constants cannot be modified." msgstr "Sabit değerler değiştirilemez." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "InterpolatedCamera kullanımdan kaldırılmıştır ve Godot 4.0'da " +#~ "kaldırılacaktır." + #~ msgid "No" #~ msgstr "Hayır" @@ -14782,9 +14808,6 @@ msgstr "Sabit değerler değiştirilemez." #~ msgid "Use Default Light" #~ msgstr "Önyüklü Işık Kullan" -#~ msgid "Use Default sRGB" -#~ msgstr "Önyüklü sRGB'yi Kullan" - #~ msgid "Default Light Normal:" #~ msgstr "Önyüklü Işığın Olağanı:" diff --git a/editor/translations/tzm.po b/editor/translations/tzm.po index 67b5af0d44..c4614c7eb3 100644 --- a/editor/translations/tzm.po +++ b/editor/translations/tzm.po @@ -1795,8 +1795,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3872,6 +3872,18 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +msgid "Select Importer" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Importer:" +msgstr "" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp msgid "%d Files" msgstr "" @@ -4923,7 +4935,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -9951,6 +9962,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -11900,6 +11915,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12155,11 +12178,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/uk.po b/editor/translations/uk.po index 74f5becfea..4cdbe25d02 100644 --- a/editor/translations/uk.po +++ b/editor/translations/uk.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: Ukrainian (Godot Engine)\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" +"PO-Revision-Date: 2021-02-22 21:30+0000\n" "Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n" "Language-Team: Ukrainian <https://hosted.weblate.org/projects/godot-engine/" "godot/uk/>\n" @@ -1873,8 +1873,8 @@ msgid "Open a File or Directory" msgstr "Відкрити файл або каталог" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Зберегти" @@ -2548,10 +2548,8 @@ msgstr "" "налаштування." #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "" -"Не вдалося знайти поле скрипт для доповнення плагіну в: 'res://addons/%s'." +msgstr "Не вдалося знайти поле скрипту для додатка тут: «%s»." #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4084,6 +4082,21 @@ msgstr "Повернули об'єкт, що походить від Node, у м msgid "Saving..." msgstr "Збереження..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Режим виділення" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Імпорт" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Завантажити типовий" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d файлів" @@ -5056,9 +5069,8 @@ msgid "Got:" msgstr "Отримав:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" -msgstr "Помилка перевірки хешування sha256" +msgstr "Не вдалося пройти перевірку хешу SHA-256" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Asset Download Error:" @@ -5161,7 +5173,6 @@ msgid "Sort:" msgstr "Сортувати:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Категорія:" @@ -10438,6 +10449,11 @@ msgstr "Автозавантаження" msgid "Plugins" msgstr "Плаґіни (додатки)" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Завантажити типовий" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Заздалегідь установлений..." @@ -10689,12 +10705,10 @@ msgid "Instance Child Scene" msgstr "Створити екземпляр дочірньої сцени" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "Не можна працювати із вузлами зі сторонньої сцени!" +msgstr "Не можна вставляти кореневий вузол до сцени цього кореневого вузла." #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" msgstr "Вставити вузли" @@ -10825,7 +10839,6 @@ msgid "Attach Script" msgstr "Долучити скрипт" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" msgstr "Вирізати вузли" @@ -12508,6 +12521,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "Порожній CollisionPolygon2D ніяк не вплине на зіткнення." +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12829,12 +12850,6 @@ msgstr "" "У драйвері GLES2 не передбачено підтримки GIProbes.\n" "Скористайтеся замість них BakedLightmap." -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" -"InterpolatedCamera вважається застарілою, її буде вилучено у Godot 4.0." - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "SpotLight з кутом, який є більшим за 90 градусів, не може давати тіні." @@ -13180,6 +13195,11 @@ msgstr "Змінні величини можна пов'язувати лише msgid "Constants cannot be modified." msgstr "Сталі не можна змінювати." +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "" +#~ "InterpolatedCamera вважається застарілою, її буде вилучено у Godot 4.0." + #~ msgid "No" #~ msgstr "Ні" diff --git a/editor/translations/ur_PK.po b/editor/translations/ur_PK.po index eccfc5f710..a2e1decab6 100644 --- a/editor/translations/ur_PK.po +++ b/editor/translations/ur_PK.po @@ -1829,8 +1829,8 @@ msgid "Open a File or Directory" msgstr "" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "" @@ -3950,6 +3950,20 @@ msgstr "" msgid "Saving..." msgstr "" +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr ".تمام کا انتخاب" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr ".سپورٹ" + +#: editor/import_defaults_editor.cpp +msgid "Reset to Defaults" +msgstr "" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5026,7 +5040,6 @@ msgid "Sort:" msgstr "" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "" @@ -10201,6 +10214,10 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +msgid "Import Defaults" +msgstr "" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12207,6 +12224,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12462,11 +12487,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/vi.po b/editor/translations/vi.po index 3d01339f40..94692dc9b2 100644 --- a/editor/translations/vi.po +++ b/editor/translations/vi.po @@ -15,13 +15,15 @@ # Steve Dang <bynguu@outlook.com>, 2020. # Harry Mitchell <minhyh0987@gmail.com>, 2020. # HSGamer <huynhqtienvtag@gmail.com>, 2020. -# LetterC67 <hoangdeptoong@gmail.com>, 2020. +# LetterC67 <hoangdeptoong@gmail.com>, 2020, 2021. +# Rev <revolnoom7801@gmail.com>, 2021. +# SyliawDeV <thanhlongstranger@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-08-11 14:04+0000\n" -"Last-Translator: LetterC67 <hoangdeptoong@gmail.com>\n" +"PO-Revision-Date: 2021-03-08 15:33+0000\n" +"Last-Translator: Rev <revolnoom7801@gmail.com>\n" "Language-Team: Vietnamese <https://hosted.weblate.org/projects/godot-engine/" "godot/vi/>\n" "Language: vi\n" @@ -29,12 +31,13 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.2-dev\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp msgid "Invalid type argument to convert(), use TYPE_* constants." -msgstr "Hàm convert() có loại đối số không hợp lệ, sử dụng các hằng TYPE_*." +msgstr "" +"Hàm convert() có loại đối số không hợp lệ, hãy sử dụng các hằng TYPE_*." #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp msgid "Expected a string of length 1 (a character)." @@ -171,9 +174,8 @@ msgid "Anim Change Call" msgstr "Đổi Function Gọi Animation" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Anim Multi Change Keyframe Time" -msgstr "Đổi thời gian khung hình" +msgstr "Đổi nhiều thời gian khung hình" #: editor/animation_track_editor.cpp #, fuzzy @@ -206,26 +208,25 @@ msgstr "Chỉnh Vòng Lặp Hoạt Ảnh" #: editor/animation_track_editor.cpp msgid "Property Track" -msgstr "" +msgstr "Theo dõi đặc tính" #: editor/animation_track_editor.cpp msgid "3D Transform Track" -msgstr "" +msgstr "Theo dõi chuyển đổi 3D" #: editor/animation_track_editor.cpp msgid "Call Method Track" -msgstr "" +msgstr "Gọi phương thức theo dõi" #: editor/animation_track_editor.cpp msgid "Bezier Curve Track" -msgstr "" +msgstr "Theo dõi đường cong Bezier" #: editor/animation_track_editor.cpp msgid "Audio Playback Track" -msgstr "" +msgstr "Bản nhạc phát lại âm thanh" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Animation Playback Track" msgstr "Ngưng chạy animation. (S)" @@ -238,7 +239,6 @@ msgid "Animation length (seconds)" msgstr "Độ dài hoạt ảnh (giây)" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Add Track" msgstr "Thêm Track Animation" @@ -257,7 +257,7 @@ msgstr "Âm thanh:" #: editor/animation_track_editor.cpp msgid "Anim Clips:" -msgstr "" +msgstr "Hoạt ảnh:" #: editor/animation_track_editor.cpp msgid "Change Track Path" @@ -265,7 +265,7 @@ msgstr "Thay đổi đường dẫn Track" #: editor/animation_track_editor.cpp msgid "Toggle this track on/off." -msgstr "Bật tắt track này on/off." +msgstr "Bật hoặc tắt track này, on/off" #: editor/animation_track_editor.cpp msgid "Update Mode (How this property is set)" @@ -383,7 +383,7 @@ msgstr "Chèn Anim" #: editor/animation_track_editor.cpp msgid "AnimationPlayer can't animate itself, only other players." -msgstr "AnimationPlayer không thể tự tạo hoạt ảnh, chỉ các player khác." +msgstr "AnimationPlayer không thể tự tạo hoạt ảnh, phải nhờ các Player khác." #: editor/animation_track_editor.cpp msgid "Anim Create & Insert" @@ -407,7 +407,7 @@ msgstr "Sắp xếp lại Tracks" #: editor/animation_track_editor.cpp msgid "Transform tracks only apply to Spatial-based nodes." -msgstr "" +msgstr "Các chuyển đổi chỉ có thể áp dụng cho các node Spatial" #: editor/animation_track_editor.cpp msgid "" @@ -416,7 +416,7 @@ msgid "" "-AudioStreamPlayer2D\n" "-AudioStreamPlayer3D" msgstr "" -"Các bản âm thanh chỉ có thể trỏ đến các nút:\n" +"Các bản âm thanh chỉ có thể trỏ đến các loại:\n" "-AudioStreamPlayer\n" "-AudioStreamPlayer2D\n" "-AudioStreamPlayer3D" @@ -428,10 +428,11 @@ msgstr "Các bản hoạt ảnh chỉ có thể trỏ tới các nút AnimationP #: editor/animation_track_editor.cpp msgid "An animation player can't animate itself, only other players." msgstr "" +"Animation player không tự tạo hoạt ảnh được, phải thông qua các player khác." #: editor/animation_track_editor.cpp msgid "Not possible to add a new track without a root" -msgstr "" +msgstr "Không thể thêm track mới mà không có root." #: editor/animation_track_editor.cpp msgid "Invalid track for Bezier (no suitable sub-properties)" @@ -482,14 +483,13 @@ msgid "Paste Tracks" msgstr "Dán Tracks" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Anim Scale Keys" -msgstr "Anim Scale Keys" +msgstr "Key để scale hoạt ảnh" #: editor/animation_track_editor.cpp msgid "" "This option does not work for Bezier editing, as it's only a single track." -msgstr "" +msgstr "Tùy chọn này không áp lên Bezier được, vì nó chỉ là một track." #: editor/animation_track_editor.cpp msgid "" @@ -503,6 +503,16 @@ msgid "" "Alternatively, use an import preset that imports animations to separate " "files." msgstr "" +"Cáianimation này thuộc về một cảnh đã nhập, vì vậy những thay đổi đối với " +"các bản nhạc đã nhập sẽ không được lưu.\n" +"\n" +"Để bật khả năng thêm các bản nhạc tùy chỉnh, hãy điều hướng đến cài đặt nhập " +"của cảnh và đặt\n" +"\"animation > Lưu trữ\" thành \"Tệp\", bật \"Hoạt hình> Giữ các bản nhạc tùy " +"chỉnh\", sau đó nhập lại.(vn)\n" +"\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks" +"\", sau đó nhập lại (english).\n" +"Hoặc, sử dụng cài đặt trước nhập khẩu nhập hình ảnh động để tách các tệp." #: editor/animation_track_editor.cpp msgid "Warning: Editing imported animation" @@ -536,7 +546,7 @@ msgstr "Giây" #: editor/animation_track_editor.cpp #: editor/plugins/sprite_frames_editor_plugin.cpp msgid "FPS" -msgstr "" +msgstr "Khung hình(FPS)" #: editor/animation_track_editor.cpp editor/editor_properties.cpp #: editor/plugins/polygon_2d_editor_plugin.cpp @@ -554,7 +564,7 @@ msgstr "Thuộc tính hoạt cảnh." #: editor/animation_track_editor.cpp msgid "Copy Tracks" -msgstr "" +msgstr "Sao Chép Tracks" #: editor/animation_track_editor.cpp msgid "Scale Selection" @@ -570,7 +580,7 @@ msgstr "Nhân đôi lựa chọn" #: editor/animation_track_editor.cpp msgid "Duplicate Transposed" -msgstr "" +msgstr "Chuyển đổi trùng lặp" #: editor/animation_track_editor.cpp msgid "Delete Selection" @@ -598,7 +608,7 @@ msgstr "Chọn node để được làm diễn hoạt:" #: editor/animation_track_editor.cpp msgid "Use Bezier Curves" -msgstr "" +msgstr "Sử dụng đường cong Bezier" #: editor/animation_track_editor.cpp msgid "Anim. Optimizer" @@ -606,15 +616,15 @@ msgstr "Tối ưu hóa Animation" #: editor/animation_track_editor.cpp msgid "Max. Linear Error:" -msgstr "" +msgstr "Sai lệch tuyến tính lớn nhất:" #: editor/animation_track_editor.cpp msgid "Max. Angular Error:" -msgstr "" +msgstr "Sai lệch góc lớn nhất:" #: editor/animation_track_editor.cpp msgid "Max Optimizable Angle:" -msgstr "" +msgstr "Góc lớn nhất có thể tối ưu:" #: editor/animation_track_editor.cpp msgid "Optimize" @@ -622,7 +632,7 @@ msgstr "Tối ưu" #: editor/animation_track_editor.cpp msgid "Remove invalid keys" -msgstr "Gỡ bỏ các khoá không hợp lệ" +msgstr "Xóa các khoá không hợp lệ" #: editor/animation_track_editor.cpp msgid "Remove unresolved and empty tracks" @@ -659,9 +669,8 @@ msgid "Copy" msgstr "Sao chép" #: editor/animation_track_editor.cpp -#, fuzzy msgid "Select All/None" -msgstr "Chọn Không có" +msgstr "Chọn tất cả/ hoặc không" #: editor/animation_track_editor_plugins.cpp msgid "Add Audio Track Clip" @@ -669,19 +678,19 @@ msgstr "Thêm Track Âm thanh" #: editor/animation_track_editor_plugins.cpp msgid "Change Audio Track Clip Start Offset" -msgstr "" +msgstr "Thay đổi thời điểm bắt đầu phát track âm thanh." #: editor/animation_track_editor_plugins.cpp msgid "Change Audio Track Clip End Offset" -msgstr "" +msgstr "Thay đổi thời điểm kết thúc track âm thanh" #: editor/array_property_edit.cpp msgid "Resize Array" -msgstr "Đổi lại size Array" +msgstr "Thay đổi kích thước mảng" #: editor/array_property_edit.cpp msgid "Change Array Value Type" -msgstr "Đổi loại giá trị Array" +msgstr "Đổi kiểu giá trị Array" #: editor/array_property_edit.cpp msgid "Change Array Value" @@ -768,9 +777,8 @@ msgid "Method in target node must be specified." msgstr "Phương thức trong nút đích phải được chỉ định." #: editor/connections_dialog.cpp -#, fuzzy msgid "Method name must be a valid identifier." -msgstr "Phương thức trong nút đích phải được chỉ định." +msgstr "Tên phương thức phải được chỉ định." #: editor/connections_dialog.cpp msgid "" @@ -822,9 +830,8 @@ msgid "Extra Call Arguments:" msgstr "Mở rộng Đối số được gọi:" #: editor/connections_dialog.cpp -#, fuzzy msgid "Receiver Method:" -msgstr "Lọc các nút" +msgstr "Hàm nhận:" #: editor/connections_dialog.cpp msgid "Advanced" @@ -846,7 +853,7 @@ msgstr "Một lần" #: editor/connections_dialog.cpp msgid "Disconnects the signal after its first emission." -msgstr "Ngắt kết nối tín hiệu sau lần phát xạ đầu tiên." +msgstr "Ngắt kết nối tín hiệu sau lần phát đầu tiên." #: editor/connections_dialog.cpp msgid "Cannot connect signal" @@ -864,7 +871,7 @@ msgstr "Không thể kết nối tín hiệu" #: editor/run_settings_dialog.cpp editor/settings_config_dialog.cpp #: modules/visual_script/visual_script_editor.cpp msgid "Close" -msgstr "Tắt" +msgstr "Đóng" #: editor/connections_dialog.cpp msgid "Connect" @@ -912,9 +919,8 @@ msgid "Signals" msgstr "Tín hiệu (Signal)" #: editor/connections_dialog.cpp -#, fuzzy msgid "Filter signals" -msgstr "Lọc tệp tin ..." +msgstr "Lọc tín hiệu" #: editor/connections_dialog.cpp msgid "Are you sure you want to remove all connections from this signal?" @@ -978,7 +984,6 @@ msgid "Search Replacement For:" msgstr "Tìm kiếm thay thế cho:" #: editor/dependency_editor.cpp -#, fuzzy msgid "Dependencies For:" msgstr "Phần phụ thuộc cho:" @@ -1026,7 +1031,7 @@ msgstr "Trình chỉnh sửa Phụ thuộc" #: editor/dependency_editor.cpp msgid "Search Replacement Resource:" -msgstr "" +msgstr "Tìm kiếm tài nguyên thay thế:" #: editor/dependency_editor.cpp editor/editor_file_dialog.cpp #: editor/editor_help_search.cpp editor/editor_node.cpp @@ -1090,13 +1095,12 @@ msgid "Permanently delete %d item(s)? (No undo!)" msgstr "Xoá vĩnh viễn các đối tượng %d? (Không thể hoàn lại!)" #: editor/dependency_editor.cpp -#, fuzzy msgid "Show Dependencies" -msgstr "Phần phụ thuộc cho:" +msgstr "Hiện các phần phụ thuộc" #: editor/dependency_editor.cpp msgid "Orphan Resource Explorer" -msgstr "" +msgstr "Tìm tài nguyên mất gốc" #: editor/dependency_editor.cpp editor/editor_audio_buses.cpp #: editor/editor_file_dialog.cpp editor/editor_node.cpp @@ -1464,15 +1468,15 @@ msgstr "" #: editor/editor_autoload_settings.cpp msgid "Keyword cannot be used as an autoload name." -msgstr "" +msgstr "Từ khóa không thể dùng làm tên một nạp tự động." #: editor/editor_autoload_settings.cpp msgid "Autoload '%s' already exists!" -msgstr "" +msgstr "Nạp tự động '%s' đã tồn tại!" #: editor/editor_autoload_settings.cpp msgid "Rename Autoload" -msgstr "" +msgstr "Đổi tên" #: editor/editor_autoload_settings.cpp msgid "Toggle AutoLoad Globals" @@ -1875,8 +1879,8 @@ msgid "Open a File or Directory" msgstr "Mở một tệp tin hoặc thư mục" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "Lưu" @@ -2787,9 +2791,8 @@ msgid "Project Settings..." msgstr "Cài đặt Dự Án" #: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp -#, fuzzy msgid "Version Control" -msgstr "Phiên bản:" +msgstr "Theo dõi phiên bản" #: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp msgid "Set Up Version Control" @@ -2975,9 +2978,8 @@ msgid "Q&A" msgstr "Hỏi và Đáp" #: editor/editor_node.cpp -#, fuzzy msgid "Report a Bug" -msgstr "Nhập vào lại" +msgstr "Báo lỗi" #: editor/editor_node.cpp msgid "Send Docs Feedback" @@ -2989,7 +2991,7 @@ msgstr "Cộng đồng" #: editor/editor_node.cpp msgid "About" -msgstr "Thông tin chúng tôi" +msgstr "Về chúng tôi" #: editor/editor_node.cpp msgid "Play the project." @@ -3001,7 +3003,7 @@ msgstr "Chạy" #: editor/editor_node.cpp msgid "Pause the scene execution for debugging." -msgstr "" +msgstr "Dừng chạy Cảnh để gỡ lỗi." #: editor/editor_node.cpp msgid "Pause Scene" @@ -3029,7 +3031,7 @@ msgstr "Chạy Cảnh Tuỳ Chọn" #: editor/editor_node.cpp msgid "Changing the video driver requires restarting the editor." -msgstr "Thay đổi trình điều kiển Video, yêu cầu khởi động lại Trình biên tập." +msgstr "Thay đổi trình điều khiển Video cần phải khởi động lại Trình biên tập." #: editor/editor_node.cpp editor/project_settings_editor.cpp #: editor/settings_config_dialog.cpp @@ -3041,14 +3043,12 @@ msgid "Spins when the editor window redraws." msgstr "" #: editor/editor_node.cpp -#, fuzzy msgid "Update Continuously" -msgstr "Liên tục" +msgstr "Cập nhật Liên tục" #: editor/editor_node.cpp -#, fuzzy msgid "Update When Changed" -msgstr "Đối số đã thay đổi" +msgstr "Cập nhật khi có thay đổi" #: editor/editor_node.cpp msgid "Hide Update Spinner" @@ -3064,7 +3064,7 @@ msgstr "Quan Sát Viên" #: editor/editor_node.cpp msgid "Expand Bottom Panel" -msgstr "Mở rộng bảng điều khiển phía dưới" +msgstr "Mở rộng bảng điều khiển dưới" #: editor/editor_node.cpp msgid "Output" @@ -3093,7 +3093,7 @@ msgid "" "the \"Use Custom Build\" option should be enabled in the Android export " "preset." msgstr "" -"Điều này sẽ thiết lập dự án của bạn cho các bản dựng Android tùy chỉnh bằng " +"Việc này sẽ thiết lập dự án của bạn cho các bản dựng Android tùy chỉnh bằng " "cách cài đặt nguồn mẫu thành \"res://android/build\".\n" "Bạn có thể áp dụng các sửa đổi và xây dựng APK tùy chỉnh khi xuất (thêm các " "mô-đun, thay đổi AndroidManifest.xml, ...).\n" @@ -3136,16 +3136,18 @@ msgid "" "The following files are newer on disk.\n" "What action should be taken?" msgstr "" +"Các tệp sau xuất hiện trên ổ cứng gần đây hơn.\n" +"Bạn muốn làm gì đây?" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp msgid "Reload" -msgstr "" +msgstr "Tải lại" #: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp #: editor/plugins/shader_editor_plugin.cpp msgid "Resave" -msgstr "" +msgstr "Lưu lại" #: editor/editor_node.cpp msgid "New Inherited" @@ -3184,9 +3186,8 @@ msgid "Open the previous Editor" msgstr "" #: editor/editor_node.h -#, fuzzy msgid "Warning!" -msgstr "Cảnh báo" +msgstr "Cảnh báo!" #: editor/editor_path.cpp msgid "No sub-resources found." @@ -3201,9 +3202,8 @@ msgid "Thumbnail..." msgstr "" #: editor/editor_plugin_settings.cpp -#, fuzzy msgid "Main Script:" -msgstr "Tạo Script" +msgstr "Mã lệnh chính:" #: editor/editor_plugin_settings.cpp msgid "Edit Plugin" @@ -3244,7 +3244,7 @@ msgstr "" #: editor/editor_profiler.cpp msgid "Average Time (sec)" -msgstr "" +msgstr "Thời gian trung bình (giây)" #: editor/editor_profiler.cpp msgid "Frame %" @@ -3289,7 +3289,7 @@ msgstr "" #: editor/editor_properties.cpp msgid "Bit %d, value %d" -msgstr "" +msgstr "Bit %d, giá trị %d" #: editor/editor_properties.cpp msgid "[Empty]" @@ -4057,6 +4057,21 @@ msgstr "" msgid "Saving..." msgstr "Đang lưu ..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "Chế độ chọn" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "Nhập vào" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "Nạp mặc định" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5143,7 +5158,6 @@ msgid "Sort:" msgstr "Sắp xếp:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "Danh mục:" @@ -10414,6 +10428,11 @@ msgstr "" msgid "Plugins" msgstr "" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "Nạp mặc định" + #: editor/property_editor.cpp msgid "Preset..." msgstr "Cài sẵn ..." @@ -12465,6 +12484,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12720,11 +12747,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/zh_CN.po b/editor/translations/zh_CN.po index 3b0394b1d7..ac2d4a61f6 100644 --- a/editor/translations/zh_CN.po +++ b/editor/translations/zh_CN.po @@ -43,7 +43,7 @@ # Song DongHui <14729626293@163.com>, 2019. # simano clio <sim2cle@gmail.com>, 2019. # ByonkoGalilei <byonko@qq.com>, 2019. -# qjyqjyqjyqjy <qjyqjyqjyqjy@sina.com.cn>, 2019. +# qjyqjyqjyqjy <qjyqjyqjyqjy@sina.com.cn>, 2019, 2021. # liushuyu011 <liushuyu011@gmail.com>, 2019. # DS <dseqrasd@126.com>, 2019. # ZeroAurora <zeroaurora@qq.com>, 2019. @@ -76,11 +76,12 @@ # twoBornottwoB <305766341@qq.com>, 2021. # Magian <magian1127@gmail.com>, 2021. # Weiduo Xie <xwditfr@gmail.com>, 2021. +# suplife <2634557184@qq.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Chinese (Simplified) (Godot Engine)\n" "POT-Creation-Date: 2018-01-20 12:15+0200\n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" +"PO-Revision-Date: 2021-03-08 15:33+0000\n" "Last-Translator: Haoyu Qiu <timothyqiu32@gmail.com>\n" "Language-Team: Chinese (Simplified) <https://hosted.weblate.org/projects/" "godot-engine/godot/zh_Hans/>\n" @@ -89,7 +90,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.5\n" +"X-Generator: Weblate 4.5.1\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -98,13 +99,13 @@ msgstr "convert() 的参数类型无效,请使用 TYPE_* 常量。" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp msgid "Expected a string of length 1 (a character)." -msgstr "应为长度 1 的字符串(1 字符)。" +msgstr "应为长度为 1 的字符串(1 字符)。" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/mono/glue/gd_glue.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp msgid "Not enough bytes for decoding bytes, or invalid format." -msgstr "没有足够的字节可解码或格式无效。" +msgstr "解码字节数不够,或格式无效。" #: core/math/expression.cpp msgid "Invalid input %i (not passed) in expression" @@ -1898,8 +1899,8 @@ msgid "Open a File or Directory" msgstr "打开文件或目录" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "保存" @@ -2554,9 +2555,8 @@ msgid "Unable to enable addon plugin at: '%s' parsing of config failed." msgstr "无法在 “%s” 上启用加载项插件:配置解析失败。" #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "无法在 “res://addons/%s” 中找到加载项插件的脚本字段。" +msgstr "无法在 “%s” 上找到加载项的 script 字段。" #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -4044,6 +4044,21 @@ msgstr "有在 `post_import()` 方法中返回继承了 Node 的对象吗?" msgid "Saving..." msgstr "保存中..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "选择模式" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "导入" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "使用默认sRGB" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d 个文件" @@ -4704,7 +4719,7 @@ msgstr "过渡已存在!" #: editor/plugins/animation_state_machine_editor.cpp msgid "Add Transition" -msgstr "添加转换" +msgstr "添加过渡" #: editor/plugins/animation_state_machine_editor.cpp #: modules/visual_script/visual_script_editor.cpp @@ -4745,7 +4760,7 @@ msgstr "节点已移除" #: editor/plugins/animation_state_machine_editor.cpp msgid "Transition Removed" -msgstr "转换已移除" +msgstr "过渡已移除" #: editor/plugins/animation_state_machine_editor.cpp msgid "Set Start Node (Autoplay)" @@ -4968,7 +4983,7 @@ msgstr "无法将响应保存到:" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Write error." -msgstr "写错误。" +msgstr "写入错误。" #: editor/plugins/asset_library_editor_plugin.cpp msgid "Request failed, too many redirects" @@ -4999,7 +5014,6 @@ msgid "Got:" msgstr "获得:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" msgstr "SHA-256 哈希值校验失败" @@ -5104,7 +5118,6 @@ msgid "Sort:" msgstr "排序:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "分类:" @@ -10274,6 +10287,11 @@ msgstr "自动加载" msgid "Plugins" msgstr "插件" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "加载默认" + #: editor/property_editor.cpp msgid "Preset..." msgstr "预设..." @@ -10521,12 +10539,10 @@ msgid "Instance Child Scene" msgstr "实例化子场景" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "无法操作外部场景的节点!" +msgstr "不能将根节点粘贴进相同场景。" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" msgstr "粘贴节点" @@ -10653,7 +10669,6 @@ msgid "Attach Script" msgstr "添加脚本" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" msgstr "剪切节点" @@ -12269,6 +12284,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "空的 CollisionPolygon2D 不起任何碰撞检测作用。" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12555,11 +12578,6 @@ msgstr "" "GLES2 视频驱动程序不支持 GIProbes。\n" "请改用 BakedLightmap。" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera 已废弃,将在 Godot 4.0 中删除。" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "角度宽于 90 度的 SpotLight 无法投射出阴影。" @@ -12884,6 +12902,10 @@ msgstr "变量只能在顶点函数中指定。" msgid "Constants cannot be modified." msgstr "不允许修改常量。" +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera 已废弃,将在 Godot 4.0 中删除。" + #~ msgid "No" #~ msgstr "否" @@ -14531,9 +14553,6 @@ msgstr "不允许修改常量。" #~ msgid "Use Default Light" #~ msgstr "使用默认光照" -#~ msgid "Use Default sRGB" -#~ msgstr "使用默认sRGB" - #~ msgid "Default Light Normal:" #~ msgstr "默认光照法线:" diff --git a/editor/translations/zh_HK.po b/editor/translations/zh_HK.po index 728ecba4ba..2009ba8f20 100644 --- a/editor/translations/zh_HK.po +++ b/editor/translations/zh_HK.po @@ -1922,8 +1922,8 @@ msgid "Open a File or Directory" msgstr "選擇資料夾/檔案" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "儲存" @@ -4173,6 +4173,21 @@ msgstr "" msgid "Saving..." msgstr "儲存中..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "選擇模式" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "導入" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "預設" + #: editor/import_dock.cpp #, fuzzy msgid "%d Files" @@ -5313,7 +5328,6 @@ msgid "Sort:" msgstr "排序:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "分類:" @@ -10643,6 +10657,11 @@ msgstr "" msgid "Plugins" msgstr "插件" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "預設" + #: editor/property_editor.cpp msgid "Preset..." msgstr "" @@ -12735,6 +12754,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12992,11 +13019,6 @@ msgid "" "Use a BakedLightmap instead." msgstr "" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "" diff --git a/editor/translations/zh_TW.po b/editor/translations/zh_TW.po index 7ac1142466..5708d11522 100644 --- a/editor/translations/zh_TW.po +++ b/editor/translations/zh_TW.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-02-21 10:51+0000\n" +"PO-Revision-Date: 2021-02-27 00:47+0000\n" "Last-Translator: BinotaLIU <me@binota.org>\n" "Language-Team: Chinese (Traditional) <https://hosted.weblate.org/projects/" "godot-engine/godot/zh_Hant/>\n" @@ -1851,8 +1851,8 @@ msgid "Open a File or Directory" msgstr "開啟檔案或資料夾" #: editor/editor_file_dialog.cpp editor/editor_node.cpp -#: editor/editor_properties.cpp editor/inspector_dock.cpp -#: editor/plugins/animation_player_editor_plugin.cpp +#: editor/editor_properties.cpp editor/import_defaults_editor.cpp +#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp #: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp msgid "Save" msgstr "保存" @@ -2505,9 +2505,8 @@ msgid "Unable to enable addon plugin at: '%s' parsing of config failed." msgstr "無法在「%s」上啟用擴充功能,解析組態設定失敗。" #: editor/editor_node.cpp -#, fuzzy msgid "Unable to find script field for addon plugin at: '%s'." -msgstr "無法在擴充功能「res://addons/%s」中無法找到腳本欄位。" +msgstr "無法在擴充功能「r%s」中找到腳本欄位。" #: editor/editor_node.cpp msgid "Unable to load addon script from path: '%s'." @@ -3995,6 +3994,21 @@ msgstr "是否有在 `post_import()` 方法內回傳繼承 Node 之物件?" msgid "Saving..." msgstr "正在保存..." +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Select Importer" +msgstr "選擇模式" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Importer:" +msgstr "匯入" + +#: editor/import_defaults_editor.cpp +#, fuzzy +msgid "Reset to Defaults" +msgstr "載入預設" + #: editor/import_dock.cpp msgid "%d Files" msgstr "%d 個檔案" @@ -4950,7 +4964,6 @@ msgid "Got:" msgstr "獲得:" #: editor/plugins/asset_library_editor_plugin.cpp -#, fuzzy msgid "Failed SHA-256 hash check" msgstr "SHA-256 雜湊檢查失敗" @@ -5055,7 +5068,6 @@ msgid "Sort:" msgstr "排序:" #: editor/plugins/asset_library_editor_plugin.cpp -#: editor/project_settings_editor.cpp msgid "Category:" msgstr "分類:" @@ -10226,6 +10238,11 @@ msgstr "Autoload" msgid "Plugins" msgstr "外掛" +#: editor/project_settings_editor.cpp +#, fuzzy +msgid "Import Defaults" +msgstr "載入預設" + #: editor/property_editor.cpp msgid "Preset..." msgstr "預設設定..." @@ -10473,12 +10490,10 @@ msgid "Instance Child Scene" msgstr "實體化子場景" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Can't paste root node into the same scene." -msgstr "無法對外部場景的節點進行操作!" +msgstr "無法將跟節點貼到相同的場景中。" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Paste Node(s)" msgstr "貼上節點" @@ -10605,7 +10620,6 @@ msgid "Attach Script" msgstr "附加腳本" #: editor/scene_tree_dock.cpp -#, fuzzy msgid "Cut Node(s)" msgstr "剪下節點" @@ -12225,6 +12239,14 @@ msgstr "" msgid "An empty CollisionPolygon2D has no effect on collision." msgstr "空白的 CollisionPolygon2D 不會產生任何碰撞效果。" +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 3 points are needed in 'Solids' build mode." +msgstr "" + +#: scene/2d/collision_polygon_2d.cpp +msgid "Invalid polygon. At least 2 points are needed in 'Segments' build mode." +msgstr "" + #: scene/2d/collision_shape_2d.cpp msgid "" "CollisionShape2D only serves to provide a collision shape to a " @@ -12510,11 +12532,6 @@ msgstr "" "GLES2 視訊驅動程式不支援 GIProbes。\n" "請改為使用 BakedLightmap。" -#: scene/3d/interpolated_camera.cpp -msgid "" -"InterpolatedCamera has been deprecated and will be removed in Godot 4.0." -msgstr "InterpolatedCamera 已停止維護,且將於 Godot 4.0 中移除。" - #: scene/3d/light.cpp msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows." msgstr "角度大於 90 度的 SpotLight 無法投射出陰影。" @@ -12840,6 +12857,10 @@ msgstr "Varying 變數只可在頂點函式中指派。" msgid "Constants cannot be modified." msgstr "不可修改常數。" +#~ msgid "" +#~ "InterpolatedCamera has been deprecated and will be removed in Godot 4.0." +#~ msgstr "InterpolatedCamera 已停止維護,且將於 Godot 4.0 中移除。" + #~ msgid "No" #~ msgstr "否" diff --git a/main/main.cpp b/main/main.cpp index e9b06f6b07..9c8909f8fb 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -538,8 +538,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // Only flush stdout in debug builds by default, as spamming `print()` will // decrease performance if this is enabled. - GLOBAL_DEF("application/run/flush_stdout_on_print", false); - GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true); + GLOBAL_DEF_RST("application/run/flush_stdout_on_print", false); + GLOBAL_DEF_RST("application/run/flush_stdout_on_print.debug", true); GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); @@ -1174,6 +1174,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph _print_line_enabled = false; } + Logger::set_flush_stdout_on_print(ProjectSettings::get_singleton()->get("application/run/flush_stdout_on_print")); + OS::get_singleton()->set_cmdline(execpath, main_args); GLOBAL_DEF("rendering/driver/driver_name", "Vulkan"); @@ -1742,6 +1744,19 @@ Error Main::setup2(Thread::ID p_main_tid_override) { register_scene_types(); +#ifdef TOOLS_ENABLED + ClassDB::set_current_api(ClassDB::API_EDITOR); + EditorNode::register_editor_types(); + + ClassDB::set_current_api(ClassDB::API_CORE); + +#endif + + MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); + + register_platform_apis(); + register_module_types(); + GLOBAL_DEF("display/mouse_cursor/custom_image", String()); GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2()); GLOBAL_DEF("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); @@ -1758,18 +1773,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) { Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot); } } -#ifdef TOOLS_ENABLED - ClassDB::set_current_api(ClassDB::API_EDITOR); - EditorNode::register_editor_types(); - - ClassDB::set_current_api(ClassDB::API_CORE); - -#endif - - MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); - - register_platform_apis(); - register_module_types(); camera_server = CameraServer::create(); diff --git a/misc/dist/html/editor.html b/misc/dist/html/editor.html index 535721f418..3bf87f3506 100644 --- a/misc/dist/html/editor.html +++ b/misc/dist/html/editor.html @@ -2,8 +2,18 @@ <html xmlns='http://www.w3.org/1999/xhtml' lang='' xml:lang=''> <head> <meta charset='utf-8' /> - <meta name='viewport' content='width=device-width, user-scalable=no' /> + <meta name='viewport' content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no' /> + <meta name="mobile-web-app-capable" content="yes" /> + <meta name="apple-mobile-web-app-capable" content="yes" /> + <meta name="application-name" content="Godot" /> + <meta name="apple-mobile-web-app-title" content="Godot" /> + <meta name="theme-color" content="#478cbf" /> + <meta name="msapplication-navbutton-color" content="#478cbf" /> + <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> + <meta name="msapplication-starturl" content="/latest" /> <link id='-gd-engine-icon' rel='icon' type='image/png' href='favicon.png' /> + <link rel="apple-touch-icon" type="image/png" href="favicon.png" /> + <link rel="manifest" href="manifest.json" /> <title>Godot Engine Web Editor (@GODOT_VERSION@)</title> <style> *:focus { @@ -250,7 +260,13 @@ <div id='status-notice' class='godot' style='display: none;'></div> </div> </div> - + <script> + window.addEventListener("load", () => { + if ("serviceWorker" in navigator) { + navigator.serviceWorker.register("service.worker.js"); + } + }); + </script> <script src='godot.tools.js'></script> <script>//<![CDATA[ diff --git a/misc/dist/html/manifest.json b/misc/dist/html/manifest.json new file mode 100644 index 0000000000..6e0053c23c --- /dev/null +++ b/misc/dist/html/manifest.json @@ -0,0 +1,18 @@ +{ + "name": "Godot Engine", + "short_name": "Godot", + "description": "Multi-platform 2D and 3D game engine with a feature-rich editor", + "lang": "en", + "start_url": "/godot.tools.html", + "display": "standalone", + "orientation": "landscape", + "theme_color": "#478cbf", + "icons": [ + { + "src": "favicon.png", + "sizes": "256x256", + "type": "image/png" + } + ], + "background_color": "#333b4f" +} diff --git a/misc/dist/html/offline.html b/misc/dist/html/offline.html new file mode 100644 index 0000000000..000c21b4d3 --- /dev/null +++ b/misc/dist/html/offline.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>You are offline</title> + <style> + html { + background-color: #333b4f; + color: #e0e0e0; + } + + body { + font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + margin: 2rem; + } + + p { + margin-block: 1rem; + } + + button { + display: block; + padding: 1rem 2rem; + margin: 3rem auto 0; + } + </style> +</head> +<body> + <h1>You are offline</h1> + <p>This application requires an Internet connection to run for the first time.</p> + <p>Press the button below to try reloading:</p> + <button type="button">Reload</button> + + <script> + document.querySelector("button").addEventListener("click", () => { + window.location.reload(); + }); + </script> +</body> +</html> diff --git a/misc/dist/html/service-worker.js b/misc/dist/html/service-worker.js new file mode 100644 index 0000000000..d4eaed2b17 --- /dev/null +++ b/misc/dist/html/service-worker.js @@ -0,0 +1,84 @@ +// This service worker is required to expose an exported Godot project as a +// Progressive Web App. It provides an offline fallback page telling the user +// that they need an Internet conneciton to run the project if desired. +// Incrementing CACHE_VERSION will kick off the install event and force +// previously cached resources to be updated from the network. +const CACHE_VERSION = "@GODOT_VERSION@"; +const CACHE_NAME = "@GODOT_NAME@-cache"; +const OFFLINE_URL = "offline.html"; +// Files that will be cached on load. +const CACHED_FILES = [ + "godot.tools.html", + "offline.html", + "godot.tools.js", + "godot.tools.worker.js", + "godot.tools.audio.worklet.js", + "logo.svg", + "favicon.png", +]; + +// Files that we might not want the user to preload, and will only be cached on first load. +const CACHABLE_FILES = [ + "godot.tools.wasm", +]; +const FULL_CACHE = CACHED_FILES.concat(CACHABLE_FILES); + +self.addEventListener("install", (event) => { + event.waitUntil(async function () { + const cache = await caches.open(CACHE_NAME); + // Clear old cache (including optionals). + await Promise.all(FULL_CACHE.map(path => cache.delete(path))); + // Insert new one. + const done = await cache.addAll(CACHED_FILES); + return done; + }()); +}); + +self.addEventListener("activate", (event) => { + event.waitUntil(async function () { + if ("navigationPreload" in self.registration) { + await self.registration.navigationPreload.enable(); + } + }()); + // Tell the active service worker to take control of the page immediately. + self.clients.claim(); +}); + +self.addEventListener("fetch", (event) => { + const isNavigate = event.request.mode === "navigate"; + const url = event.request.url || ""; + const referrer = event.request.referrer || ""; + const base = referrer.slice(0, referrer.lastIndexOf("/") + 1); + const local = url.startsWith(base) ? url.replace(base, "") : ""; + const isCachable = FULL_CACHE.some(v => v === local) || (base === referrer && base.endsWith(CACHED_FILES[0])); + if (isNavigate || isCachable) { + event.respondWith(async function () { + try { + // Use the preloaded response, if it's there + let request = event.request.clone(); + let response = await event.preloadResponse; + if (!response) { + // Or, go over network. + response = await fetch(event.request); + } + if (isCachable) { + // Update the cache + const cache = await caches.open(CACHE_NAME); + cache.put(request, response.clone()); + } + return response; + } catch (error) { + const cache = await caches.open(CACHE_NAME); + if (event.request.mode === "navigate") { + // Check if we have full cache. + const cached = await Promise.all(FULL_CACHE.map(name => cache.match(name))); + const missing = cached.some(v => v === undefined); + const cachedResponse = missing ? await caches.match(OFFLINE_URL) : await caches.match(CACHED_FILES[0]); + return cachedResponse; + } + const cachedResponse = await caches.match(event.request); + return cachedResponse; + } + }()); + } +}); diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index bce8ec8076..d9f5beb5a1 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -148,6 +148,9 @@ void CollisionObjectBullet::add_collision_exception(const CollisionObjectBullet void CollisionObjectBullet::remove_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) { exceptions.erase(p_ignoreCollisionObject->get_self()); + if (!bt_collision_object) { + return; + } bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, false); if (space) { space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher()); @@ -155,11 +158,14 @@ void CollisionObjectBullet::remove_collision_exception(const CollisionObjectBull } bool CollisionObjectBullet::has_collision_exception(const CollisionObjectBullet *p_otherCollisionObject) const { - return !bt_collision_object->checkCollideWith(p_otherCollisionObject->bt_collision_object); + return exceptions.has(p_otherCollisionObject->get_self()); } void CollisionObjectBullet::set_collision_enabled(bool p_enabled) { collisionsEnabled = p_enabled; + if (!bt_collision_object) { + return; + } if (collisionsEnabled) { bt_collision_object->setCollisionFlags(bt_collision_object->getCollisionFlags() & (~btCollisionObject::CF_NO_CONTACT_RESPONSE)); } else { diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index 73b1738b03..c97f5f0389 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -58,8 +58,10 @@ typedef enum { GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags) GODOT_PROPERTY_HINT_LAYERS_2D_RENDER, GODOT_PROPERTY_HINT_LAYERS_2D_PHYSICS, + GODOT_PROPERTY_HINT_LAYERS_2D_NAVIGATION, GODOT_PROPERTY_HINT_LAYERS_3D_RENDER, GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS, + GODOT_PROPERTY_HINT_LAYERS_3D_NAVIGATION, GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," GODOT_PROPERTY_HINT_DIR, ///< a directory path must be passed GODOT_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc," diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index 4f61ad5040..af76d9a4cc 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -200,11 +200,11 @@ real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const { return map->get_edge_connection_margin(); } -Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const { +Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_layers) const { const NavMap *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>()); - return map->get_path(p_origin, p_destination, p_optimize); + return map->get_path(p_origin, p_destination, p_optimize, p_layers); } Vector3 GdNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const { @@ -273,6 +273,20 @@ COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) { region->set_transform(p_transform); } +COMMAND_2(region_set_layers, RID, p_region, uint32_t, p_layers) { + NavRegion *region = region_owner.getornull(p_region); + ERR_FAIL_COND(region == nullptr); + + region->set_layers(p_layers); +} + +uint32_t GdNavigationServer::region_get_layers(RID p_region) const { + NavRegion *region = region_owner.getornull(p_region); + ERR_FAIL_COND_V(region == nullptr, 0); + + return region->get_layers(); +} + COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) { NavRegion *region = region_owner.getornull(p_region); ERR_FAIL_COND(region == nullptr); diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h index 92f4ccfdd5..8bc65eccab 100644 --- a/modules/gdnavigation/gd_navigation_server.h +++ b/modules/gdnavigation/gd_navigation_server.h @@ -100,7 +100,7 @@ public: COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin); virtual real_t map_get_edge_connection_margin(RID p_map) const; - virtual Vector<Vector3> map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const; + virtual Vector<Vector3> map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_layers = 1) const; virtual Vector3 map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision = false) const; virtual Vector3 map_get_closest_point(RID p_map, const Vector3 &p_point) const; @@ -109,6 +109,8 @@ public: virtual RID region_create() const; COMMAND_2(region_set_map, RID, p_region, RID, p_map); + COMMAND_2(region_set_layers, RID, p_region, uint32_t, p_layers); + virtual uint32_t region_get_layers(RID p_region) const; COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform); COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh); virtual void region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const; diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index 2646a4cc0c..5289975e4b 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -70,7 +70,7 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const { return p; } -Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const { +Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_layers) const { const gd::Polygon *begin_poly = nullptr; const gd::Polygon *end_poly = nullptr; Vector3 begin_point; @@ -82,6 +82,11 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p for (size_t i(0); i < polygons.size(); i++) { const gd::Polygon &p = polygons[i]; + // Only consider the polygon if it in a region with compatible layers. + if ((p_layers & p.owner->get_layers()) == 0) { + continue; + } + // For each point cast a face and check the distance between the origin/destination for (size_t point_id = 2; point_id < p.points.size(); point_id++) { Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos); @@ -144,6 +149,11 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p for (size_t i = 0; i < navigation_polys[least_cost_id].poly->edges.size(); i++) { gd::NavigationPoly *least_cost_poly = &navigation_polys[least_cost_id]; + // Only consider the polygon if it in a region with compatible layers. + if ((p_layers & least_cost_poly->poly->owner->get_layers()) == 0) { + continue; + } + const gd::Edge &edge = least_cost_poly->poly->edges[i]; if (!edge.other_polygon) { continue; @@ -629,7 +639,7 @@ void NavMap::sync() { connection->get().B->edges[connection->get().B_edge].other_edge = connection->get().A_edge; } else { // The edge is already connected with another edge, skip. - ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation3D's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem."); + ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the current `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem."); } } } diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h index bffc1fbc1a..6b7cfae324 100644 --- a/modules/gdnavigation/nav_map.h +++ b/modules/gdnavigation/nav_map.h @@ -102,7 +102,7 @@ public: gd::PointKey get_point_key(const Vector3 &p_pos) const; - Vector<Vector3> get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const; + Vector<Vector3> get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_layers = 1) const; Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const; Vector3 get_closest_point(const Vector3 &p_point) const; Vector3 get_closest_point_normal(const Vector3 &p_point) const; diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp index 383b0f15a6..a07995bc11 100644 --- a/modules/gdnavigation/nav_region.cpp +++ b/modules/gdnavigation/nav_region.cpp @@ -41,6 +41,14 @@ void NavRegion::set_map(NavMap *p_map) { polygons_dirty = true; } +void NavRegion::set_layers(uint32_t p_layers) { + layers = p_layers; +} + +uint32_t NavRegion::get_layers() const { + return layers; +} + void NavRegion::set_transform(Transform p_transform) { transform = p_transform; polygons_dirty = true; diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h index 954780033b..fff7843fde 100644 --- a/modules/gdnavigation/nav_region.h +++ b/modules/gdnavigation/nav_region.h @@ -31,10 +31,10 @@ #ifndef NAV_REGION_H #define NAV_REGION_H -#include "nav_rid.h" +#include "scene/resources/navigation_mesh.h" +#include "nav_rid.h" #include "nav_utils.h" -#include "scene/3d/navigation_3d.h" #include <vector> /** @@ -48,6 +48,7 @@ class NavRegion : public NavRid { NavMap *map = nullptr; Transform transform; Ref<NavigationMesh> mesh; + uint32_t layers = 1; bool polygons_dirty = true; @@ -66,6 +67,9 @@ public: return map; } + void set_layers(uint32_t p_layers); + uint32_t get_layers() const; + void set_transform(Transform transform); const Transform &get_transform() const { return transform; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7f873ccd7a..06d628d23f 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -1176,7 +1176,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &c codegen.generator->write_and_left_operand(result_addr); // Check value equality. - codegen.generator->write_binary_operator(result_addr, Variant::OP_EQUAL, p_value_addr, expr_addr); + codegen.generator->write_binary_operator(equality_test_addr, Variant::OP_EQUAL, p_value_addr, expr_addr); codegen.generator->write_and_right_operand(equality_test_addr); // AND both type and value equality. diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index b17971cf93..a9975c8602 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2261,10 +2261,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } r_arghint = _make_arguments_hint(info, p_argidx); - return; } - if (ClassDB::is_parent_class(class_name, "Node") && (p_method == "get_node" || p_method == "has_node") && p_argidx == 0) { + if (p_argidx == 0 && ClassDB::is_parent_class(class_name, "Node") && (p_method == "get_node" || p_method == "has_node")) { // Get autoloads List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index a77fb14064..15cb3146ee 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -130,8 +130,10 @@ GDScriptParser::GDScriptParser() { register_annotation(MethodInfo("@export_flags", { Variant::STRING, "names" }), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_FLAGS, Variant::INT>, 0, true); register_annotation(MethodInfo("@export_flags_2d_render"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_2D_RENDER, Variant::INT>); register_annotation(MethodInfo("@export_flags_2d_physics"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_2D_PHYSICS, Variant::INT>); + register_annotation(MethodInfo("@export_flags_2d_navigation"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_2D_NAVIGATION, Variant::INT>); register_annotation(MethodInfo("@export_flags_3d_render"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_3D_RENDER, Variant::INT>); register_annotation(MethodInfo("@export_flags_3d_physics"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_3D_PHYSICS, Variant::INT>); + register_annotation(MethodInfo("@export_flags_3d_navigation"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_3D_NAVIGATION, Variant::INT>); // Networking. register_annotation(MethodInfo("@remote"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_REMOTE>); register_annotation(MethodInfo("@master"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_MASTER>); @@ -2080,6 +2082,17 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_unary_operator(ExpressionN return operation; } +GDScriptParser::ExpressionNode *GDScriptParser::parse_binary_not_in_operator(ExpressionNode *p_previous_operand, bool p_can_assign) { + // check that NOT is followed by IN by consuming it before calling parse_binary_operator which will only receive a plain IN + consume(GDScriptTokenizer::Token::IN, R"(Expected "in" after "not" in content-test operator.)"); + ExpressionNode *in_operation = parse_binary_operator(p_previous_operand, p_can_assign); + UnaryOpNode *operation = alloc_node<UnaryOpNode>(); + operation->operation = UnaryOpNode::OP_LOGIC_NOT; + operation->variant_op = Variant::OP_NOT; + operation->operand = in_operation; + return operation; +} + GDScriptParser::ExpressionNode *GDScriptParser::parse_binary_operator(ExpressionNode *p_previous_operand, bool p_can_assign) { GDScriptTokenizer::Token op = previous; BinaryOpNode *operation = alloc_node<BinaryOpNode>(); @@ -2906,7 +2919,7 @@ GDScriptParser::ParseRule *GDScriptParser::get_rule(GDScriptTokenizer::Token::Ty // Logical { nullptr, &GDScriptParser::parse_binary_operator, PREC_LOGIC_AND }, // AND, { nullptr, &GDScriptParser::parse_binary_operator, PREC_LOGIC_OR }, // OR, - { &GDScriptParser::parse_unary_operator, nullptr, PREC_NONE }, // NOT, + { &GDScriptParser::parse_unary_operator, &GDScriptParser::parse_binary_not_in_operator, PREC_CONTENT_TEST }, // NOT, { nullptr, &GDScriptParser::parse_binary_operator, PREC_LOGIC_AND }, // AMPERSAND_AMPERSAND, { nullptr, &GDScriptParser::parse_binary_operator, PREC_LOGIC_OR }, // PIPE_PIPE, { &GDScriptParser::parse_unary_operator, nullptr, PREC_NONE }, // BANG, @@ -3157,11 +3170,16 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node push_error(R"(Cannot use "@export" annotation with variable without type or initializer, since type can't be inferred.)", p_annotation); return false; } - if (variable->initializer->type != Node::LITERAL) { + if (variable->initializer->type == Node::LITERAL) { + variable->export_info.type = static_cast<LiteralNode *>(variable->initializer)->value.get_type(); + } else if (variable->initializer->type == Node::ARRAY) { + variable->export_info.type = Variant::ARRAY; + } else if (variable->initializer->type == Node::DICTIONARY) { + variable->export_info.type = Variant::DICTIONARY; + } else { push_error(R"(To use "@export" annotation with type-less variable, the default value must be a literal.)", p_annotation); return false; } - variable->export_info.type = static_cast<LiteralNode *>(variable->initializer)->value.get_type(); } // else: Actual type will be set by the analyzer, which can infer the proper type. } diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index d59b68b602..a4b1d4c866 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1285,6 +1285,7 @@ private: ExpressionNode *parse_builtin_constant(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_unary_operator(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_binary_operator(ExpressionNode *p_previous_operand, bool p_can_assign); + ExpressionNode *parse_binary_not_in_operator(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_ternary_operator(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_assignment(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_array(ExpressionNode *p_previous_operand, bool p_can_assign); diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 4868347a74..0a4d4055b4 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -72,6 +72,7 @@ #include "scene/3d/node_3d.h" #include "scene/3d/skeleton_3d.h" #include "scene/animation/animation_player.h" +#include "scene/main/node.h" #include "scene/resources/surface_tool.h" #include <limits> @@ -449,14 +450,8 @@ Error GLTFDocument::_serialize_nodes(Ref<GLTFState> state) { return OK; } -String GLTFDocument::_sanitize_scene_name(const String &name) { - RegEx regex("([^a-zA-Z0-9_ -]+)"); - String p_name = regex.sub(name, "", true); - return p_name; -} - String GLTFDocument::_gen_unique_name(Ref<GLTFState> state, const String &p_name) { - const String s_name = _sanitize_scene_name(p_name); + const String s_name = p_name.validate_node_name(); String name; int index = 1; @@ -464,7 +459,7 @@ String GLTFDocument::_gen_unique_name(Ref<GLTFState> state, const String &p_name name = s_name; if (index > 1) { - name += " " + itos(index); + name += itos(index); } if (!state->unique_names.has(name)) { break; @@ -477,6 +472,39 @@ String GLTFDocument::_gen_unique_name(Ref<GLTFState> state, const String &p_name return name; } +String GLTFDocument::_sanitize_animation_name(const String &p_name) { + // Animations disallow the normal node invalid characters as well as "," and "[" + // (See animation/animation_player.cpp::add_animation) + + // TODO: Consider adding invalid_characters or a validate_animation_name to animation_player to mirror Node. + String name = p_name.validate_node_name(); + name = name.replace(",", ""); + name = name.replace("[", ""); + return name; +} + +String GLTFDocument::_gen_unique_animation_name(Ref<GLTFState> state, const String &p_name) { + const String s_name = _sanitize_animation_name(p_name); + + String name; + int index = 1; + while (true) { + name = s_name; + + if (index > 1) { + name += itos(index); + } + if (!state->unique_animation_names.has(name)) { + break; + } + index++; + } + + state->unique_animation_names.insert(name); + + return name; +} + String GLTFDocument::_sanitize_bone_name(const String &name) { String p_name = name.camelcase_to_underscore(true); @@ -4729,7 +4757,7 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) { if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) { animation->set_loop(true); } - animation->set_name(_sanitize_scene_name(name)); + animation->set_name(_gen_unique_animation_name(state, name)); } for (int j = 0; j < channels.size(); j++) { diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index ddf307e6a7..bda1ce87d6 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -162,8 +162,9 @@ private: Error _parse_nodes(Ref<GLTFState> state); String _get_type_name(const GLTFType p_component); String _get_accessor_type_name(const GLTFDocument::GLTFType p_type); - String _sanitize_scene_name(const String &name); String _gen_unique_name(Ref<GLTFState> state, const String &p_name); + String _sanitize_animation_name(const String &name); + String _gen_unique_animation_name(Ref<GLTFState> state, const String &p_name); String _sanitize_bone_name(const String &name); String _gen_unique_bone_name(Ref<GLTFState> state, const GLTFSkeletonIndex skel_i, diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 86f8f44612..ff9778e7d8 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -71,6 +71,8 @@ void GLTFState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_lights", "lights"), &GLTFState::set_lights); ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFState::get_unique_names); ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFState::set_unique_names); + ClassDB::bind_method(D_METHOD("get_unique_animation_names"), &GLTFState::get_unique_animation_names); + ClassDB::bind_method(D_METHOD("set_unique_animation_names", "unique_animation_names"), &GLTFState::set_unique_animation_names); ClassDB::bind_method(D_METHOD("get_skeletons"), &GLTFState::get_skeletons); ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons); ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node); @@ -98,6 +100,7 @@ void GLTFState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "cameras", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_cameras", "get_cameras"); // Vector<Ref<GLTFCamera>> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "lights", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_lights", "get_lights"); // Vector<Ref<GLTFLight>> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_names", "get_unique_names"); // Set<String> + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>> ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // Map<GLTFSkeletonIndex, ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>> @@ -255,6 +258,14 @@ void GLTFState::set_unique_names(Array p_unique_names) { GLTFDocument::set_from_array(unique_names, p_unique_names); } +Array GLTFState::get_unique_animation_names() { + return GLTFDocument::to_array(unique_animation_names); +} + +void GLTFState::set_unique_animation_names(Array p_unique_animation_names) { + GLTFDocument::set_from_array(unique_animation_names, p_unique_animation_names); +} + Array GLTFState::get_skeletons() { return GLTFDocument::to_array(skeletons); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index 4ce5aa9491..9030962b03 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -80,6 +80,7 @@ class GLTFState : public Resource { Vector<Ref<GLTFCamera>> cameras; Vector<Ref<GLTFLight>> lights; Set<String> unique_names; + Set<String> unique_animation_names; Vector<Ref<GLTFSkeleton>> skeletons; Map<GLTFSkeletonIndex, GLTFNodeIndex> skeleton_to_node; @@ -147,6 +148,9 @@ public: Array get_unique_names(); void set_unique_names(Array p_unique_names); + Array get_unique_animation_names(); + void set_unique_animation_names(Array p_unique_names); + Array get_skeletons(); void set_skeletons(Array p_skeletons); diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index e28cc57f9b..25776b1f6d 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -184,6 +184,9 @@ </method> </methods> <members> + <member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false"> + If [code]true[/code], this GridMap bakes a navigation region. + </member> <member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x" default="true"> If [code]true[/code], grid items are centered on the X axis. </member> @@ -211,6 +214,9 @@ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The physics layers this GridMap detects collisions in. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> + <member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1"> + The navigation layers the GridMap generates its navigable regions in. + </member> <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library"> The assigned [MeshLibrary]. </member> diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index e7c252dc53..c1c230d104 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -179,6 +179,24 @@ bool GridMap::get_collision_layer_bit(int p_bit) const { return get_collision_layer() & (1 << p_bit); } +void GridMap::set_bake_navigation(bool p_bake_navigation) { + bake_navigation = p_bake_navigation; + _recreate_octant_data(); +} + +bool GridMap::is_baking_navigation() { + return bake_navigation; +} + +void GridMap::set_navigation_layers(uint32_t p_layers) { + navigation_layers = p_layers; + _recreate_octant_data(); +} + +uint32_t GridMap::get_navigation_layers() { + return navigation_layers; +} + void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) { if (!mesh_library.is_null()) { mesh_library->unregister_owner(this); @@ -474,13 +492,15 @@ bool GridMap::_octant_update(const OctantKey &p_key) { Octant::NavMesh nm; nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item); - if (navigation) { + if (bake_navigation) { RID region = NavigationServer3D::get_singleton()->region_create(); + NavigationServer3D::get_singleton()->region_set_layers(region, navigation_layers); NavigationServer3D::get_singleton()->region_set_navmesh(region, navmesh); - NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform); - NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform() * mesh_library->get_item_navmesh_transform(c.item)); + NavigationServer3D::get_singleton()->region_set_map(region, get_world_3d()->get_navigation_map()); nm.region = region; } + g.navmesh_ids[E->get()] = nm; } } @@ -564,15 +584,17 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) { RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); } - if (navigation && mesh_library.is_valid()) { + if (bake_navigation && mesh_library.is_valid()) { for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { if (cell_map.has(F->key()) && F->get().region.is_valid() == false) { Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item); if (nm.is_valid()) { RID region = NavigationServer3D::get_singleton()->region_create(); + NavigationServer3D::get_singleton()->region_set_layers(region, navigation_layers); NavigationServer3D::get_singleton()->region_set_navmesh(region, nm); - NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform); - NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform() * F->get().xform); + NavigationServer3D::get_singleton()->region_set_map(region, get_world_3d()->get_navigation_map()); + F->get().region = region; } } @@ -594,12 +616,10 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID()); } - if (navigation) { - for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { - if (F->get().region.is_valid()) { - NavigationServer3D::get_singleton()->free(F->get().region); - F->get().region = RID(); - } + for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { + if (F->get().region.is_valid()) { + NavigationServer3D::get_singleton()->free(F->get().region); + F->get().region = RID(); } } } @@ -635,16 +655,6 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) { void GridMap::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - Node3D *c = this; - while (c) { - navigation = Object::cast_to<Navigation3D>(c); - if (navigation) { - break; - } - - c = Object::cast_to<Node3D>(c->get_parent()); - } - last_transform = get_global_transform(); for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { @@ -679,8 +689,6 @@ void GridMap::_notification(int p_what) { _octant_exit_world(E->key()); } - navigation = nullptr; - //_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS); //_update_octants_callback(); //_update_area_instances(); @@ -785,6 +793,12 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &GridMap::set_collision_layer_bit); ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &GridMap::get_collision_layer_bit); + ClassDB::bind_method(D_METHOD("set_bake_navigation", "bake_navigation"), &GridMap::set_bake_navigation); + ClassDB::bind_method(D_METHOD("is_baking_navigation"), &GridMap::is_baking_navigation); + + ClassDB::bind_method(D_METHOD("set_navigation_layers", "layers"), &GridMap::set_navigation_layers); + ClassDB::bind_method(D_METHOD("get_navigation_layers"), &GridMap::get_navigation_layers); + ClassDB::bind_method(D_METHOD("set_mesh_library", "mesh_library"), &GridMap::set_mesh_library); ClassDB::bind_method(D_METHOD("get_mesh_library"), &GridMap::get_mesh_library); @@ -838,6 +852,9 @@ void GridMap::_bind_methods() { ADD_GROUP("Collision", "collision_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); + ADD_GROUP("Navigation", ""); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bake_navigation"), "set_bake_navigation", "is_baking_navigation"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers"); BIND_CONSTANT(INVALID_CELL_ITEM); diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index e5ec4bb602..4c04d492f7 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -31,7 +31,6 @@ #ifndef GRID_MAP_H #define GRID_MAP_H -#include "scene/3d/navigation_3d.h" #include "scene/3d/node_3d.h" #include "scene/resources/mesh_library.h" #include "scene/resources/multimesh.h" @@ -135,6 +134,8 @@ class GridMap : public Node3D { uint32_t collision_layer = 1; uint32_t collision_mask = 1; + bool bake_navigation = false; + uint32_t navigation_layers = 1; Transform last_transform; @@ -145,7 +146,6 @@ class GridMap : public Node3D { bool center_y = true; bool center_z = true; float cell_scale = 1.0; - Navigation3D *navigation = nullptr; bool clip = false; bool clip_above = true; @@ -223,6 +223,12 @@ public: void set_collision_mask_bit(int p_bit, bool p_value); bool get_collision_mask_bit(int p_bit) const; + void set_bake_navigation(bool p_bake_navigation); + bool is_baking_navigation(); + + void set_navigation_layers(uint32_t p_layers); + uint32_t get_navigation_layers(); + void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library); Ref<MeshLibrary> get_mesh_library() const; diff --git a/modules/mono/Directory.Build.props b/modules/mono/Directory.Build.props new file mode 100644 index 0000000000..fbf864b11b --- /dev/null +++ b/modules/mono/Directory.Build.props @@ -0,0 +1,3 @@ +<Project> + <Import Project="$(MSBuildThisFileDirectory)\SdkPackageVersions.props" /> +</Project> diff --git a/modules/mono/SdkPackageVersions.props b/modules/mono/SdkPackageVersions.props new file mode 100644 index 0000000000..396443f30e --- /dev/null +++ b/modules/mono/SdkPackageVersions.props @@ -0,0 +1,6 @@ +<Project> + <PropertyGroup> + <PackageVersion_Godot_NET_Sdk>4.0.0-dev4</PackageVersion_Godot_NET_Sdk> + <PackageVersion_Godot_SourceGenerators>4.0.0-dev1</PackageVersion_Godot_SourceGenerators> + </PropertyGroup> +</Project> diff --git a/modules/mono/build_scripts/godot_net_sdk_build.py b/modules/mono/build_scripts/godot_net_sdk_build.py index 3bfba0f0f6..8c5a60d2db 100644 --- a/modules/mono/build_scripts/godot_net_sdk_build.py +++ b/modules/mono/build_scripts/godot_net_sdk_build.py @@ -21,6 +21,18 @@ def build_godot_net_sdk(source, target, env): # No need to copy targets. The Godot.NET.Sdk csproj takes care of copying them. +def get_nupkgs_versions(props_file): + import xml.etree.ElementTree as ET + + tree = ET.parse(props_file) + root = tree.getroot() + + return { + "Godot.NET.Sdk": root.find("./PropertyGroup/PackageVersion_Godot_NET_Sdk").text.strip(), + "Godot.SourceGenerators": root.find("./PropertyGroup/PackageVersion_Godot_SourceGenerators").text.strip(), + } + + def build(env_mono): assert env_mono["tools"] @@ -30,14 +42,12 @@ def build(env_mono): module_dir = os.getcwd() - package_version_file = os.path.join( - module_dir, "editor", "Godot.NET.Sdk", "Godot.NET.Sdk", "Godot.NET.Sdk_PackageVersion.txt" - ) - - with open(package_version_file, mode="r") as f: - version = f.read().strip() + nupkgs_versions = get_nupkgs_versions(os.path.join(module_dir, "SdkPackageVersions.props")) - target_filenames = ["Godot.NET.Sdk.%s.nupkg" % version] + target_filenames = [ + "Godot.NET.Sdk.%s.nupkg" % nupkgs_versions["Godot.NET.Sdk"], + "Godot.SourceGenerators.%s.nupkg" % nupkgs_versions["Godot.SourceGenerators"], + ] targets = [os.path.join(nupkgs_dir, filename) for filename in target_filenames] diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 25cc64393a..4fca80fca0 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -31,6 +31,7 @@ #include "csharp_script.h" #include <mono/metadata/threads.h> +#include <mono/metadata/tokentype.h> #include <stdint.h> #include "core/config/project_settings.h" @@ -1182,46 +1183,56 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } #endif -void CSharpLanguage::_load_scripts_metadata() { - scripts_metadata.clear(); +void CSharpLanguage::lookup_script_for_class(GDMonoClass *p_class) { + if (!p_class->has_attribute(CACHED_CLASS(ScriptPathAttribute))) { + return; + } - String scripts_metadata_filename = "scripts_metadata."; + MonoObject *attr = p_class->get_attribute(CACHED_CLASS(ScriptPathAttribute)); + String path = CACHED_FIELD(ScriptPathAttribute, path)->get_string_value(attr); -#ifdef TOOLS_ENABLED - scripts_metadata_filename += Engine::get_singleton()->is_editor_hint() ? "editor" : "editor_player"; -#else -#ifdef DEBUG_ENABLED - scripts_metadata_filename += "debug"; -#else - scripts_metadata_filename += "release"; -#endif -#endif + dotnet_script_lookup_map[path] = DotNetScriptLookupInfo( + p_class->get_namespace(), p_class->get_name(), p_class); +} - String scripts_metadata_path = GodotSharpDirs::get_res_metadata_dir().plus_file(scripts_metadata_filename); +void CSharpLanguage::lookup_scripts_in_assembly(GDMonoAssembly *p_assembly) { + if (p_assembly->has_attribute(CACHED_CLASS(AssemblyHasScriptsAttribute))) { + MonoObject *attr = p_assembly->get_attribute(CACHED_CLASS(AssemblyHasScriptsAttribute)); + bool requires_lookup = CACHED_FIELD(AssemblyHasScriptsAttribute, requiresLookup)->get_bool_value(attr); - if (FileAccess::exists(scripts_metadata_path)) { - String old_json; + if (requires_lookup) { + // This is supported for scenarios where specifying all types would be cumbersome, + // such as when disabling C# source generators (for whatever reason) or when using a + // language other than C# that has nothing similar to source generators to automate it. + MonoImage *image = p_assembly->get_image(); - Error ferr = read_all_file_utf8(scripts_metadata_path, old_json); + int rows = mono_image_get_table_rows(image, MONO_TABLE_TYPEDEF); - ERR_FAIL_COND(ferr != OK); + for (int i = 1; i < rows; i++) { + // We don't search inner classes, only top-level. + MonoClass *mono_class = mono_class_get(image, (i + 1) | MONO_TOKEN_TYPE_DEF); - Variant old_dict_var; - String err_str; - int err_line; - Error json_err = JSON::parse(old_json, old_dict_var, err_str, err_line); - if (json_err != OK) { - ERR_PRINT("Failed to parse metadata file: '" + err_str + "' (" + String::num_int64(err_line) + ")."); - return; - } + if (!mono_class_is_assignable_from(CACHED_CLASS_RAW(GodotObject), mono_class)) { + continue; + } - scripts_metadata = old_dict_var.operator Dictionary(); - scripts_metadata_invalidated = false; + GDMonoClass *current = p_assembly->get_class(mono_class); + if (current) { + lookup_script_for_class(current); + } + } + } else { + // This is the most likely scenario as we use C# source generators + MonoArray *script_types = (MonoArray *)CACHED_FIELD(AssemblyHasScriptsAttribute, scriptTypes)->get_value(attr); - print_verbose("Successfully loaded scripts metadata"); - } else { - if (!Engine::get_singleton()->is_editor_hint()) { - ERR_PRINT("Missing scripts metadata file."); + int length = mono_array_length(script_types); + + for (int i = 0; i < length; i++) { + MonoReflectionType *reftype = mono_array_get(script_types, MonoReflectionType *, i); + ManagedType type = ManagedType::from_reftype(reftype); + ERR_CONTINUE(!type.type_class); + lookup_script_for_class(type.type_class); + } } } } @@ -1300,7 +1311,7 @@ void CSharpLanguage::_on_scripts_domain_unloaded() { } #endif - scripts_metadata_invalidated = true; + dotnet_script_lookup_map.clear(); } #ifdef TOOLS_ENABLED @@ -3356,45 +3367,34 @@ Error CSharpScript::reload(bool p_keep_state) { GD_MONO_SCOPE_THREAD_ATTACH; - GDMonoAssembly *project_assembly = GDMono::get_singleton()->get_project_assembly(); - - if (project_assembly) { - const Variant *script_metadata_var = CSharpLanguage::get_singleton()->get_scripts_metadata().getptr(get_path()); - if (script_metadata_var) { - Dictionary script_metadata = script_metadata_var->operator Dictionary()["class"]; - const Variant *namespace_ = script_metadata.getptr("namespace"); - const Variant *class_name = script_metadata.getptr("class_name"); - ERR_FAIL_NULL_V(namespace_, ERR_BUG); - ERR_FAIL_NULL_V(class_name, ERR_BUG); - GDMonoClass *klass = project_assembly->get_class(namespace_->operator String(), class_name->operator String()); - if (klass && CACHED_CLASS(GodotObject)->is_assignable_from(klass)) { - script_class = klass; - } - } else { - // Missing script metadata. Fallback to legacy method - script_class = project_assembly->get_object_derived_class(name); + const DotNetScriptLookupInfo *lookup_info = + CSharpLanguage::get_singleton()->lookup_dotnet_script(get_path()); + + if (lookup_info) { + GDMonoClass *klass = lookup_info->script_class; + if (klass) { + ERR_FAIL_COND_V(!CACHED_CLASS(GodotObject)->is_assignable_from(klass), FAILED); + script_class = klass; } + } - valid = script_class != nullptr; + valid = script_class != nullptr; - if (script_class) { + if (script_class) { #ifdef DEBUG_ENABLED - print_verbose("Found class " + script_class->get_full_name() + " for script " + get_path()); + print_verbose("Found class " + script_class->get_full_name() + " for script " + get_path()); #endif - native = GDMonoUtils::get_class_native_base(script_class); + native = GDMonoUtils::get_class_native_base(script_class); - CRASH_COND(native == nullptr); + CRASH_COND(native == nullptr); - update_script_class_info(this); + update_script_class_info(this); - _update_exports(); - } - - return OK; + _update_exports(); } - return ERR_FILE_MISSING_DEPENDENCIES; + return OK; } ScriptLanguage *CSharpScript::get_language() const { diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index a31135cd32..40f7ed4552 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -66,6 +66,18 @@ TScriptInstance *cast_script_instance(ScriptInstance *p_inst) { #define CAST_CSHARP_INSTANCE(m_inst) (cast_script_instance<CSharpInstance, CSharpLanguage>(m_inst)) +struct DotNetScriptLookupInfo { + String class_namespace; + String class_name; + GDMonoClass *script_class = nullptr; + + DotNetScriptLookupInfo() {} // Required by HashMap... + + DotNetScriptLookupInfo(const String &p_class_namespace, const String &p_class_name, GDMonoClass *p_script_class) : + class_namespace(p_class_namespace), class_name(p_class_name), script_class(p_script_class) { + } +}; + class CSharpScript : public Script { GDCLASS(CSharpScript, Script); @@ -390,16 +402,15 @@ class CSharpLanguage : public ScriptLanguage { int lang_idx = -1; - Dictionary scripts_metadata; - bool scripts_metadata_invalidated = true; + HashMap<String, DotNetScriptLookupInfo> dotnet_script_lookup_map; + + void lookup_script_for_class(GDMonoClass *p_class); // For debug_break and debug_break_parse int _debug_parse_err_line = -1; String _debug_parse_err_file; String _debug_error; - void _load_scripts_metadata(); - friend class GDMono; void _on_scripts_domain_unloaded(); @@ -436,18 +447,13 @@ public: void reload_assemblies(bool p_soft_reload); #endif - _FORCE_INLINE_ Dictionary get_scripts_metadata_or_nothing() { - return scripts_metadata_invalidated ? Dictionary() : scripts_metadata; - } + _FORCE_INLINE_ ManagedCallableMiddleman *get_managed_callable_middleman() const { return managed_callable_middleman; } - _FORCE_INLINE_ const Dictionary &get_scripts_metadata() { - if (scripts_metadata_invalidated) { - _load_scripts_metadata(); - } - return scripts_metadata; - } + void lookup_scripts_in_assembly(GDMonoAssembly *p_assembly); - _FORCE_INLINE_ ManagedCallableMiddleman *get_managed_callable_middleman() const { return managed_callable_middleman; } + const DotNetScriptLookupInfo *lookup_dotnet_script(const String &p_script_path) const { + return dotnet_script_lookup_map.getptr(p_script_path); + } String get_name() const override; diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln index 56c0cb7703..d1868f52ef 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln @@ -2,6 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.NET.Sdk", "Godot.NET.Sdk\Godot.NET.Sdk.csproj", "{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators", "Godot.SourceGenerators\Godot.SourceGenerators.csproj", "{32D31B23-2A45-4099-B4F5-95B4C8FF7D9F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators.Sample", "Godot.SourceGenerators.Sample\Godot.SourceGenerators.Sample.csproj", "{7297A614-8DF5-43DE-9EAD-99671B26BD1F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharp", "..\..\glue\GodotSharp\GodotSharp\GodotSharp.csproj", "{AEBF0036-DA76-4341-B651-A3F2856AB2FA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +18,17 @@ Global {31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU {31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU {31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Release|Any CPU.Build.0 = Release|Any CPU + {32D31B23-2A45-4099-B4F5-95B4C8FF7D9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32D31B23-2A45-4099-B4F5-95B4C8FF7D9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32D31B23-2A45-4099-B4F5-95B4C8FF7D9F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32D31B23-2A45-4099-B4F5-95B4C8FF7D9F}.Release|Any CPU.Build.0 = Release|Any CPU + {7297A614-8DF5-43DE-9EAD-99671B26BD1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7297A614-8DF5-43DE-9EAD-99671B26BD1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7297A614-8DF5-43DE-9EAD-99671B26BD1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7297A614-8DF5-43DE-9EAD-99671B26BD1F}.Release|Any CPU.Build.0 = Release|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj index 8304d9e321..ef8add0ba8 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj @@ -8,43 +8,33 @@ <PackageId>Godot.NET.Sdk</PackageId> <Version>4.0.0</Version> - <PackageProjectUrl>https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk</PackageProjectUrl> + <PackageVersion>$(PackageVersion_Godot_NET_Sdk)</PackageVersion> + <RepositoryUrl>https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk</RepositoryUrl> + <PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl> <PackageType>MSBuildSdk</PackageType> <PackageTags>MSBuildSdk</PackageTags> + <PackageLicenseExpression>MIT</PackageLicenseExpression> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> - </PropertyGroup> - <PropertyGroup> - <NuspecFile>Godot.NET.Sdk.nuspec</NuspecFile> - <GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);SetNuSpecProperties</GenerateNuspecDependsOn> + <!-- Exclude target framework from the package dependencies as we don't include the build output --> + <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> + <IncludeBuildOutput>false</IncludeBuildOutput> </PropertyGroup> - <Target Name="ReadGodotNETSdkVersion" BeforeTargets="BeforeBuild;BeforeRebuild;CoreCompile"> - <PropertyGroup> - <PackageVersion>$([System.IO.File]::ReadAllText('$(ProjectDir)Godot.NET.Sdk_PackageVersion.txt').Trim())</PackageVersion> - </PropertyGroup> - </Target> + <ItemGroup> + <!-- Package Sdk\Sdk.props and Sdk\Sdk.targets file --> + <None Include="Sdk\Sdk.props" Pack="true" PackagePath="Sdk" Visible="false" /> + <None Include="Sdk\Sdk.targets" Pack="true" PackagePath="Sdk" Visible="false" /> + <!-- SdkPackageVersions.props --> - <Target Name="SetNuSpecProperties" Condition=" Exists('$(NuspecFile)') " DependsOnTargets="ReadGodotNETSdkVersion"> - <PropertyGroup> - <NuspecProperties> - id=$(PackageId); - description=$(Description); - authors=$(Authors); - version=$(PackageVersion); - packagetype=$(PackageType); - tags=$(PackageTags); - projecturl=$(PackageProjectUrl) - </NuspecProperties> - </PropertyGroup> - </Target> + <None Include="..\..\..\SdkPackageVersions.props" Pack="true" PackagePath="Sdk" Visible="false" /> + </ItemGroup> <Target Name="CopyNupkgToSConsOutputDir" AfterTargets="Pack"> <PropertyGroup> <GodotSourceRootPath>$(SolutionDir)\..\..\..\..\</GodotSourceRootPath> <GodotOutputDataDir>$(GodotSourceRootPath)\bin\GodotSharp\</GodotOutputDataDir> </PropertyGroup> - <Copy SourceFiles="$(OutputPath)$(PackageId).$(PackageVersion).nupkg" - DestinationFolder="$(GodotOutputDataDir)Tools\nupkgs\" /> + <Copy SourceFiles="$(PackageOutputPath)$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$(GodotOutputDataDir)Tools\nupkgs\" /> </Target> </Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.nuspec b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.nuspec deleted file mode 100644 index ba68a4da43..0000000000 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.nuspec +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"> - <metadata> - <id>$id$</id> - <version>$version$</version> - <description>$description$</description> - <authors>$authors$</authors> - <owners>$authors$</owners> - <projectUrl>$projecturl$</projectUrl> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <license type="expression">MIT</license> - <licenseUrl>https://licenses.nuget.org/MIT</licenseUrl> - <tags>$tags$</tags> - <packageTypes> - <packageType name="$packagetype$" /> - </packageTypes> - <repository url="$projecturl$" /> - </metadata> - <files> - <file src="Sdk\**" target="Sdk" /> - </files> -</package> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk_PackageVersion.txt b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk_PackageVersion.txt deleted file mode 100644 index 34749489b9..0000000000 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk_PackageVersion.txt +++ /dev/null @@ -1 +0,0 @@ -4.0.0-dev3 diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props index 5febcf3175..0128f5c706 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props @@ -1,4 +1,6 @@ <Project> + <Import Project="$(MSBuildThisFileDirectory)\SdkPackageVersions.props" /> + <PropertyGroup> <!-- Determines if we should import Microsoft.NET.Sdk, if it wasn't already imported. --> <GodotSdkImportsMicrosoftNetSdk Condition=" '$(UsingMicrosoftNETSdk)' != 'true' ">true</GodotSdkImportsMicrosoftNetSdk> @@ -94,6 +96,7 @@ <DefineConstants>$(GodotDefineConstants);$(DefineConstants)</DefineConstants> </PropertyGroup> + <!-- Godot API references --> <ItemGroup> <!-- TODO: diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets index f5afd75505..92e299d2f3 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets @@ -14,4 +14,9 @@ --> <DefineConstants Condition=" '$(GodotRealTIsDouble)' == 'true' ">GODOT_REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants> </PropertyGroup> + + <!-- C# source generators --> + <ItemGroup Condition=" '$(DisableImplicitGodotGeneratorReferences)' != 'true' "> + <PackageReference Include="Godot.SourceGenerators" Version="$(PackageVersion_Godot_SourceGenerators)" /> + </ItemGroup> </Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs new file mode 100644 index 0000000000..5eaebc4474 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Bar.cs @@ -0,0 +1,15 @@ +namespace Godot.SourceGenerators.Sample +{ + partial class Bar : Godot.Object + { + } + + // Foo in another file + partial class Foo + { + } + + partial class NotSameNameAsFile : Godot.Object + { + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs new file mode 100644 index 0000000000..21a5bfe560 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Foo.cs @@ -0,0 +1,11 @@ +namespace Godot.SourceGenerators.Sample +{ + partial class Foo : Godot.Object + { + } + + // Foo again in the same file + partial class Foo + { + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj new file mode 100644 index 0000000000..24f7909861 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj @@ -0,0 +1,31 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>netstandard2.1</TargetFramework> + </PropertyGroup> + + <PropertyGroup> + <!-- $(GodotProjectDir) would normally be defined by the Godot.NET.Sdk --> + <GodotProjectDir>$(MSBuildProjectDirectory)</GodotProjectDir> + </PropertyGroup> + + <PropertyGroup> + <!-- The emitted files are not part of the compilation nor design. + They're only for peeking at the generated sources. Sometimes the + emitted files get corrupted, but that won't break anything. --> + <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> + <CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\..\..\glue\GodotSharp\GodotSharp\GodotSharp.csproj"> + <Private>False</Private> + </ProjectReference> + <ProjectReference Include="..\Godot.SourceGenerators\Godot.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> + </ItemGroup> + + <!-- This file is imported automatically when using PackageReference to + reference Godot.SourceGenerators, but not when using ProjectReference --> + <Import Project="..\Godot.SourceGenerators\Godot.SourceGenerators.props" /> + +</Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs new file mode 100644 index 0000000000..4867c986e6 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs @@ -0,0 +1,33 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Godot.SourceGenerators +{ + public static class Common + { + public static void ReportNonPartialGodotScriptClass( + GeneratorExecutionContext context, + ClassDeclarationSyntax cds, INamedTypeSymbol symbol + ) + { + string message = + "Missing partial modifier on declaration of type '" + + $"{symbol.FullQualifiedName()}' which is a subclass of '{GodotClasses.Object}'"; + + string description = $"{message}. Subclasses of '{GodotClasses.Object}' must be " + + "declared with the partial modifier or annotated with the " + + $"attribute '{GodotClasses.DisableGodotGeneratorsAttr}'."; + + context.ReportDiagnostic(Diagnostic.Create( + new DiagnosticDescriptor(id: "GODOT-G0001", + title: message, + messageFormat: message, + category: "Usage", + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description), + cds.GetLocation(), + cds.SyntaxTree.FilePath)); + } + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs new file mode 100644 index 0000000000..c3e74822d5 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Godot.SourceGenerators +{ + static class ExtensionMethods + { + public static bool TryGetGlobalAnalyzerProperty( + this GeneratorExecutionContext context, string property, out string? value + ) => context.AnalyzerConfigOptions.GlobalOptions + .TryGetValue("build_property." + property, out value); + + private static bool InheritsFrom(this INamedTypeSymbol? symbol, string baseName) + { + if (symbol == null) + return false; + + while (true) + { + if (symbol.ToString() == baseName) + { + return true; + } + + if (symbol.BaseType != null) + { + symbol = symbol.BaseType; + continue; + } + + break; + } + + return false; + } + + private static bool IsGodotScriptClass( + this ClassDeclarationSyntax cds, Compilation compilation, + out INamedTypeSymbol? symbol + ) + { + var sm = compilation.GetSemanticModel(cds.SyntaxTree); + + var classTypeSymbol = sm.GetDeclaredSymbol(cds); + + if (classTypeSymbol?.BaseType == null + || !classTypeSymbol.BaseType.InheritsFrom(GodotClasses.Object)) + { + symbol = null; + return false; + } + + symbol = classTypeSymbol; + return true; + } + + public static IEnumerable<(ClassDeclarationSyntax cds, INamedTypeSymbol symbol)> SelectGodotScriptClasses( + this IEnumerable<ClassDeclarationSyntax> source, + Compilation compilation + ) + { + foreach (var cds in source) + { + if (cds.IsGodotScriptClass(compilation, out var symbol)) + yield return (cds, symbol!); + } + } + + public static bool IsPartial(this ClassDeclarationSyntax cds) + => cds.Modifiers.Any(SyntaxKind.PartialKeyword); + + public static bool HasDisableGeneratorsAttribute(this INamedTypeSymbol symbol) + => symbol.GetAttributes().Any(attr => + attr.AttributeClass?.ToString() == GodotClasses.DisableGodotGeneratorsAttr); + + private static SymbolDisplayFormat FullyQualifiedFormatOmitGlobal { get; } = + SymbolDisplayFormat.FullyQualifiedFormat + .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted); + + public static string FullQualifiedName(this INamedTypeSymbol symbol) + => symbol.ToDisplayString(NullableFlowState.NotNull, FullyQualifiedFormatOmitGlobal); + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj new file mode 100644 index 0000000000..224d7e5b5a --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj @@ -0,0 +1,40 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>netstandard2.0</TargetFramework> + <LangVersion>8.0</LangVersion> + <Nullable>enable</Nullable> + </PropertyGroup> + <PropertyGroup> + <Description>Core C# source generator for Godot projects.</Description> + <Authors>Godot Engine contributors</Authors> + + <PackageId>Godot.SourceGenerators</PackageId> + <Version>4.0.0</Version> + <PackageVersion>$(PackageVersion_Godot_SourceGenerators)</PackageVersion> + <RepositoryUrl>https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators</RepositoryUrl> + <PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl> + <PackageLicenseExpression>MIT</PackageLicenseExpression> + + <GeneratePackageOnBuild>true</GeneratePackageOnBuild> <!-- Generates a package at build --> + <IncludeBuildOutput>false</IncludeBuildOutput> <!-- Do not include the generator as a lib dependency --> + </PropertyGroup> + <ItemGroup> + <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" PrivateAssets="all" /> + <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.1" PrivateAssets="all" /> + </ItemGroup> + <ItemGroup> + <!-- Package the generator in the analyzer directory of the nuget package --> + <None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" /> + + <!-- Package the props file --> + <None Include="Godot.SourceGenerators.props" Pack="true" PackagePath="build" Visible="false" /> + </ItemGroup> + + <Target Name="CopyNupkgToSConsOutputDir" AfterTargets="Pack"> + <PropertyGroup> + <GodotSourceRootPath>$(SolutionDir)\..\..\..\..\</GodotSourceRootPath> + <GodotOutputDataDir>$(GodotSourceRootPath)\bin\GodotSharp\</GodotOutputDataDir> + </PropertyGroup> + <Copy SourceFiles="$(PackageOutputPath)$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$(GodotOutputDataDir)Tools\nupkgs\" /> + </Target> +</Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props new file mode 100644 index 0000000000..f9b47ad5b1 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.props @@ -0,0 +1,7 @@ +<Project> + <ItemGroup> + <!-- $(GodotProjectDir) is defined by Godot.NET.Sdk --> + <CompilerVisibleProperty Include="GodotProjectDir" /> + <CompilerVisibleProperty Include="GodotScriptPathAttributeGenerator" /> + </ItemGroup> +</Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs new file mode 100644 index 0000000000..29e41d155a --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs @@ -0,0 +1,9 @@ +namespace Godot.SourceGenerators +{ + public static class GodotClasses + { + public const string Object = "Godot.Object"; + public const string DisableGodotGeneratorsAttr = "Godot.DisableGodotGeneratorsAttribute"; + public const string AssemblyHasScriptsAttr = "Godot.AssemblyHasScriptsAttribute"; + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs new file mode 100644 index 0000000000..150e59e414 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Text; + +namespace Godot.SourceGenerators +{ + [Generator] + public class ScriptPathAttributeGenerator : ISourceGenerator + { + public void Execute(GeneratorExecutionContext context) + { + if (context.TryGetGlobalAnalyzerProperty("GodotScriptPathAttributeGenerator", out string? toggle) + && toggle == "disabled") + { + return; + } + + // NOTE: IsNullOrEmpty doesn't work well with nullable checks + // ReSharper disable once ReplaceWithStringIsNullOrEmpty + if (!context.TryGetGlobalAnalyzerProperty("GodotProjectDir", out string? godotProjectDir) + || godotProjectDir!.Length == 0) + { + throw new InvalidOperationException("Property 'GodotProjectDir' is null or empty."); + } + + var godotClasses = context.Compilation.SyntaxTrees + .SelectMany(tree => + tree.GetRoot().DescendantNodes() + .OfType<ClassDeclarationSyntax>() + // Ignore inner classes + .Where(cds => !(cds.Parent is ClassDeclarationSyntax)) + .SelectGodotScriptClasses(context.Compilation) + // Report and skip non-partial classes + .Where(x => + { + if (x.cds.IsPartial() || x.symbol.HasDisableGeneratorsAttribute()) + return true; + Common.ReportNonPartialGodotScriptClass(context, x.cds, x.symbol); + return false; + }) + ) + // Ignore classes whose name is not the same as the file name + .Where(x => Path.GetFileNameWithoutExtension(x.cds.SyntaxTree.FilePath) == x.symbol.Name) + .GroupBy(x => x.symbol) + .ToDictionary(g => g.Key, g => g.Select(x => x.cds)); + + foreach (var godotClass in godotClasses) + { + VisitGodotScriptClass(context, godotProjectDir, + symbol: godotClass.Key, + classDeclarations: godotClass.Value); + } + + if (godotClasses.Count <= 0) + return; + + AddScriptTypesAssemblyAttr(context, godotClasses); + } + + private static void VisitGodotScriptClass( + GeneratorExecutionContext context, + string godotProjectDir, + INamedTypeSymbol symbol, + IEnumerable<ClassDeclarationSyntax> classDeclarations + ) + { + var attributesBuilder = new StringBuilder(); + + // Remember syntax trees for which we already added an attribute, to prevent unnecessary duplicates. + var attributedTrees = new List<SyntaxTree>(); + + foreach (var cds in classDeclarations) + { + if (attributedTrees.Contains(cds.SyntaxTree)) + continue; + + attributedTrees.Add(cds.SyntaxTree); + + if (attributesBuilder.Length != 0) + attributesBuilder.Append("\n "); + + attributesBuilder.Append(@"[ScriptPathAttribute(""res://"); + attributesBuilder.Append(RelativeToDir(cds.SyntaxTree.FilePath, godotProjectDir)); + attributesBuilder.Append(@""")]"); + } + + string classNs = symbol.ContainingNamespace.Name; + string className = symbol.Name; + + var source = $@"using Godot; +namespace {classNs} +{{ + {attributesBuilder} + partial class {className} + {{ + }} +}} +"; + context.AddSource(classNs + "." + className + "_ScriptPath_Generated", + SourceText.From(source, Encoding.UTF8)); + } + + private static void AddScriptTypesAssemblyAttr(GeneratorExecutionContext context, + Dictionary<INamedTypeSymbol, IEnumerable<ClassDeclarationSyntax>> godotClasses) + { + var sourceBuilder = new StringBuilder(); + + sourceBuilder.Append("[assembly:"); + sourceBuilder.Append(GodotClasses.AssemblyHasScriptsAttr); + sourceBuilder.Append("(new System.Type[] {"); + + bool first = true; + + foreach (var godotClass in godotClasses) + { + var qualifiedName = godotClass.Key.ToDisplayString( + NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat); + if (!first) + sourceBuilder.Append(", "); + first = false; + sourceBuilder.Append("typeof("); + sourceBuilder.Append(qualifiedName); + sourceBuilder.Append(")"); + } + + sourceBuilder.Append("})]\n"); + + context.AddSource("AssemblyScriptTypes_Generated", + SourceText.From(sourceBuilder.ToString(), Encoding.UTF8)); + } + + public void Initialize(GeneratorInitializationContext context) + { + } + + private static string RelativeToDir(string path, string dir) + { + // Make sure the directory ends with a path separator + dir = Path.Combine(dir, " ").TrimEnd(); + + if (Path.DirectorySeparatorChar == '\\') + dir = dir.Replace("/", "\\") + "\\"; + + var fullPath = new Uri(Path.GetFullPath(path), UriKind.Absolute); + var relRoot = new Uri(Path.GetFullPath(dir), UriKind.Absolute); + + // MakeRelativeUri converts spaces to %20, hence why we need UnescapeDataString + return Uri.UnescapeDataString(relRoot.MakeRelativeUri(fullPath).ToString()); + } + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs index 4e2c0f17cc..cdac9acb25 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs @@ -1,11 +1,5 @@ using System; -using GodotTools.Core; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; using Microsoft.Build.Construction; -using Microsoft.Build.Globbing; namespace GodotTools.ProjectEditor { @@ -31,47 +25,6 @@ namespace GodotTools.ProjectEditor return root != null ? new MSBuildProject(root) : null; } - private static List<string> GetAllFilesRecursive(string rootDirectory, string mask) - { - string[] files = Directory.GetFiles(rootDirectory, mask, SearchOption.AllDirectories); - - // We want relative paths - for (int i = 0; i < files.Length; i++) - { - files[i] = files[i].RelativeToPath(rootDirectory); - } - - return new List<string>(files); - } - - // NOTE: Assumes auto-including items. Only used by the scripts metadata generator, which will be replaced with source generators in the future. - public static IEnumerable<string> GetIncludeFiles(string projectPath, string itemType) - { - var excluded = new List<string>(); - var includedFiles = GetAllFilesRecursive(Path.GetDirectoryName(projectPath), "*.cs"); - - var root = ProjectRootElement.Open(projectPath); - Debug.Assert(root != null); - - foreach (var item in root.Items) - { - if (string.IsNullOrEmpty(item.Condition)) - continue; - - if (item.ItemType != itemType) - continue; - - string normalizedRemove = item.Remove.NormalizePath(); - - var glob = MSBuildGlob.Parse(normalizedRemove); - excluded.AddRange(includedFiles.Where(includedFile => glob.IsMatch(includedFile))); - } - - includedFiles.RemoveAll(f => excluded.Contains(f)); - - return includedFiles; - } - public static void MigrateToProjectSdksStyle(MSBuildProject project, string projectName) { var origRoot = project.Root; diff --git a/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets b/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets index 1d382dcb43..aab2d73bdd 100644 --- a/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets +++ b/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets @@ -3,7 +3,6 @@ <Target Name="SetPropertiesForGenerateGodotNupkgsVersions"> <PropertyGroup> - <GodotNETSdkPackageVersionFile>$(SolutionDir)..\Godot.NET.Sdk\Godot.NET.Sdk\Godot.NET.Sdk_PackageVersion.txt</GodotNETSdkPackageVersionFile> <GeneratedGodotNupkgsVersionsFile>$(IntermediateOutputPath)GodotNupkgsVersions.g.cs</GeneratedGodotNupkgsVersionsFile> </PropertyGroup> </Target> @@ -18,13 +17,14 @@ </Target> <Target Name="_GenerateGodotNupkgsVersionsFile" DependsOnTargets="SetPropertiesForGenerateGodotNupkgsVersions" - Inputs="$(MSBuildProjectFile);@(GodotNETSdkPackageVersionFile)" + Inputs="$(MSBuildProjectFile);$(MSBuildThisFileDirectory);$(MSBuildProjectFile)\..\..\..\SdkPackageVersions.props" Outputs="$(GeneratedGodotNupkgsVersionsFile)"> <PropertyGroup> <GenerateGodotNupkgsVersionsCode><![CDATA[ namespace $(RootNamespace) { public class GeneratedGodotNupkgsVersions { - public const string GodotNETSdk = "$([System.IO.File]::ReadAllText('$(GodotNETSdkPackageVersionFile)').Trim())"%3b + public const string GodotNETSdk = "$(PackageVersion_Godot_NET_Sdk)"%3b + public const string GodotSourceGenerators = "$(PackageVersion_Godot_SourceGenerators)"%3b } } ]]></GenerateGodotNupkgsVersionsCode> diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs index b96b0c8175..2b6f972529 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs @@ -218,43 +218,12 @@ namespace GodotTools.Build Godot.GD.PushError("Failed to setup Godot NuGet Offline Packages: " + e.Message); } - GenerateEditorScriptMetadata(); - if (GodotSharpEditor.Instance.SkipBuildBeforePlaying) return true; // Requested play from an external editor/IDE which already built the project return BuildProjectBlocking("Debug"); } - // NOTE: This will be replaced with C# source generators in 4.0 - public static void GenerateEditorScriptMetadata() - { - string editorScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor"); - string playerScriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, "scripts_metadata.editor_player"); - - CsProjOperations.GenerateScriptsMetadata(GodotSharpDirs.ProjectCsProjPath, editorScriptsMetadataPath); - - if (!File.Exists(editorScriptsMetadataPath)) - return; - - try - { - File.Copy(editorScriptsMetadataPath, playerScriptsMetadataPath); - } - catch (IOException e) - { - throw new IOException("Failed to copy scripts metadata file.", innerException: e); - } - } - - // NOTE: This will be replaced with C# source generators in 4.0 - public static string GenerateExportedGameScriptMetadata(bool isDebug) - { - string scriptsMetadataPath = Path.Combine(GodotSharpDirs.ResMetadataDir, $"scripts_metadata.{(isDebug ? "debug" : "release")}"); - CsProjOperations.GenerateScriptsMetadata(GodotSharpDirs.ProjectCsProjPath, scriptsMetadataPath); - return scriptsMetadataPath; - } - public static void Initialize() { // Build tool settings diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs index 708ec73454..ed69c2b833 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs @@ -43,8 +43,6 @@ namespace GodotTools.Build GD.PushError("Failed to setup Godot NuGet Offline Packages: " + e.Message); } - BuildManager.GenerateEditorScriptMetadata(); - if (!BuildManager.BuildProjectBlocking("Debug")) return; // Build failed @@ -74,8 +72,6 @@ namespace GodotTools.Build GD.PushError("Failed to setup Godot NuGet Offline Packages: " + e.Message); } - BuildManager.GenerateEditorScriptMetadata(); - if (!BuildManager.BuildProjectBlocking("Debug", targets: new[] {"Rebuild"})) return; // Build failed diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs b/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs index 793ef7fd71..16dd1c8c6b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/NuGetUtils.cs @@ -290,7 +290,8 @@ namespace GodotTools.Build private static readonly (string packageId, string packageVersion)[] PackagesToAdd = { - ("Godot.NET.Sdk", GeneratedGodotNupkgsVersions.GodotNETSdk) + ("Godot.NET.Sdk", GeneratedGodotNupkgsVersions.GodotNETSdk), + ("Godot.SourceGenerators", GeneratedGodotNupkgsVersions.GodotSourceGenerators), }; } } diff --git a/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs b/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs index 1d800b8151..e43f10804d 100644 --- a/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs +++ b/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs @@ -1,11 +1,6 @@ using Godot; using System; -using System.Linq; -using Godot.Collections; -using GodotTools.Internals; using GodotTools.ProjectEditor; -using File = GodotTools.Utils.File; -using Directory = GodotTools.Utils.Directory; namespace GodotTools { @@ -23,86 +18,5 @@ namespace GodotTools return string.Empty; } } - - private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - private static ulong ConvertToTimestamp(this DateTime value) - { - TimeSpan elapsedTime = value - Epoch; - return (ulong)elapsedTime.TotalSeconds; - } - - private static bool TryParseFileMetadata(string includeFile, ulong modifiedTime, out Dictionary fileMetadata) - { - fileMetadata = null; - - var parseError = ScriptClassParser.ParseFile(includeFile, out var classes, out string errorStr); - - if (parseError != Error.Ok) - { - GD.PushError($"Failed to determine namespace and class for script: {includeFile}. Parse error: {errorStr ?? parseError.ToString()}"); - return false; - } - - string searchName = System.IO.Path.GetFileNameWithoutExtension(includeFile); - - var firstMatch = classes.FirstOrDefault(classDecl => - classDecl.BaseCount != 0 && // If it doesn't inherit anything, it can't be a Godot.Object. - classDecl.SearchName == searchName // Filter by the name we're looking for - ); - - if (firstMatch == null) - return false; // Not found - - fileMetadata = new Dictionary - { - ["modified_time"] = $"{modifiedTime}", - ["class"] = new Dictionary - { - ["namespace"] = firstMatch.Namespace, - ["class_name"] = firstMatch.Name, - ["nested"] = firstMatch.Nested - } - }; - - return true; - } - - public static void GenerateScriptsMetadata(string projectPath, string outputPath) - { - var metadataDict = Internal.GetScriptsMetadataOrNothing().Duplicate(); - - bool IsUpToDate(string includeFile, ulong modifiedTime) - { - return metadataDict.TryGetValue(includeFile, out var oldFileVar) && - ulong.TryParse(((Dictionary)oldFileVar)["modified_time"] as string, - out ulong storedModifiedTime) && storedModifiedTime == modifiedTime; - } - - var outdatedFiles = ProjectUtils.GetIncludeFiles(projectPath, "Compile") - .Select(path => ("res://" + path).SimplifyGodotPath()) - .ToDictionary(path => path, path => File.GetLastWriteTime(path).ConvertToTimestamp()) - .Where(pair => !IsUpToDate(includeFile: pair.Key, modifiedTime: pair.Value)) - .ToArray(); - - foreach (var pair in outdatedFiles) - { - metadataDict.Remove(pair.Key); - - string includeFile = pair.Key; - - if (TryParseFileMetadata(includeFile, modifiedTime: pair.Value, out var fileMetadata)) - metadataDict[includeFile] = fileMetadata; - } - - string json = metadataDict.Count <= 0 ? "{}" : JSON.Print(metadataDict); - - string baseDir = outputPath.GetBaseDir(); - - if (!Directory.Exists(baseDir)) - Directory.CreateDirectory(baseDir); - - File.WriteAllText(outputPath, json); - } } } diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index e9bb701562..270be8b6bf 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -157,9 +157,6 @@ namespace GodotTools.Export string buildConfig = isDebug ? "ExportDebug" : "ExportRelease"; - string scriptsMetadataPath = BuildManager.GenerateExportedGameScriptMetadata(isDebug); - AddFile(scriptsMetadataPath, scriptsMetadataPath); - if (!BuildManager.BuildProjectBlocking(buildConfig, platform: platform)) throw new Exception("Failed to build project"); diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs index 7e5049e4b7..77370090ec 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs @@ -1,7 +1,5 @@ -using System; using System.Runtime.CompilerServices; using Godot; -using Godot.Collections; using GodotTools.IdeMessaging.Requests; namespace GodotTools.Internals @@ -42,9 +40,6 @@ namespace GodotTools.Internals public static void EditorNodeShowScriptScreen() => internal_EditorNodeShowScriptScreen(); - public static Dictionary<string, object> GetScriptsMetadataOrNothing() => - internal_GetScriptsMetadataOrNothing(typeof(Dictionary<string, object>)); - public static string MonoWindowsInstallRoot => internal_MonoWindowsInstallRoot(); public static void EditorRunPlay() => internal_EditorRunPlay(); @@ -101,9 +96,6 @@ namespace GodotTools.Internals private static extern void internal_EditorNodeShowScriptScreen(); [MethodImpl(MethodImplOptions.InternalCall)] - private static extern Dictionary<string, object> internal_GetScriptsMetadataOrNothing(Type dictType); - - [MethodImpl(MethodImplOptions.InternalCall)] private static extern string internal_MonoWindowsInstallRoot(); [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs deleted file mode 100644 index c72a84c513..0000000000 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Godot; -using Godot.Collections; - -namespace GodotTools.Internals -{ - public static class ScriptClassParser - { - public class ClassDecl - { - public string Name { get; } - public string Namespace { get; } - public bool Nested { get; } - public long BaseCount { get; } - - public string SearchName => Nested ? - Name.Substring(Name.LastIndexOf(".", StringComparison.Ordinal) + 1) : - Name; - - public ClassDecl(string name, string @namespace, bool nested, long baseCount) - { - Name = name; - Namespace = @namespace; - Nested = nested; - BaseCount = baseCount; - } - } - - [MethodImpl(MethodImplOptions.InternalCall)] - private static extern Error internal_ParseFile(string filePath, Array<Dictionary> classes, out string errorStr); - - public static Error ParseFile(string filePath, out IEnumerable<ClassDecl> classes, out string errorStr) - { - var classesArray = new Array<Dictionary>(); - var error = internal_ParseFile(filePath, classesArray, out errorStr); - if (error != Error.Ok) - { - classes = null; - return error; - } - - var classesList = new List<ClassDecl>(); - - foreach (var classDeclDict in classesArray) - { - classesList.Add(new ClassDecl( - (string)classDeclDict["name"], - (string)classDeclDict["namespace"], - (bool)classDeclDict["nested"], - (long)classDeclDict["base_count"] - )); - } - - classes = classesList; - - return Error.Ok; - } - } -} diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 667e4a3879..21efd58938 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -49,7 +49,6 @@ #include "../utils/osx_utils.h" #include "code_completion.h" #include "godotsharp_export.h" -#include "script_class_parser.h" MonoString *godot_icall_GodotSharpDirs_ResDataDir() { return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_res_data_dir()); @@ -172,36 +171,6 @@ MonoBoolean godot_icall_EditorProgress_Step(MonoString *p_task, MonoString *p_st return EditorNode::progress_task_step(task, state, p_step, (bool)p_force_refresh); } -int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes, MonoString **r_error_str) { - *r_error_str = nullptr; - - String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath); - - ScriptClassParser scp; - Error err = scp.parse_file(filepath); - if (err == OK) { - Array classes = GDMonoMarshal::mono_object_to_variant(p_classes); - const Vector<ScriptClassParser::ClassDecl> &class_decls = scp.get_classes(); - - for (int i = 0; i < class_decls.size(); i++) { - const ScriptClassParser::ClassDecl &classDecl = class_decls[i]; - - Dictionary classDeclDict; - classDeclDict["name"] = classDecl.name; - classDeclDict["namespace"] = classDecl.namespace_; - classDeclDict["nested"] = classDecl.nested; - classDeclDict["base_count"] = classDecl.base.size(); - classes.push_back(classDeclDict); - } - } else { - String error_str = scp.get_error(); - if (!error_str.is_empty()) { - *r_error_str = GDMonoMarshal::mono_string_from_godot(error_str); - } - } - return err; -} - uint32_t godot_icall_ExportPlugin_GetExportedAssemblyDependencies(MonoObject *p_initial_assemblies, MonoString *p_build_config, MonoString *p_custom_bcl_dir, MonoObject *r_assembly_dependencies) { Dictionary initial_dependencies = GDMonoMarshal::mono_object_to_variant(p_initial_assemblies); @@ -289,18 +258,6 @@ void godot_icall_Internal_EditorNodeShowScriptScreen() { EditorNode::get_singleton()->call("_editor_select", EditorNode::EDITOR_SCRIPT); } -MonoObject *godot_icall_Internal_GetScriptsMetadataOrNothing(MonoReflectionType *p_dict_reftype) { - Dictionary maybe_metadata = CSharpLanguage::get_singleton()->get_scripts_metadata_or_nothing(); - - MonoType *dict_type = mono_reflection_type_get_type(p_dict_reftype); - - int type_encoding = mono_type_get_type(dict_type); - MonoClass *type_class_raw = mono_class_from_mono_type(dict_type); - GDMonoClass *type_class = GDMono::get_singleton()->get_class(type_class_raw); - - return GDMonoMarshal::variant_to_mono_object(maybe_metadata, ManagedType(type_encoding, type_class)); -} - MonoString *godot_icall_Internal_MonoWindowsInstallRoot() { #ifdef WINDOWS_ENABLED String install_root_dir = GDMono::get_singleton()->get_mono_reg_info().install_root_dir; @@ -395,9 +352,6 @@ void register_editor_internal_calls() { GDMonoUtils::add_internal_call("GodotTools.Internals.EditorProgress::internal_Dispose", godot_icall_EditorProgress_Dispose); GDMonoUtils::add_internal_call("GodotTools.Internals.EditorProgress::internal_Step", godot_icall_EditorProgress_Step); - // ScriptClassParser - GDMonoUtils::add_internal_call("GodotTools.Internals.ScriptClassParser::internal_ParseFile", godot_icall_ScriptClassParser_ParseFile); - // ExportPlugin GDMonoUtils::add_internal_call("GodotTools.Export.ExportPlugin::internal_GetExportedAssemblyDependencies", godot_icall_ExportPlugin_GetExportedAssemblyDependencies); @@ -416,7 +370,6 @@ void register_editor_internal_calls() { GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_EditorDebuggerNodeReloadScripts", godot_icall_Internal_EditorDebuggerNodeReloadScripts); GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_ScriptEditorEdit", godot_icall_Internal_ScriptEditorEdit); GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_EditorNodeShowScriptScreen", godot_icall_Internal_EditorNodeShowScriptScreen); - GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_GetScriptsMetadataOrNothing", godot_icall_Internal_GetScriptsMetadataOrNothing); GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_MonoWindowsInstallRoot", godot_icall_Internal_MonoWindowsInstallRoot); GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_EditorRunPlay", godot_icall_Internal_EditorRunPlay); GDMonoUtils::add_internal_call("GodotTools.Internals.Internal::internal_EditorRunStop", godot_icall_Internal_EditorRunStop); diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp deleted file mode 100644 index e81cbe4ebd..0000000000 --- a/modules/mono/editor/script_class_parser.cpp +++ /dev/null @@ -1,753 +0,0 @@ -/*************************************************************************/ -/* script_class_parser.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "script_class_parser.h" - -#include "core/os/os.h" -#include "core/templates/map.h" - -#include "../utils/string_utils.h" - -const char *ScriptClassParser::token_names[ScriptClassParser::TK_MAX] = { - "[", - "]", - "{", - "}", - ".", - ":", - ",", - "Symbol", - "Identifier", - "String", - "Number", - "<", - ">", - "EOF", - "Error" -}; - -String ScriptClassParser::get_token_name(ScriptClassParser::Token p_token) { - ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>"); - return token_names[p_token]; -} - -ScriptClassParser::Token ScriptClassParser::get_token() { - while (true) { - switch (code[idx]) { - case '\n': { - line++; - idx++; - break; - }; - case 0: { - return TK_EOF; - } break; - case '{': { - idx++; - return TK_CURLY_BRACKET_OPEN; - }; - case '}': { - idx++; - return TK_CURLY_BRACKET_CLOSE; - }; - case '[': { - idx++; - return TK_BRACKET_OPEN; - }; - case ']': { - idx++; - return TK_BRACKET_CLOSE; - }; - case '<': { - idx++; - return TK_OP_LESS; - }; - case '>': { - idx++; - return TK_OP_GREATER; - }; - case ':': { - idx++; - return TK_COLON; - }; - case ',': { - idx++; - return TK_COMMA; - }; - case '.': { - idx++; - return TK_PERIOD; - }; - case '#': { - //compiler directive - while (code[idx] != '\n' && code[idx] != 0) { - idx++; - } - continue; - } break; - case '/': { - switch (code[idx + 1]) { - case '*': { // block comment - idx += 2; - while (true) { - if (code[idx] == 0) { - error_str = "Unterminated comment"; - error = true; - return TK_ERROR; - } else if (code[idx] == '*' && code[idx + 1] == '/') { - idx += 2; - break; - } else if (code[idx] == '\n') { - line++; - } - - idx++; - } - - } break; - case '/': { // line comment skip - while (code[idx] != '\n' && code[idx] != 0) { - idx++; - } - - } break; - default: { - value = "/"; - idx++; - return TK_SYMBOL; - } - } - - continue; // a comment - } break; - case '\'': - case '"': { - bool verbatim = idx != 0 && code[idx - 1] == '@'; - - char32_t begin_str = code[idx]; - idx++; - String tk_string = String(); - while (true) { - if (code[idx] == 0) { - error_str = "Unterminated String"; - error = true; - return TK_ERROR; - } else if (code[idx] == begin_str) { - if (verbatim && code[idx + 1] == '"') { // '""' is verbatim string's '\"' - idx += 2; // skip next '"' as well - continue; - } - - idx += 1; - break; - } else if (code[idx] == '\\' && !verbatim) { - //escaped characters... - idx++; - char32_t next = code[idx]; - if (next == 0) { - error_str = "Unterminated String"; - error = true; - return TK_ERROR; - } - char32_t res = 0; - - switch (next) { - case 'b': - res = 8; - break; - case 't': - res = 9; - break; - case 'n': - res = 10; - break; - case 'f': - res = 12; - break; - case 'r': - res = 13; - break; - case '\"': - res = '\"'; - break; - case '\\': - res = '\\'; - break; - default: { - res = next; - } break; - } - - tk_string += res; - - } else { - if (code[idx] == '\n') { - line++; - } - tk_string += code[idx]; - } - idx++; - } - - value = tk_string; - - return TK_STRING; - } break; - default: { - if (code[idx] <= 32) { - idx++; - break; - } - - if ((code[idx] >= 33 && code[idx] <= 47) || (code[idx] >= 58 && code[idx] <= 63) || (code[idx] >= 91 && code[idx] <= 94) || code[idx] == 96 || (code[idx] >= 123 && code[idx] <= 127)) { - value = String::chr(code[idx]); - idx++; - return TK_SYMBOL; - } - - if (code[idx] == '-' || (code[idx] >= '0' && code[idx] <= '9')) { - //a number - const char32_t *rptr; - double number = String::to_float(&code[idx], &rptr); - idx += (rptr - &code[idx]); - value = number; - return TK_NUMBER; - - } else if ((code[idx] == '@' && code[idx + 1] != '"') || code[idx] == '_' || (code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) { - String id; - - id += code[idx]; - idx++; - - while (code[idx] == '_' || (code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || (code[idx] >= '0' && code[idx] <= '9') || code[idx] > 127) { - id += code[idx]; - idx++; - } - - value = id; - return TK_IDENTIFIER; - } else if (code[idx] == '@' && code[idx + 1] == '"') { - // begin of verbatim string - idx++; - } else { - error_str = "Unexpected character."; - error = true; - return TK_ERROR; - } - } - } - } -} - -Error ScriptClassParser::_skip_generic_type_params() { - Token tk; - - while (true) { - tk = get_token(); - - if (tk == TK_IDENTIFIER) { - tk = get_token(); - // Type specifications can end with "?" to denote nullable types, such as IList<int?> - if (tk == TK_SYMBOL) { - tk = get_token(); - if (value.operator String() != "?") { - error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found unexpected symbol '" + value + "'"; - error = true; - return ERR_PARSE_ERROR; - } - if (tk != TK_OP_GREATER && tk != TK_COMMA) { - error_str = "Nullable type symbol '?' is only allowed after an identifier, but found " + get_token_name(tk) + " next."; - error = true; - return ERR_PARSE_ERROR; - } - } - - if (tk == TK_PERIOD) { - while (true) { - tk = get_token(); - - if (tk != TK_IDENTIFIER) { - error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - tk = get_token(); - - if (tk != TK_PERIOD) { - break; - } - } - } - - if (tk == TK_OP_LESS) { - Error err = _skip_generic_type_params(); - if (err) { - return err; - } - tk = get_token(); - } - - if (tk == TK_OP_GREATER) { - return OK; - } else if (tk != TK_COMMA) { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - } else if (tk == TK_OP_LESS) { - error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found " + get_token_name(TK_OP_LESS); - error = true; - return ERR_PARSE_ERROR; - } else if (tk == TK_OP_GREATER) { - return OK; - } else { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - } -} - -Error ScriptClassParser::_parse_type_full_name(String &r_full_name) { - Token tk = get_token(); - - if (tk != TK_IDENTIFIER) { - error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - r_full_name += String(value); - - if (code[idx] == '<') { - idx++; - - // We don't mind if the base is generic, but we skip it any ways since this information is not needed - Error err = _skip_generic_type_params(); - if (err) { - return err; - } - } - - if (code[idx] != '.') { // We only want to take the next token if it's a period - return OK; - } - - tk = get_token(); - - CRASH_COND(tk != TK_PERIOD); // Assertion - - r_full_name += "."; - - return _parse_type_full_name(r_full_name); -} - -Error ScriptClassParser::_parse_class_base(Vector<String> &r_base) { - String name; - - Error err = _parse_type_full_name(name); - if (err) { - return err; - } - - Token tk = get_token(); - - if (tk == TK_COMMA) { - err = _parse_class_base(r_base); - if (err) { - return err; - } - } else if (tk == TK_IDENTIFIER && String(value) == "where") { - err = _parse_type_constraints(); - if (err) { - return err; - } - - // An open curly bracket was parsed by _parse_type_constraints, so we can exit - } else if (tk == TK_CURLY_BRACKET_OPEN) { - // we are finished when we hit the open curly bracket - } else { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - r_base.push_back(name); - - return OK; -} - -Error ScriptClassParser::_parse_type_constraints() { - Token tk = get_token(); - if (tk != TK_IDENTIFIER) { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - tk = get_token(); - if (tk != TK_COLON) { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - while (true) { - tk = get_token(); - if (tk == TK_IDENTIFIER) { - if (String(value) == "where") { - return _parse_type_constraints(); - } - - tk = get_token(); - if (tk == TK_PERIOD) { - while (true) { - tk = get_token(); - - if (tk != TK_IDENTIFIER) { - error_str = "Expected " + get_token_name(TK_IDENTIFIER) + ", found: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - tk = get_token(); - - if (tk != TK_PERIOD) { - break; - } - } - } - } - - if (tk == TK_COMMA) { - continue; - } else if (tk == TK_IDENTIFIER && String(value) == "where") { - return _parse_type_constraints(); - } else if (tk == TK_SYMBOL && String(value) == "(") { - tk = get_token(); - if (tk != TK_SYMBOL || String(value) != ")") { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - } else if (tk == TK_OP_LESS) { - Error err = _skip_generic_type_params(); - if (err) { - return err; - } - } else if (tk == TK_CURLY_BRACKET_OPEN) { - return OK; - } else { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - } -} - -Error ScriptClassParser::_parse_namespace_name(String &r_name, int &r_curly_stack) { - Token tk = get_token(); - - if (tk == TK_IDENTIFIER) { - r_name += String(value); - } else { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - - tk = get_token(); - - if (tk == TK_PERIOD) { - r_name += "."; - return _parse_namespace_name(r_name, r_curly_stack); - } else if (tk == TK_CURLY_BRACKET_OPEN) { - r_curly_stack++; - return OK; - } else { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } -} - -Error ScriptClassParser::parse(const String &p_code) { - code = p_code; - idx = 0; - line = 0; - error_str = String(); - error = false; - value = Variant(); - classes.clear(); - - Token tk = get_token(); - - Map<int, NameDecl> name_stack; - int curly_stack = 0; - int type_curly_stack = 0; - - while (!error && tk != TK_EOF) { - String identifier = value; - if (tk == TK_IDENTIFIER && (identifier == "class" || identifier == "struct")) { - bool is_class = identifier == "class"; - - tk = get_token(); - - if (tk == TK_IDENTIFIER) { - String name = value; - int at_level = curly_stack; - - ClassDecl class_decl; - - for (Map<int, NameDecl>::Element *E = name_stack.front(); E; E = E->next()) { - const NameDecl &name_decl = E->value(); - - if (name_decl.type == NameDecl::NAMESPACE_DECL) { - if (E != name_stack.front()) { - class_decl.namespace_ += "."; - } - class_decl.namespace_ += name_decl.name; - } else { - class_decl.name += name_decl.name + "."; - } - } - - class_decl.name += name; - class_decl.nested = type_curly_stack > 0; - - bool generic = false; - - while (true) { - tk = get_token(); - - if (tk == TK_COLON) { - Error err = _parse_class_base(class_decl.base); - if (err) { - return err; - } - - curly_stack++; - type_curly_stack++; - - break; - } else if (tk == TK_CURLY_BRACKET_OPEN) { - curly_stack++; - type_curly_stack++; - break; - } else if (tk == TK_OP_LESS && !generic) { - generic = true; - - Error err = _skip_generic_type_params(); - if (err) { - return err; - } - } else if (tk == TK_IDENTIFIER && String(value) == "where") { - Error err = _parse_type_constraints(); - if (err) { - return err; - } - - // An open curly bracket was parsed by _parse_type_constraints, so we can exit - curly_stack++; - type_curly_stack++; - break; - } else { - error_str = "Unexpected token: " + get_token_name(tk); - error = true; - return ERR_PARSE_ERROR; - } - } - - NameDecl name_decl; - name_decl.name = name; - name_decl.type = is_class ? NameDecl::CLASS_DECL : NameDecl::STRUCT_DECL; - name_stack[at_level] = name_decl; - - if (is_class) { - if (!generic) { // no generics, thanks - classes.push_back(class_decl); - } else if (OS::get_singleton()->is_stdout_verbose()) { - String full_name = class_decl.namespace_; - if (full_name.length()) { - full_name += "."; - } - full_name += class_decl.name; - OS::get_singleton()->print("Ignoring generic class declaration: %s\n", full_name.utf8().get_data()); - } - } - } - } else if (tk == TK_IDENTIFIER && identifier == "namespace") { - if (type_curly_stack > 0) { - error_str = "Found namespace nested inside type."; - error = true; - return ERR_PARSE_ERROR; - } - - String name; - int at_level = curly_stack; - - Error err = _parse_namespace_name(name, curly_stack); - if (err) { - return err; - } - - NameDecl name_decl; - name_decl.name = name; - name_decl.type = NameDecl::NAMESPACE_DECL; - name_stack[at_level] = name_decl; - } else if (tk == TK_CURLY_BRACKET_OPEN) { - curly_stack++; - } else if (tk == TK_CURLY_BRACKET_CLOSE) { - curly_stack--; - if (name_stack.has(curly_stack)) { - if (name_stack[curly_stack].type != NameDecl::NAMESPACE_DECL) { - type_curly_stack--; - } - name_stack.erase(curly_stack); - } - } - - tk = get_token(); - } - - if (!error && tk == TK_EOF && curly_stack > 0) { - error_str = "Reached EOF with missing close curly brackets."; - error = true; - } - - if (error) { - return ERR_PARSE_ERROR; - } - - return OK; -} - -static String get_preprocessor_directive(const String &p_line, int p_from) { - CRASH_COND(p_line[p_from] != '#'); - p_from++; - int i = p_from; - while (i < p_line.length() && (p_line[i] == '_' || (p_line[i] >= 'A' && p_line[i] <= 'Z') || - (p_line[i] >= 'a' && p_line[i] <= 'z') || p_line[i] > 127)) { - i++; - } - return p_line.substr(p_from, i - p_from); -} - -static void run_dummy_preprocessor(String &r_source, const String &p_filepath) { - Vector<String> lines = r_source.split("\n", /* p_allow_empty: */ true); - - bool *include_lines = memnew_arr(bool, lines.size()); - - int if_level = -1; - Vector<bool> is_branch_being_compiled; - - for (int i = 0; i < lines.size(); i++) { - const String &line = lines[i]; - - const int line_len = line.length(); - - int j; - for (j = 0; j < line_len; j++) { - if (line[j] != ' ' && line[j] != '\t') { - if (line[j] == '#') { - // First non-whitespace char of the line is '#' - include_lines[i] = false; - - String directive = get_preprocessor_directive(line, j); - - if (directive == "if") { - if_level++; - is_branch_being_compiled.push_back(if_level == 0 || is_branch_being_compiled[if_level - 1]); - } else if (directive == "elif") { - ERR_CONTINUE_MSG(if_level == -1, "Found unexpected '#elif' directive. File: '" + p_filepath + "'."); - is_branch_being_compiled.write[if_level] = false; - } else if (directive == "else") { - ERR_CONTINUE_MSG(if_level == -1, "Found unexpected '#else' directive. File: '" + p_filepath + "'."); - is_branch_being_compiled.write[if_level] = false; - } else if (directive == "endif") { - ERR_CONTINUE_MSG(if_level == -1, "Found unexpected '#endif' directive. File: '" + p_filepath + "'."); - is_branch_being_compiled.remove(if_level); - if_level--; - } - - break; - } else { - // First non-whitespace char of the line is not '#' - include_lines[i] = if_level == -1 || is_branch_being_compiled[if_level]; - break; - } - } - } - - if (j == line_len) { - // Loop ended without finding a non-whitespace character. - // Either the line was empty or it only contained whitespaces. - include_lines[i] = if_level == -1 || is_branch_being_compiled[if_level]; - } - } - - r_source.clear(); - - // Custom join ignoring lines removed by the preprocessor - for (int i = 0; i < lines.size(); i++) { - if (i > 0 && include_lines[i - 1]) { - r_source += '\n'; - } - - if (include_lines[i]) { - r_source += lines[i]; - } - } -} - -Error ScriptClassParser::parse_file(const String &p_filepath) { - String source; - - Error ferr = read_all_file_utf8(p_filepath, source); - - ERR_FAIL_COND_V_MSG(ferr != OK, ferr, - ferr == ERR_INVALID_DATA ? - "File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded." - " Please ensure that scripts are saved in valid UTF-8 unicode." : - "Failed to read file: '" + p_filepath + "'."); - - run_dummy_preprocessor(source, p_filepath); - - return parse(source); -} - -String ScriptClassParser::get_error() { - return error_str; -} - -Vector<ScriptClassParser::ClassDecl> ScriptClassParser::get_classes() { - return classes; -} diff --git a/modules/mono/editor/script_class_parser.h b/modules/mono/editor/script_class_parser.h deleted file mode 100644 index 75a46bb4e5..0000000000 --- a/modules/mono/editor/script_class_parser.h +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************/ -/* script_class_parser.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef SCRIPT_CLASS_PARSER_H -#define SCRIPT_CLASS_PARSER_H - -#include "core/string/ustring.h" -#include "core/templates/vector.h" -#include "core/variant/variant.h" - -class ScriptClassParser { -public: - struct NameDecl { - enum Type { - NAMESPACE_DECL, - CLASS_DECL, - STRUCT_DECL - }; - - String name; - Type type = NAMESPACE_DECL; - }; - - struct ClassDecl { - String name; - String namespace_; - Vector<String> base; - bool nested = false; - }; - -private: - String code; - int idx = 0; - int line = 0; - String error_str; - bool error = false; - Variant value; - - Vector<ClassDecl> classes; - - enum Token { - TK_BRACKET_OPEN, - TK_BRACKET_CLOSE, - TK_CURLY_BRACKET_OPEN, - TK_CURLY_BRACKET_CLOSE, - TK_PERIOD, - TK_COLON, - TK_COMMA, - TK_SYMBOL, - TK_IDENTIFIER, - TK_STRING, - TK_NUMBER, - TK_OP_LESS, - TK_OP_GREATER, - TK_EOF, - TK_ERROR, - TK_MAX - }; - - static const char *token_names[TK_MAX]; - static String get_token_name(Token p_token); - - Token get_token(); - - Error _skip_generic_type_params(); - - Error _parse_type_full_name(String &r_full_name); - Error _parse_class_base(Vector<String> &r_base); - Error _parse_type_constraints(); - Error _parse_namespace_name(String &r_name, int &r_curly_stack); - -public: - Error parse(const String &p_code); - Error parse_file(const String &p_filepath); - - String get_error(); - - Vector<ClassDecl> get_classes(); -}; - -#endif // SCRIPT_CLASS_PARSER_H diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs new file mode 100644 index 0000000000..ef135da51a --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/AssemblyHasScriptsAttribute.cs @@ -0,0 +1,22 @@ +using System; + +namespace Godot +{ + [AttributeUsage(AttributeTargets.Assembly)] + public class AssemblyHasScriptsAttribute : Attribute + { + private readonly bool requiresLookup; + private readonly System.Type[] scriptTypes; + + public AssemblyHasScriptsAttribute() + { + requiresLookup = true; + } + + public AssemblyHasScriptsAttribute(System.Type[] scriptTypes) + { + requiresLookup = false; + this.scriptTypes = scriptTypes; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/DisableGodotGeneratorsAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/DisableGodotGeneratorsAttribute.cs new file mode 100644 index 0000000000..ac6cffceb2 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/DisableGodotGeneratorsAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace Godot +{ + [AttributeUsage(AttributeTargets.Class)] + public class DisableGodotGeneratorsAttribute : Attribute + { + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ScriptPathAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ScriptPathAttribute.cs new file mode 100644 index 0000000000..12eb1035c3 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ScriptPathAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Godot +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + public class ScriptPathAttribute : Attribute + { + private string path; + + public ScriptPathAttribute(string path) + { + this.path = path; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs new file mode 100644 index 0000000000..702a6c76ba --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Godot +{ + public static partial class GD + { + /// <summary> + /// Fires when an unhandled exception occurs, regardless of project settings. + /// </summary> + public static event EventHandler<UnhandledExceptionArgs> UnhandledException; + + private static void OnUnhandledException(Exception e) + { + UnhandledException?.Invoke(null, new UnhandledExceptionArgs(e)); + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs new file mode 100644 index 0000000000..be01674568 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/UnhandledExceptionArgs.cs @@ -0,0 +1,20 @@ +using System; + +namespace Godot +{ + /// <summary> + /// Event arguments for when unhandled exceptions occur. + /// </summary> + public class UnhandledExceptionArgs + { + /// <summary> + /// Exception object + /// </summary> + public Exception Exception { get; private set; } + + internal UnhandledExceptionArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj index 7c1a23d510..54aaaf1f92 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -14,9 +14,12 @@ <ItemGroup> <Compile Include="Core\AABB.cs" /> <Compile Include="Core\Array.cs" /> + <Compile Include="Core\Attributes\AssemblyHasScriptsAttribute.cs" /> + <Compile Include="Core\Attributes\DisableGodotGeneratorsAttribute.cs" /> <Compile Include="Core\Attributes\ExportAttribute.cs" /> <Compile Include="Core\Attributes\GodotMethodAttribute.cs" /> <Compile Include="Core\Attributes\RPCAttributes.cs" /> + <Compile Include="Core\Attributes\ScriptPathAttribute.cs" /> <Compile Include="Core\Attributes\SignalAttribute.cs" /> <Compile Include="Core\Attributes\ToolAttribute.cs" /> <Compile Include="Core\Basis.cs" /> @@ -37,6 +40,7 @@ <Compile Include="Core\GodotSynchronizationContext.cs" /> <Compile Include="Core\GodotTaskScheduler.cs" /> <Compile Include="Core\GodotTraceListener.cs" /> + <Compile Include="Core\GodotUnhandledExceptionEvent.cs" /> <Compile Include="Core\Interfaces\IAwaitable.cs" /> <Compile Include="Core\Interfaces\IAwaiter.cs" /> <Compile Include="Core\Interfaces\ISerializationListener.cs" /> @@ -56,6 +60,7 @@ <Compile Include="Core\StringName.cs" /> <Compile Include="Core\Transform.cs" /> <Compile Include="Core\Transform2D.cs" /> + <Compile Include="Core\UnhandledExceptionArgs.cs" /> <Compile Include="Core\Vector2.cs" /> <Compile Include="Core\Vector2i.cs" /> <Compile Include="Core\Vector3.cs" /> diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index a39a6fe381..020a40575c 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -179,16 +179,16 @@ private: #ifdef OSX_ENABLED if (!DirAccess::exists(data_editor_tools_dir)) { - data_editor_tools_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Tools"); + data_editor_tools_dir = exe_dir.plus_file("../Resources/GodotSharp/Tools"); } if (!DirAccess::exists(data_editor_prebuilt_api_dir)) { - data_editor_prebuilt_api_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Api"); + data_editor_prebuilt_api_dir = exe_dir.plus_file("../Resources/GodotSharp/Api"); } if (!DirAccess::exists(data_mono_root_dir)) { data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/lib"); + data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); } #endif @@ -218,11 +218,11 @@ private: #ifdef OSX_ENABLED if (!DirAccess::exists(data_mono_root_dir)) { data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/lib"); + data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); } if (!DirAccess::exists(data_game_assemblies_dir)) { - data_game_assemblies_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Assemblies"); + data_game_assemblies_dir = exe_dir.plus_file("../Resources/GodotSharp/Assemblies"); } #endif diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 43a39a4966..560788fb3a 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -1006,6 +1006,7 @@ bool GDMono::_load_project_assembly() { if (success) { mono_assembly_set_main(project_assembly->get_assembly()); + CSharpLanguage::get_singleton()->lookup_scripts_in_assembly(project_assembly); } return success; diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 1fe06bfbee..a1556bace5 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -345,6 +345,45 @@ String GDMonoAssembly::get_path() const { return String::utf8(mono_image_get_filename(image)); } +bool GDMonoAssembly::has_attribute(GDMonoClass *p_attr_class) { +#ifdef DEBUG_ENABLED + ERR_FAIL_NULL_V(p_attr_class, false); +#endif + + if (!attrs_fetched) { + fetch_attributes(); + } + + if (!attributes) { + return false; + } + + return mono_custom_attrs_has_attr(attributes, p_attr_class->get_mono_ptr()); +} + +MonoObject *GDMonoAssembly::get_attribute(GDMonoClass *p_attr_class) { +#ifdef DEBUG_ENABLED + ERR_FAIL_NULL_V(p_attr_class, nullptr); +#endif + + if (!attrs_fetched) { + fetch_attributes(); + } + + if (!attributes) { + return nullptr; + } + + return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); +} + +void GDMonoAssembly::fetch_attributes() { + ERR_FAIL_COND(attributes != nullptr); + + attributes = mono_custom_attrs_from_assembly(assembly); + attrs_fetched = true; +} + GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) { ERR_FAIL_NULL_V(image, nullptr); @@ -390,70 +429,6 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { return wrapped_class; } -GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) { - GDMonoClass *match = nullptr; - - if (gdobject_class_cache_updated) { - Map<StringName, GDMonoClass *>::Element *result = gdobject_class_cache.find(p_class); - - if (result) { - match = result->get(); - } - } else { - List<GDMonoClass *> nested_classes; - - int rows = mono_image_get_table_rows(image, MONO_TABLE_TYPEDEF); - - for (int i = 1; i < rows; i++) { - MonoClass *mono_class = mono_class_get(image, (i + 1) | MONO_TOKEN_TYPE_DEF); - - if (!mono_class_is_assignable_from(CACHED_CLASS_RAW(GodotObject), mono_class)) { - continue; - } - - GDMonoClass *current = get_class(mono_class); - - if (!current) { - continue; - } - - nested_classes.push_back(current); - - if (!match && current->get_name() == p_class) { - match = current; - } - - while (!nested_classes.is_empty()) { - GDMonoClass *current_nested = nested_classes.front()->get(); - nested_classes.pop_front(); - - void *iter = nullptr; - - while (true) { - MonoClass *raw_nested = mono_class_get_nested_types(current_nested->get_mono_ptr(), &iter); - - if (!raw_nested) { - break; - } - - GDMonoClass *nested_class = get_class(raw_nested); - - if (nested_class) { - gdobject_class_cache.insert(nested_class->get_name(), nested_class); - nested_classes.push_back(nested_class); - } - } - } - - gdobject_class_cache.insert(current->get_name(), current); - } - - gdobject_class_cache_updated = true; - } - - return match; -} - GDMonoAssembly *GDMonoAssembly::load(const String &p_name, MonoAssemblyName *p_aname, bool p_refonly, const Vector<String> &p_search_dirs) { if (GDMono::get_singleton()->get_corlib_assembly() && (p_name == "mscorlib" || p_name == "mscorlib.dll")) { return GDMono::get_singleton()->get_corlib_assembly(); diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h index 350fcf3210..6191c491f4 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.h +++ b/modules/mono/mono_gd/gd_mono_assembly.h @@ -71,13 +71,13 @@ class GDMonoAssembly { MonoImage *image; MonoAssembly *assembly; + bool attrs_fetched = false; + MonoCustomAttrInfo *attributes = nullptr; + #ifdef GD_MONO_HOT_RELOAD uint64_t modified_time = 0; #endif - bool gdobject_class_cache_updated = false; - Map<StringName, GDMonoClass *> gdobject_class_cache; - HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes; Map<MonoClass *, GDMonoClass *> cached_raw; @@ -111,11 +111,14 @@ public: String get_path() const; + bool has_attribute(GDMonoClass *p_attr_class); + MonoObject *get_attribute(GDMonoClass *p_attr_class); + + void fetch_attributes(); + GDMonoClass *get_class(const StringName &p_namespace, const StringName &p_name); GDMonoClass *get_class(MonoClass *p_mono_class); - GDMonoClass *get_object_derived_class(const StringName &p_class); - static String find_assembly(const String &p_name); static void fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config = String(), const String &p_custom_bcl_dir = String()); diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp index aea467660f..d66cc29b9a 100644 --- a/modules/mono/mono_gd/gd_mono_cache.cpp +++ b/modules/mono/mono_gd/gd_mono_cache.cpp @@ -148,6 +148,11 @@ void CachedData::clear_godot_api_cache() { class_PuppetSyncAttribute = nullptr; class_GodotMethodAttribute = nullptr; field_GodotMethodAttribute_methodName = nullptr; + class_ScriptPathAttribute = nullptr; + field_ScriptPathAttribute_path = nullptr; + class_AssemblyHasScriptsAttribute = nullptr; + field_AssemblyHasScriptsAttribute_requiresLookup = nullptr; + field_AssemblyHasScriptsAttribute_scriptTypes = nullptr; field_GodotObject_ptr = nullptr; field_StringName_ptr = nullptr; @@ -272,6 +277,11 @@ void update_godot_api_cache() { CACHE_CLASS_AND_CHECK(PuppetSyncAttribute, GODOT_API_CLASS(PuppetSyncAttribute)); CACHE_CLASS_AND_CHECK(GodotMethodAttribute, GODOT_API_CLASS(GodotMethodAttribute)); CACHE_FIELD_AND_CHECK(GodotMethodAttribute, methodName, CACHED_CLASS(GodotMethodAttribute)->get_field("methodName")); + CACHE_CLASS_AND_CHECK(ScriptPathAttribute, GODOT_API_CLASS(ScriptPathAttribute)); + CACHE_FIELD_AND_CHECK(ScriptPathAttribute, path, CACHED_CLASS(ScriptPathAttribute)->get_field("path")); + CACHE_CLASS_AND_CHECK(AssemblyHasScriptsAttribute, GODOT_API_CLASS(AssemblyHasScriptsAttribute)); + CACHE_FIELD_AND_CHECK(AssemblyHasScriptsAttribute, requiresLookup, CACHED_CLASS(AssemblyHasScriptsAttribute)->get_field("requiresLookup")); + CACHE_FIELD_AND_CHECK(AssemblyHasScriptsAttribute, scriptTypes, CACHED_CLASS(AssemblyHasScriptsAttribute)->get_field("scriptTypes")); CACHE_FIELD_AND_CHECK(GodotObject, ptr, CACHED_CLASS(GodotObject)->get_field(BINDINGS_PTR_FIELD)); CACHE_FIELD_AND_CHECK(StringName, ptr, CACHED_CLASS(StringName)->get_field(BINDINGS_PTR_FIELD)); diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h index fb75cb4b1c..51370da452 100644 --- a/modules/mono/mono_gd/gd_mono_cache.h +++ b/modules/mono/mono_gd/gd_mono_cache.h @@ -119,6 +119,11 @@ struct CachedData { GDMonoClass *class_PuppetSyncAttribute; GDMonoClass *class_GodotMethodAttribute; GDMonoField *field_GodotMethodAttribute_methodName; + GDMonoClass *class_ScriptPathAttribute; + GDMonoField *field_ScriptPathAttribute_path; + GDMonoClass *class_AssemblyHasScriptsAttribute; + GDMonoField *field_AssemblyHasScriptsAttribute_requiresLookup; + GDMonoField *field_AssemblyHasScriptsAttribute_scriptTypes; GDMonoField *field_GodotObject_ptr; GDMonoField *field_StringName_ptr; diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 65e2680905..fa93c6533a 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -43,7 +43,6 @@ #include <mono/metadata/exception.h> namespace GDMonoInternals { - void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { // This method should not fail @@ -113,9 +112,11 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { void unhandled_exception(MonoException *p_exc) { mono_print_unhandled_exception((MonoObject *)p_exc); + gd_unhandled_exception_event(p_exc); if (GDMono::get_singleton()->get_unhandled_exception_policy() == GDMono::POLICY_TERMINATE_APP) { // Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders + mono_unhandled_exception((MonoObject *)p_exc); GDMono::unhandled_exception_hook((MonoObject *)p_exc, nullptr); GD_UNREACHABLE(); } else { @@ -127,4 +128,14 @@ void unhandled_exception(MonoException *p_exc) { #endif } } + +void gd_unhandled_exception_event(MonoException *p_exc) { + MonoImage *mono_image = GDMono::get_singleton()->get_core_api_assembly()->get_image(); + + MonoClass *gd_klass = mono_class_from_name(mono_image, "Godot", "GD"); + MonoMethod *unhandled_exception_method = mono_class_get_method_from_name(gd_klass, "OnUnhandledException", -1); + void *args[1]; + args[0] = p_exc; + mono_runtime_invoke(unhandled_exception_method, nullptr, (void **)args, nullptr); +} } // namespace GDMonoInternals diff --git a/modules/mono/mono_gd/gd_mono_internals.h b/modules/mono/mono_gd/gd_mono_internals.h index 34d2d35b2d..26eb270eee 100644 --- a/modules/mono/mono_gd/gd_mono_internals.h +++ b/modules/mono/mono_gd/gd_mono_internals.h @@ -38,7 +38,6 @@ #include "core/object/class_db.h" namespace GDMonoInternals { - void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged); /** @@ -46,6 +45,8 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged); * Use GDMonoUtils::debug_unhandled_exception(MonoException *) instead. */ void unhandled_exception(MonoException *p_exc); + +void gd_unhandled_exception_event(MonoException *p_exc); } // namespace GDMonoInternals #endif // GD_MONO_INTERNALS_H diff --git a/modules/text_server_adv/bitmap_font_adv.cpp b/modules/text_server_adv/bitmap_font_adv.cpp index e33556b232..df7b42eac6 100644 --- a/modules/text_server_adv/bitmap_font_adv.cpp +++ b/modules/text_server_adv/bitmap_font_adv.cpp @@ -361,6 +361,10 @@ Error BitmapFontDataAdvanced::load_from_file(const String &p_filename, int p_bas base_size = height; } + if (hb_handle) { + hb_font_destroy(hb_handle); + } + hb_handle = hb_bmp_font_create(this, base_size, nullptr); valid = true; memdelete(f); @@ -379,12 +383,10 @@ Error BitmapFontDataAdvanced::bitmap_new(float p_height, float p_ascent, int p_b char_map.clear(); textures.clear(); kerning_map.clear(); - - for (Map<float, hb_font_t *>::Element *E = cache.front(); E; E = E->next()) { - hb_font_destroy(E->get()); + if (hb_handle) { + hb_font_destroy(hb_handle); } - cache.clear(); - + hb_handle = hb_bmp_font_create(this, base_size, nullptr); valid = true; return OK; @@ -466,10 +468,7 @@ float BitmapFontDataAdvanced::get_base_size() const { hb_font_t *BitmapFontDataAdvanced::get_hb_handle(int p_size) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!valid, nullptr); - if (!cache.has(p_size)) { - cache[p_size] = hb_bmp_font_create(this, p_size, nullptr); - } - return cache[p_size]; + return hb_handle; } bool BitmapFontDataAdvanced::has_char(char32_t p_char) const { @@ -516,6 +515,10 @@ Vector2 BitmapFontDataAdvanced::get_size(uint32_t p_char, int p_size) const { return c->rect.size * (float(p_size) / float(base_size)); } +float BitmapFontDataAdvanced::get_font_scale(int p_size) const { + return float(p_size) / float(base_size); +} + Vector2 BitmapFontDataAdvanced::get_kerning(uint32_t p_char, uint32_t p_next, int p_size) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!valid, Vector2()); @@ -543,13 +546,13 @@ Vector2 BitmapFontDataAdvanced::draw_glyph(RID p_canvas, int p_size, const Vecto ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), Vector2()); if (c->texture_idx != -1) { Point2i cpos = p_pos; - cpos += c->align * (float(p_size) / float(base_size)); - cpos.y -= ascent * (float(p_size) / float(base_size)); + cpos += (c->align + Vector2(0, -ascent)) * (float(p_size) / float(base_size)); + Size2i csize = c->rect.size * (float(p_size) / float(base_size)); if (RenderingServer::get_singleton() != nullptr) { //if (distance_field_hint) { // Not implemented. // RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, true); //} - RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, c->rect.size * (float(p_size) / float(base_size))), textures[c->texture_idx]->get_rid(), c->rect, p_color, false, false); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, csize), textures[c->texture_idx]->get_rid(), c->rect, p_color, false, false); //if (distance_field_hint) { // RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, false); //} @@ -576,7 +579,7 @@ Vector2 BitmapFontDataAdvanced::draw_glyph_outline(RID p_canvas, int p_size, int } BitmapFontDataAdvanced::~BitmapFontDataAdvanced() { - for (Map<float, hb_font_t *>::Element *E = cache.front(); E; E = E->next()) { - hb_font_destroy(E->get()); + if (hb_handle) { + hb_font_destroy(hb_handle); } } diff --git a/modules/text_server_adv/bitmap_font_adv.h b/modules/text_server_adv/bitmap_font_adv.h index da7c2b00ac..7b620021e1 100644 --- a/modules/text_server_adv/bitmap_font_adv.h +++ b/modules/text_server_adv/bitmap_font_adv.h @@ -63,11 +63,11 @@ private: HashMap<uint32_t, Character> char_map; Map<KerningPairKey, int> kerning_map; - Map<float, hb_font_t *> cache; + hb_font_t *hb_handle = nullptr; float height = 0.f; float ascent = 0.f; - float base_size = 0.f; + int base_size = 0; bool distance_field_hint = false; public: @@ -101,6 +101,7 @@ public: virtual bool has_outline() const override { return false; }; virtual float get_base_size() const override; + virtual float get_font_scale(int p_size) const override; virtual hb_font_t *get_hb_handle(int p_size) override; diff --git a/modules/text_server_fb/bitmap_font_fb.cpp b/modules/text_server_fb/bitmap_font_fb.cpp index c58f8cbba1..313f170f04 100644 --- a/modules/text_server_fb/bitmap_font_fb.cpp +++ b/modules/text_server_fb/bitmap_font_fb.cpp @@ -319,14 +319,13 @@ Vector2 BitmapFontDataFallback::draw_glyph(RID p_canvas, int p_size, const Vecto ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), Vector2()); if (c->texture_idx != -1) { Point2i cpos = p_pos; - cpos += c->align * (float(p_size) / float(base_size)); - cpos.y -= ascent * (float(p_size) / float(base_size)); - + cpos += (c->align + Vector2(0, -ascent)) * (float(p_size) / float(base_size)); + Size2i csize = c->rect.size * (float(p_size) / float(base_size)); if (RenderingServer::get_singleton() != nullptr) { //if (distance_field_hint) { // Not implemented. // RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, true); //} - RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, c->rect.size * (float(p_size) / float(base_size))), textures[c->texture_idx]->get_rid(), c->rect, p_color, false, false); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, csize), textures[c->texture_idx]->get_rid(), c->rect, p_color, false, false); //if (distance_field_hint) { // RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, false); //} diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 50b61c0db3..a760e36982 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -17,7 +17,7 @@ sys_env.AddJSLibraries( [ "js/libs/library_godot_audio.js", "js/libs/library_godot_display.js", - "js/libs/library_godot_http_request.js", + "js/libs/library_godot_fetch.js", "js/libs/library_godot_os.js", "js/libs/library_godot_runtime.js", ] @@ -86,40 +86,6 @@ wrap_list = [ ] js_wrapped = env.Textfile("#bin/godot", [env.File(f) for f in wrap_list], TEXTFILESUFFIX="${PROGSUFFIX}.wrapped.js") -zip_dir = env.Dir("#bin/.javascript_zip") -binary_name = "godot.tools" if env["tools"] else "godot" -out_files = [ - zip_dir.File(binary_name + ".js"), - zip_dir.File(binary_name + ".wasm"), - zip_dir.File(binary_name + ".html"), - zip_dir.File(binary_name + ".audio.worklet.js"), -] -html_file = "#misc/dist/html/full-size.html" -if env["tools"]: - subst_dict = {"@GODOT_VERSION@": env.GetBuildVersion()} - html_file = env.Substfile( - target="#bin/godot${PROGSUFFIX}.html", source="#misc/dist/html/editor.html", SUBST_DICT=subst_dict - ) - -in_files = [js_wrapped, build[1], html_file, "#platform/javascript/js/libs/audio.worklet.js"] -if env["gdnative_enabled"]: - in_files.append(build[2]) # Runtime - out_files.append(zip_dir.File(binary_name + ".side.wasm")) -elif env["threads_enabled"]: - in_files.append(build[2]) # Worker - out_files.append(zip_dir.File(binary_name + ".worker.js")) - -if env["tools"]: - in_files.append("#misc/dist/html/logo.svg") - out_files.append(zip_dir.File("logo.svg")) - in_files.append("#icon.png") - out_files.append(zip_dir.File("favicon.png")) - -zip_files = env.InstallAs(out_files, in_files) -env.Zip( - "#bin/godot", - zip_files, - ZIPROOT=zip_dir, - ZIPSUFFIX="${PROGSUFFIX}${ZIPSUFFIX}", - ZIPCOMSTR="Archiving $SOURCES as $TARGET", -) +# Extra will be the thread worker, or the GDNative side, or None +extra = build[2] if len(build) > 2 else None +env.CreateTemplateZip(js_wrapped, build[1], extra) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 4297088c09..e80ef374ec 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -7,7 +7,7 @@ from emscripten_helpers import ( add_js_libraries, add_js_pre, add_js_externs, - get_build_version, + create_template_zip, ) from methods import get_compiler_version from SCons.Util import WhereIs @@ -147,12 +147,12 @@ def configure(env): env.AddMethod(add_js_pre, "AddJSPre") env.AddMethod(add_js_externs, "AddJSExterns") - # Add method for getting build version string. - env.AddMethod(get_build_version, "GetBuildVersion") - # Add method that joins/compiles our Engine files. env.AddMethod(create_engine_file, "CreateEngineFile") + # Add method for creating the final zip file + env.AddMethod(create_template_zip, "CreateTemplateZip") + # Closure compiler extern and support for ecmascript specs (const, let, etc). env["ENV"]["EMCC_CLOSURE_ARGS"] = "--language_in ECMASCRIPT6" diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index a605f22e16..12e06e24dc 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -683,7 +683,7 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive godot_js_config_canvas_id_get(canvas_id, 256); // Handle contextmenu, webglcontextlost - godot_js_display_setup_canvas(p_resolution.x, p_resolution.y, p_mode == WINDOW_MODE_FULLSCREEN); + godot_js_display_setup_canvas(p_resolution.x, p_resolution.y, p_mode == WINDOW_MODE_FULLSCREEN, OS::get_singleton()->is_hidpi_allowed() ? 1 : 0); // Check if it's windows. swap_cancel_ok = godot_js_display_is_swap_ok_cancel() == 1; diff --git a/platform/javascript/emscripten_helpers.py b/platform/javascript/emscripten_helpers.py index d08555916b..04fbba8a41 100644 --- a/platform/javascript/emscripten_helpers.py +++ b/platform/javascript/emscripten_helpers.py @@ -15,7 +15,7 @@ def run_closure_compiler(target, source, env, for_signature): return " ".join(cmd) -def get_build_version(env): +def get_build_version(): import version name = "custom_build" @@ -30,6 +30,65 @@ def create_engine_file(env, target, source, externs): return env.Textfile(target, [env.File(s) for s in source]) +def create_template_zip(env, js, wasm, extra): + binary_name = "godot.tools" if env["tools"] else "godot" + zip_dir = env.Dir("#bin/.javascript_zip") + in_files = [ + js, + wasm, + "#platform/javascript/js/libs/audio.worklet.js", + ] + out_files = [ + zip_dir.File(binary_name + ".js"), + zip_dir.File(binary_name + ".wasm"), + zip_dir.File(binary_name + ".audio.worklet.js"), + ] + # GDNative/Threads specific + if env["gdnative_enabled"]: + in_files.append(extra) # Runtime + out_files.append(zip_dir.File(binary_name + ".side.wasm")) + elif env["threads_enabled"]: + in_files.append(extra) # Worker + out_files.append(zip_dir.File(binary_name + ".worker.js")) + + service_worker = "#misc/dist/html/service-worker.js" + if env["tools"]: + # HTML + html = "#misc/dist/html/editor.html" + subst_dict = {"@GODOT_VERSION@": get_build_version(), "@GODOT_NAME@": "GodotEngine"} + html = env.Substfile(target="#bin/godot${PROGSUFFIX}.html", source=html, SUBST_DICT=subst_dict) + in_files.append(html) + out_files.append(zip_dir.File(binary_name + ".html")) + # And logo/favicon + in_files.append("#misc/dist/html/logo.svg") + out_files.append(zip_dir.File("logo.svg")) + in_files.append("#icon.png") + out_files.append(zip_dir.File("favicon.png")) + # PWA + service_worker = env.Substfile( + target="#bin/godot${PROGSUFFIX}.service.worker.js", source=service_worker, SUBST_DICT=subst_dict + ) + in_files.append(service_worker) + out_files.append(zip_dir.File("service.worker.js")) + in_files.append("#misc/dist/html/manifest.json") + out_files.append(zip_dir.File("manifest.json")) + in_files.append("#misc/dist/html/offline.html") + out_files.append(zip_dir.File("offline.html")) + else: + # HTML + in_files.append("#misc/dist/html/full-size.html") + out_files.append(zip_dir.File(binary_name + ".html")) + + zip_files = env.InstallAs(out_files, in_files) + env.Zip( + "#bin/godot", + zip_files, + ZIPROOT=zip_dir, + ZIPSUFFIX="${PROGSUFFIX}${ZIPSUFFIX}", + ZIPCOMSTR="Archiving $SOURCES as $TARGET", + ) + + def add_js_libraries(env, libraries): env.Append(JS_LIBS=env.File(libraries)) diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 353cc49ef8..46d0458ca1 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -242,7 +242,7 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform { return name; } - void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects); + void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects, const Dictionary &p_file_sizes); static void _server_thread_poll(void *data); @@ -281,7 +281,7 @@ public: ~EditorExportPlatformJavaScript(); }; -void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects) { +void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects, const Dictionary &p_file_sizes) { String str_template = String::utf8(reinterpret_cast<const char *>(p_html.ptr()), p_html.size()); String str_export; Vector<String> lines = str_template.split("\n"); @@ -300,6 +300,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re config["gdnativeLibs"] = libs; config["executable"] = p_name; config["args"] = args; + config["fileSizes"] = p_file_sizes; const String str_config = JSON::print(config); for (int i = 0; i < lines.size(); i++) { @@ -472,6 +473,8 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese return ERR_FILE_CORRUPT; } + Vector<uint8_t> html; + Dictionary file_sizes; do { //get filename unz_file_info info; @@ -480,6 +483,16 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese String file = fname; + // HTML is handled later + if (file == "godot.html") { + if (custom_html.is_empty()) { + html.resize(info.uncompressed_size); + unzOpenCurrentFile(pkg); + unzReadCurrentFile(pkg, html.ptrw(), html.size()); + unzCloseCurrentFile(pkg); + } + continue; + } Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -490,14 +503,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese //write - if (file == "godot.html") { - if (!custom_html.is_empty()) { - continue; - } - _fix_html(data, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects); - file = p_path.get_file(); - - } else if (file == "godot.js") { + if (file == "godot.js") { file = p_path.get_file().get_basename() + ".js"; } else if (file == "godot.worker.js") { @@ -511,6 +517,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese } else if (file == "godot.wasm") { file = p_path.get_file().get_basename() + ".wasm"; + file_sizes[file.get_file()] = (uint64_t)info.uncompressed_size; } String dst = p_path.get_base_dir().plus_file(file); @@ -532,19 +539,26 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese EditorNode::get_singleton()->show_warning(TTR("Could not read custom HTML shell:") + "\n" + custom_html); return ERR_FILE_CANT_READ; } - Vector<uint8_t> buf; - buf.resize(f->get_len()); - f->get_buffer(buf.ptrw(), buf.size()); + html.resize(f->get_len()); + f->get_buffer(html.ptrw(), html.size()); memdelete(f); - _fix_html(buf, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects); - + } + { + FileAccess *f = FileAccess::open(pck_path, FileAccess::READ); + if (f) { + file_sizes[pck_path.get_file()] = (uint64_t)f->get_len(); + memdelete(f); + f = NULL; + } + _fix_html(html, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects, file_sizes); f = FileAccess::open(p_path, FileAccess::WRITE); if (!f) { EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + p_path); return ERR_FILE_CANT_WRITE; } - f->store_buffer(buf.ptr(), buf.size()); + f->store_buffer(html.ptr(), html.size()); memdelete(f); + html.resize(0); } Ref<Image> splash; diff --git a/platform/javascript/godot_js.h b/platform/javascript/godot_js.h index 5aa8677a54..f86aadd2c2 100644 --- a/platform/javascript/godot_js.h +++ b/platform/javascript/godot_js.h @@ -92,7 +92,7 @@ extern int godot_js_display_gamepad_sample_get(int p_idx, float r_btns[16], int3 extern void godot_js_display_notification_cb(void (*p_callback)(int p_notification), int p_enter, int p_exit, int p_in, int p_out); extern void godot_js_display_paste_cb(void (*p_callback)(const char *p_text)); extern void godot_js_display_drop_files_cb(void (*p_callback)(char **p_filev, int p_filec)); -extern void godot_js_display_setup_canvas(int p_width, int p_height, int p_fullscreen); +extern void godot_js_display_setup_canvas(int p_width, int p_height, int p_fullscreen, int p_hidpi); #ifdef __cplusplus } #endif diff --git a/platform/javascript/http_client.h.inc b/platform/javascript/http_client.h.inc index 2ef1ad5b83..842a93fcba 100644 --- a/platform/javascript/http_client.h.inc +++ b/platform/javascript/http_client.h.inc @@ -30,24 +30,21 @@ // HTTPClient's additional private members in the javascript platform -Error prepare_request(Method p_method, const String &p_url, const Vector<String> &p_headers); +Error make_request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len); +static void _parse_headers(int p_len, const char **p_headers, void *p_ref); -int xhr_id; +int js_id = 0; int read_limit = 4096; -int response_read_offset = 0; Status status = STATUS_DISCONNECTED; String host; int port = -1; bool use_tls = false; -String username; -String password; int polled_response_code = 0; -String polled_response_header; -PackedByteArray polled_response; +Vector<String> response_headers; +Vector<uint8_t> response_buffer; #ifdef DEBUG_ENABLED -bool has_polled = false; uint64_t last_polling_frame = 0; #endif diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp index 1136ea299d..b79c965854 100644 --- a/platform/javascript/http_client_javascript.cpp +++ b/platform/javascript/http_client_javascript.cpp @@ -30,7 +30,38 @@ #include "core/io/http_client.h" -#include "http_request.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "stddef.h" + +typedef enum { + GODOT_JS_FETCH_STATE_REQUESTING = 0, + GODOT_JS_FETCH_STATE_BODY = 1, + GODOT_JS_FETCH_STATE_DONE = 2, + GODOT_JS_FETCH_STATE_ERROR = -1, +} godot_js_fetch_state_t; + +extern int godot_js_fetch_create(const char *p_method, const char *p_url, const char **p_headers, int p_headers_len, const uint8_t *p_body, int p_body_len); +extern int godot_js_fetch_read_headers(int p_id, void (*parse_callback)(int p_size, const char **p_headers, void *p_ref), void *p_ref); +extern int godot_js_fetch_read_chunk(int p_id, uint8_t *p_buf, int p_buf_size); +extern void godot_js_fetch_free(int p_id); +extern godot_js_fetch_state_t godot_js_fetch_state_get(int p_id); +extern int godot_js_fetch_body_length_get(int p_id); +extern int godot_js_fetch_http_status_get(int p_id); +extern int godot_js_fetch_is_chunked(int p_id); + +#ifdef __cplusplus +} +#endif + +void HTTPClient::_parse_headers(int p_len, const char **p_headers, void *p_ref) { + HTTPClient *client = static_cast<HTTPClient *>(p_ref); + for (int i = 0; i < p_len; i++) { + client->response_headers.push_back(String::utf8(p_headers[i])); + } +} Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) { close(); @@ -74,7 +105,7 @@ Ref<StreamPeer> HTTPClient::get_connection() const { ERR_FAIL_V_MSG(REF(), "Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform."); } -Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Vector<String> &p_headers) { +Error HTTPClient::make_request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len) { ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(p_method == METHOD_TRACE || p_method == METHOD_CONNECT, ERR_UNAVAILABLE, "HTTP methods TRACE and CONNECT are not supported for the HTML5 platform."); ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER); @@ -83,46 +114,33 @@ Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Ve ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER); String url = (use_tls ? "https://" : "http://") + host + ":" + itos(port) + p_url; - godot_xhr_reset(xhr_id); - godot_xhr_open(xhr_id, _methods[p_method], url.utf8().get_data(), - username.is_empty() ? nullptr : username.utf8().get_data(), - password.is_empty() ? nullptr : password.utf8().get_data()); - + Vector<CharString> keeper; + Vector<const char *> c_strings; for (int i = 0; i < p_headers.size(); i++) { - int header_separator = p_headers[i].find(": "); - ERR_FAIL_COND_V(header_separator < 0, ERR_INVALID_PARAMETER); - godot_xhr_set_request_header(xhr_id, - p_headers[i].left(header_separator).utf8().get_data(), - p_headers[i].right(header_separator + 2).utf8().get_data()); + keeper.push_back(p_headers[i].utf8()); + c_strings.push_back(keeper[i].get_data()); + } + if (js_id) { + godot_js_fetch_free(js_id); } - response_read_offset = 0; + js_id = godot_js_fetch_create(_methods[p_method], url.utf8().get_data(), c_strings.ptrw(), c_strings.size(), p_body, p_body_len); status = STATUS_REQUESTING; return OK; } Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) { - Error err = prepare_request(p_method, p_url, p_headers); - if (err != OK) - return err; if (p_body.is_empty()) { - godot_xhr_send(xhr_id, nullptr, 0); - } else { - godot_xhr_send(xhr_id, p_body.ptr(), p_body.size()); + return make_request(p_method, p_url, p_headers, nullptr, 0); } - return OK; + return make_request(p_method, p_url, p_headers, p_body.ptr(), p_body.size()); } Error HTTPClient::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) { - Error err = prepare_request(p_method, p_url, p_headers); - if (err != OK) - return err; if (p_body.is_empty()) { - godot_xhr_send(xhr_id, nullptr, 0); - } else { - const CharString cs = p_body.utf8(); - godot_xhr_send(xhr_id, cs.get_data(), cs.length()); + return make_request(p_method, p_url, p_headers, nullptr, 0); } - return OK; + const CharString cs = p_body.utf8(); + return make_request(p_method, p_url, p_headers, (const uint8_t *)cs.get_data(), cs.size() - 1); } void HTTPClient::close() { @@ -130,10 +148,13 @@ void HTTPClient::close() { port = -1; use_tls = false; status = STATUS_DISCONNECTED; - polled_response.resize(0); polled_response_code = 0; - polled_response_header = String(); - godot_xhr_reset(xhr_id); + response_headers.resize(0); + response_buffer.resize(0); + if (js_id) { + godot_js_fetch_free(js_id); + js_id = 0; + } } HTTPClient::Status HTTPClient::get_status() const { @@ -141,12 +162,11 @@ HTTPClient::Status HTTPClient::get_status() const { } bool HTTPClient::has_response() const { - return !polled_response_header.is_empty(); + return response_headers.size() > 0; } bool HTTPClient::is_response_chunked() const { - // TODO evaluate using moz-chunked-arraybuffer, fetch & ReadableStream - return false; + return godot_js_fetch_is_chunked(js_id); } int HTTPClient::get_response_code() const { @@ -154,36 +174,42 @@ int HTTPClient::get_response_code() const { } Error HTTPClient::get_response_headers(List<String> *r_response) { - if (polled_response_header.is_empty()) + if (!response_headers.size()) { return ERR_INVALID_PARAMETER; - - Vector<String> header_lines = polled_response_header.split("\r\n", false); - for (int i = 0; i < header_lines.size(); ++i) { - r_response->push_back(header_lines[i]); } - polled_response_header = String(); + for (int i = 0; i < response_headers.size(); i++) { + r_response->push_back(response_headers[i]); + } + response_headers.clear(); return OK; } int HTTPClient::get_response_body_length() const { - return polled_response.size(); + return godot_js_fetch_body_length_get(js_id); } PackedByteArray HTTPClient::read_response_body_chunk() { ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray()); - int to_read = MIN(read_limit, polled_response.size() - response_read_offset); - PackedByteArray chunk; - chunk.resize(to_read); - memcpy(chunk.ptrw(), polled_response.ptr() + response_read_offset, to_read); - response_read_offset += to_read; - - if (response_read_offset == polled_response.size()) { - status = STATUS_CONNECTED; - polled_response.resize(0); - godot_xhr_reset(xhr_id); + if (response_buffer.size() != read_limit) { + response_buffer.resize(read_limit); + } + int read = godot_js_fetch_read_chunk(js_id, response_buffer.ptrw(), read_limit); + + // Check if the stream is over. + godot_js_fetch_state_t state = godot_js_fetch_state_get(js_id); + if (state == GODOT_JS_FETCH_STATE_DONE) { + status = STATUS_DISCONNECTED; + } else if (state != GODOT_JS_FETCH_STATE_BODY) { + status = STATUS_CONNECTION_ERROR; } + PackedByteArray chunk; + if (!read) { + return chunk; + } + chunk.resize(read); + copymem(chunk.ptrw(), response_buffer.ptr(), read); return chunk; } @@ -217,48 +243,48 @@ Error HTTPClient::poll() { return OK; case STATUS_CONNECTED: - case STATUS_BODY: return OK; + case STATUS_BODY: { + godot_js_fetch_state_t state = godot_js_fetch_state_get(js_id); + if (state == GODOT_JS_FETCH_STATE_DONE) { + status = STATUS_DISCONNECTED; + } else if (state != GODOT_JS_FETCH_STATE_BODY) { + status = STATUS_CONNECTION_ERROR; + return ERR_CONNECTION_ERROR; + } + return OK; + } + case STATUS_CONNECTION_ERROR: return ERR_CONNECTION_ERROR; case STATUS_REQUESTING: { #ifdef DEBUG_ENABLED - if (!has_polled) { - has_polled = true; - } else { - // forcing synchronous requests is not possible on the web - if (last_polling_frame == Engine::get_singleton()->get_process_frames()) { - WARN_PRINT("HTTPClient polled multiple times in one frame, " - "but request cannot progress more than once per " - "frame on the HTML5 platform."); - } + // forcing synchronous requests is not possible on the web + if (last_polling_frame == Engine::get_singleton()->get_process_frames()) { + WARN_PRINT("HTTPClient polled multiple times in one frame, " + "but request cannot progress more than once per " + "frame on the HTML5 platform."); } last_polling_frame = Engine::get_singleton()->get_process_frames(); #endif - polled_response_code = godot_xhr_get_status(xhr_id); - if (godot_xhr_get_ready_state(xhr_id) != XHR_READY_STATE_DONE) { + polled_response_code = godot_js_fetch_http_status_get(js_id); + godot_js_fetch_state_t js_state = godot_js_fetch_state_get(js_id); + if (js_state == GODOT_JS_FETCH_STATE_REQUESTING) { return OK; - } else if (!polled_response_code) { + } else if (js_state == GODOT_JS_FETCH_STATE_ERROR) { + // Fetch is in error state. + status = STATUS_CONNECTION_ERROR; + return ERR_CONNECTION_ERROR; + } + if (godot_js_fetch_read_headers(js_id, &_parse_headers, this)) { + // Failed to parse headers. status = STATUS_CONNECTION_ERROR; return ERR_CONNECTION_ERROR; } - status = STATUS_BODY; - - PackedByteArray bytes; - int len = godot_xhr_get_response_headers_length(xhr_id); - bytes.resize(len + 1); - - godot_xhr_get_response_headers(xhr_id, reinterpret_cast<char *>(bytes.ptrw()), len); - bytes.ptrw()[len] = 0; - - polled_response_header = String::utf8(reinterpret_cast<const char *>(bytes.ptr())); - - polled_response.resize(godot_xhr_get_response_length(xhr_id)); - godot_xhr_get_response(xhr_id, polled_response.ptrw(), polled_response.size()); break; } @@ -269,9 +295,8 @@ Error HTTPClient::poll() { } HTTPClient::HTTPClient() { - xhr_id = godot_xhr_new(); } HTTPClient::~HTTPClient() { - godot_xhr_free(xhr_id); + close(); } diff --git a/platform/javascript/http_request.h b/platform/javascript/http_request.h deleted file mode 100644 index a9d6faade2..0000000000 --- a/platform/javascript/http_request.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************/ -/* http_request.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef HTTP_REQUEST_H -#define HTTP_REQUEST_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "stddef.h" - -typedef enum { - XHR_READY_STATE_UNSENT = 0, - XHR_READY_STATE_OPENED = 1, - XHR_READY_STATE_HEADERS_RECEIVED = 2, - XHR_READY_STATE_LOADING = 3, - XHR_READY_STATE_DONE = 4, -} godot_xhr_ready_state_t; - -extern int godot_xhr_new(); -extern void godot_xhr_reset(int p_xhr_id); -extern void godot_xhr_free(int p_xhr_id); - -extern int godot_xhr_open(int p_xhr_id, const char *p_method, const char *p_url, const char *p_user = nullptr, const char *p_password = nullptr); - -extern void godot_xhr_set_request_header(int p_xhr_id, const char *p_header, const char *p_value); - -extern void godot_xhr_send(int p_xhr_id, const void *p_data, int p_len); -extern void godot_xhr_abort(int p_xhr_id); - -/* this is an HTTPClient::ResponseCode, not ::Status */ -extern int godot_xhr_get_status(int p_xhr_id); -extern godot_xhr_ready_state_t godot_xhr_get_ready_state(int p_xhr_id); - -extern int godot_xhr_get_response_headers_length(int p_xhr_id); -extern void godot_xhr_get_response_headers(int p_xhr_id, char *r_dst, int p_len); - -extern int godot_xhr_get_response_length(int p_xhr_id); -extern void godot_xhr_get_response(int p_xhr_id, void *r_dst, int p_len); - -#ifdef __cplusplus -} -#endif - -#endif /* HTTP_REQUEST_H */ diff --git a/platform/javascript/js/engine/config.js b/platform/javascript/js/engine/config.js index bba20dc360..82ff273ecf 100644 --- a/platform/javascript/js/engine/config.js +++ b/platform/javascript/js/engine/config.js @@ -101,6 +101,11 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- */ gdnativeLibs: [], /** + * @ignore + * @type {Array.<string>} + */ + fileSizes: [], + /** * A callback function for handling Godot's ``OS.execute`` calls. * * This is for example used in the Web Editor template to switch between project manager and editor, and for running the game. @@ -219,6 +224,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy); this.persistentPaths = parse('persistentPaths', this.persistentPaths); this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs); + this.fileSizes = parse('fileSizes', this.fileSizes); this.args = parse('args', this.args); this.onExecute = parse('onExecute', this.onExecute); this.onExit = parse('onExit', this.onExit); @@ -227,10 +233,10 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- /** * @ignore * @param {string} loadPath - * @param {Promise} loadPromise + * @param {Response} response */ - Config.prototype.getModuleConfig = function (loadPath, loadPromise) { - let loader = loadPromise; + Config.prototype.getModuleConfig = function (loadPath, response) { + let r = response; return { 'print': this.onPrint, 'printErr': this.onPrintError, @@ -238,12 +244,17 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- 'noExitRuntime': true, 'dynamicLibraries': [`${loadPath}.side.wasm`], 'instantiateWasm': function (imports, onSuccess) { - loader.then(function (xhr) { - WebAssembly.instantiate(xhr.response, imports).then(function (result) { - onSuccess(result['instance'], result['module']); + function done(result) { + onSuccess(result['instance'], result['module']); + } + if (typeof (WebAssembly.instantiateStreaming) !== 'undefined') { + WebAssembly.instantiateStreaming(Promise.resolve(r), imports).then(done); + } else { + r.arrayBuffer().then(function (buffer) { + WebAssembly.instantiate(buffer, imports).then(done); }); - }); - loader = null; + } + r = null; return {}; }, 'locateFile': function (path) { diff --git a/platform/javascript/js/engine/engine.externs.js b/platform/javascript/js/engine/engine.externs.js index 1a94dd15ec..35a66a93ae 100644 --- a/platform/javascript/js/engine/engine.externs.js +++ b/platform/javascript/js/engine/engine.externs.js @@ -1,3 +1,4 @@ var Godot; var WebAssembly = {}; WebAssembly.instantiate = function(buffer, imports) {}; +WebAssembly.instantiateStreaming = function(response, imports) {}; diff --git a/platform/javascript/js/engine/engine.js b/platform/javascript/js/engine/engine.js index c51955ed3d..19a0552c8c 100644 --- a/platform/javascript/js/engine/engine.js +++ b/platform/javascript/js/engine/engine.js @@ -35,14 +35,15 @@ const Engine = (function () { * Load the engine from the specified base path. * * @param {string} basePath Base path of the engine to load. + * @param {number=} [size=0] The file size if known. * @returns {Promise} A Promise that resolves once the engine is loaded. * * @function Engine.load */ - Engine.load = function (basePath) { + Engine.load = function (basePath, size) { if (loadPromise == null) { loadPath = basePath; - loadPromise = preloader.loadPromise(`${loadPath}.wasm`); + loadPromise = preloader.loadPromise(`${loadPath}.wasm`, size, true); requestAnimationFrame(preloader.animateProgress); } return loadPromise; @@ -96,23 +97,27 @@ const Engine = (function () { initPromise = Promise.reject(new Error('A base path must be provided when calling `init` and the engine is not loaded.')); return initPromise; } - Engine.load(basePath); + Engine.load(basePath, this.config.fileSizes[`${basePath}.wasm`]); } - preloader.setProgressFunc(this.config.onProgress); - let config = this.config.getModuleConfig(loadPath, loadPromise); const me = this; - initPromise = new Promise(function (resolve, reject) { - Godot(config).then(function (module) { - module['initFS'](me.config.persistentPaths).then(function (fs_err) { - me.rtenv = module; - if (me.config.unloadAfterInit) { - Engine.unload(); - } - resolve(); - config = null; + function doInit(promise) { + return promise.then(function (response) { + return Godot(me.config.getModuleConfig(loadPath, response.clone())); + }).then(function (module) { + const paths = me.config.persistentPaths; + return module['initFS'](paths).then(function (err) { + return Promise.resolve(module); }); + }).then(function (module) { + me.rtenv = module; + if (me.config.unloadAfterInit) { + Engine.unload(); + } + return Promise.resolve(); }); - }); + } + preloader.setProgressFunc(this.config.onProgress); + initPromise = doInit(loadPromise); return initPromise; }, @@ -133,7 +138,7 @@ const Engine = (function () { * @returns {Promise} A Promise that resolves once the file is loaded. */ preloadFile: function (file, path) { - return preloader.preload(file, path); + return preloader.preload(file, path, this.config.fileSizes[file]); }, /** diff --git a/platform/javascript/js/engine/preloader.js b/platform/javascript/js/engine/preloader.js index ec34fb93f2..3535fdb361 100644 --- a/platform/javascript/js/engine/preloader.js +++ b/platform/javascript/js/engine/preloader.js @@ -1,54 +1,79 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-unused-vars - const loadXHR = function (resolve, reject, file, tracker, attempts) { - const xhr = new XMLHttpRequest(); + function getTrackedResponse(response, load_status) { + let clen = 0; + let compressed = false; + response.headers.forEach(function (value, header) { + const h = header.toLowerCase().trim(); + // We can't accurately compute compressed stream length. + if (h === 'content-encoding') { + compressed = true; + } else if (h === 'content-length') { + const length = parseInt(value, 10); + if (!Number.isNaN(length) && length > 0) { + clen = length; + } + } + }); + if (!compressed && clen) { + load_status.total = clen; + } + function onloadprogress(reader, controller) { + return reader.read().then(function (result) { + if (load_status.done) { + return Promise.resolve(); + } + if (result.value) { + controller.enqueue(result.value); + load_status.loaded += result.value.length; + } + if (!result.done) { + return onloadprogress(reader, controller); + } + load_status.done = true; + return Promise.resolve(); + }); + } + const reader = response.body.getReader(); + return new Response(new ReadableStream({ + start: function (controller) { + onloadprogress(reader, controller).then(function () { + controller.close(); + }); + }, + }), { headers: response.headers }); + } + + function loadFetch(file, tracker, fileSize, raw) { tracker[file] = { - total: 0, + total: fileSize || 0, loaded: 0, - final: false, + done: false, }; - xhr.onerror = function () { + return fetch(file).then(function (response) { + if (!response.ok) { + return Promise.reject(new Error(`Failed loading file '${file}'`)); + } + const tr = getTrackedResponse(response, tracker[file]); + if (raw) { + return Promise.resolve(tr); + } + return tr.arrayBuffer(); + }); + } + + function retry(func, attempts = 1) { + function onerror(err) { if (attempts <= 1) { - reject(new Error(`Failed loading file '${file}'`)); - } else { + return Promise.reject(err); + } + return new Promise(function (resolve, reject) { setTimeout(function () { - loadXHR(resolve, reject, file, tracker, attempts - 1); + retry(func, attempts - 1).then(resolve).catch(reject); }, 1000); - } - }; - xhr.onabort = function () { - tracker[file].final = true; - reject(new Error(`Loading file '${file}' was aborted.`)); - }; - xhr.onloadstart = function (ev) { - tracker[file].total = ev.total; - tracker[file].loaded = ev.loaded; - }; - xhr.onprogress = function (ev) { - tracker[file].loaded = ev.loaded; - tracker[file].total = ev.total; - }; - xhr.onload = function () { - if (xhr.status >= 400) { - if (xhr.status < 500 || attempts <= 1) { - reject(new Error(`Failed loading file '${file}': ${xhr.statusText}`)); - xhr.abort(); - } else { - setTimeout(function () { - loadXHR(resolve, reject, file, tracker, attempts - 1); - }, 1000); - } - } else { - tracker[file].final = true; - resolve(xhr); - } - }; - // Make request. - xhr.open('GET', file); - if (!file.endsWith('.js')) { - xhr.responseType = 'arraybuffer'; + }); } - xhr.send(); - }; + return func().catch(onerror); + } const DOWNLOAD_ATTEMPTS_MAX = 4; const loadingFiles = {}; @@ -63,7 +88,7 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-un Object.keys(loadingFiles).forEach(function (file) { const stat = loadingFiles[file]; - if (!stat.final) { + if (!stat.done) { progressIsFinal = false; } if (!totalIsValid || stat.total === 0) { @@ -92,21 +117,19 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-un progressFunc = callback; }; - this.loadPromise = function (file) { - return new Promise(function (resolve, reject) { - loadXHR(resolve, reject, file, loadingFiles, DOWNLOAD_ATTEMPTS_MAX); - }); + this.loadPromise = function (file, fileSize, raw = false) { + return retry(loadFetch.bind(null, file, loadingFiles, fileSize, raw), DOWNLOAD_ATTEMPTS_MAX); }; this.preloadedFiles = []; - this.preload = function (pathOrBuffer, destPath) { + this.preload = function (pathOrBuffer, destPath, fileSize) { let buffer = null; if (typeof pathOrBuffer === 'string') { const me = this; - return this.loadPromise(pathOrBuffer).then(function (xhr) { + return this.loadPromise(pathOrBuffer, fileSize).then(function (buf) { me.preloadedFiles.push({ path: destPath || pathOrBuffer, - buffer: xhr.response, + buffer: buf, }); return Promise.resolve(); }); diff --git a/platform/javascript/js/libs/library_godot_audio.js b/platform/javascript/js/libs/library_godot_audio.js index 8e385e9176..ac4055516c 100644 --- a/platform/javascript/js/libs/library_godot_audio.js +++ b/platform/javascript/js/libs/library_godot_audio.js @@ -238,6 +238,9 @@ const GodotAudioWorklet = { close: function () { return new Promise(function (resolve, reject) { + if (GodotAudioWorklet.promise === null) { + return; + } GodotAudioWorklet.promise.then(function () { GodotAudioWorklet.worklet.port.postMessage({ 'cmd': 'stop', @@ -247,7 +250,7 @@ const GodotAudioWorklet = { GodotAudioWorklet.worklet = null; GodotAudioWorklet.promise = null; resolve(); - }); + }).catch(function (err) { /* aborted? */ }); }); }, }, diff --git a/platform/javascript/js/libs/library_godot_display.js b/platform/javascript/js/libs/library_godot_display.js index fdb5cc0ec2..519a50f2db 100644 --- a/platform/javascript/js/libs/library_godot_display.js +++ b/platform/javascript/js/libs/library_godot_display.js @@ -400,6 +400,10 @@ const GodotDisplayScreen = { $GodotDisplayScreen__deps: ['$GodotConfig', '$GodotOS', '$GL', 'emscripten_webgl_get_current_context'], $GodotDisplayScreen: { desired_size: [0, 0], + hidpi: true, + getPixelRatio: function () { + return GodotDisplayScreen.hidpi ? window.devicePixelRatio || 1 : 1; + }, isFullscreen: function () { const elem = document.fullscreenElement || document.mozFullscreenElement || document.webkitFullscreenElement || document.msFullscreenElement; @@ -477,7 +481,7 @@ const GodotDisplayScreen = { } return 0; } - const scale = window.devicePixelRatio || 1; + const scale = GodotDisplayScreen.getPixelRatio(); if (isFullscreen || wantsFullWindow) { // We need to match screen size. width = window.innerWidth * scale; @@ -555,7 +559,7 @@ const GodotDisplay = { godot_js_display_pixel_ratio_get__sig: 'f', godot_js_display_pixel_ratio_get: function () { - return window.devicePixelRatio || 1; + return GodotDisplayScreen.getPixelRatio(); }, godot_js_display_fullscreen_request__sig: 'i', @@ -581,7 +585,7 @@ const GodotDisplay = { godot_js_display_screen_size_get__sig: 'vii', godot_js_display_screen_size_get: function (width, height) { - const scale = window.devicePixelRatio || 1; + const scale = GodotDisplayScreen.getPixelRatio(); GodotRuntime.setHeapValue(width, window.screen.width * scale, 'i32'); GodotRuntime.setHeapValue(height, window.screen.height * scale, 'i32'); }, @@ -671,7 +675,7 @@ const GodotDisplay = { document.head.appendChild(link); } const old_icon = GodotDisplay.window_icon; - const png = new Blob([GodotRuntime.heapCopy(HEAPU8, p_ptr, p_len)], { type: 'image/png' }); + const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' }); GodotDisplay.window_icon = URL.createObjectURL(png); link.href = GodotDisplay.window_icon; if (old_icon) { @@ -711,7 +715,7 @@ const GodotDisplay = { const shape = GodotRuntime.parseString(p_shape); const old_shape = GodotDisplayCursor.cursors[shape]; if (p_len > 0) { - const png = new Blob([GodotRuntime.heapCopy(HEAPU8, p_ptr, p_len)], { type: 'image/png' }); + const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' }); const url = URL.createObjectURL(png); GodotDisplayCursor.cursors[shape] = { url: url, @@ -776,8 +780,8 @@ const GodotDisplay = { GodotDisplayListeners.add(canvas, 'drop', GodotDisplayDragDrop.handler(dropFiles)); }, - godot_js_display_setup_canvas__sig: 'viii', - godot_js_display_setup_canvas: function (p_width, p_height, p_fullscreen) { + godot_js_display_setup_canvas__sig: 'viiii', + godot_js_display_setup_canvas: function (p_width, p_height, p_fullscreen, p_hidpi) { const canvas = GodotConfig.canvas; GodotDisplayListeners.add(canvas, 'contextmenu', function (ev) { ev.preventDefault(); @@ -786,6 +790,7 @@ const GodotDisplay = { alert('WebGL context lost, please reload the page'); // eslint-disable-line no-alert ev.preventDefault(); }, false); + GodotDisplayScreen.hidpi = !!p_hidpi; switch (GodotConfig.canvas_resize_policy) { case 0: // None GodotDisplayScreen.desired_size = [canvas.width, canvas.height]; @@ -800,6 +805,7 @@ const GodotDisplay = { canvas.style.left = 0; break; } + GodotDisplayScreen.updateSize(); if (p_fullscreen) { GodotDisplayScreen.requestFullscreen(); } diff --git a/platform/javascript/js/libs/library_godot_fetch.js b/platform/javascript/js/libs/library_godot_fetch.js new file mode 100644 index 0000000000..4ae6a23593 --- /dev/null +++ b/platform/javascript/js/libs/library_godot_fetch.js @@ -0,0 +1,258 @@ +/*************************************************************************/ +/* library_godot_fetch.js */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +const GodotFetch = { + $GodotFetch__deps: ['$GodotRuntime'], + $GodotFetch: { + + onread: function (id, result) { + const obj = IDHandler.get(id); + if (!obj) { + return; + } + if (result.value) { + obj.chunks.push(result.value); + } + obj.reading = false; + obj.done = result.done; + }, + + onresponse: function (id, response) { + const obj = IDHandler.get(id); + if (!obj) { + return; + } + let size = -1; + let compressed = false; + let chunked = false; + response.headers.forEach(function (value, header) { + const v = value.toLowerCase().trim(); + const h = header.toLowerCase().trim(); + if (h === 'content-encoding') { + compressed = true; + size = -1; + } else if (h === 'content-length') { + const len = Number.parseInt(value, 10); + if (!Number.isNaN(len) && !compressed) { + size = len; + } + } else if (h === 'transfer-encoding' && v === 'chunked') { + chunked = true; + } + }); + obj.bodySize = size; + obj.status = response.status; + obj.response = response; + obj.reader = response.body.getReader(); + obj.chunked = chunked; + }, + + onerror: function (id, err) { + GodotRuntime.error(err); + const obj = IDHandler.get(id); + if (!obj) { + return; + } + obj.error = err; + }, + + create: function (method, url, headers, body) { + const obj = { + request: null, + response: null, + reader: null, + error: null, + done: false, + reading: false, + status: 0, + chunks: [], + bodySize: -1, + }; + const id = IDHandler.add(obj); + const init = { + method: method, + headers: headers, + body: body, + }; + obj.request = fetch(url, init); + obj.request.then(GodotFetch.onresponse.bind(null, id)).catch(GodotFetch.onerror.bind(null, id)); + return id; + }, + + free: function (id) { + const obj = IDHandler.get(id); + if (!obj) { + return; + } + IDHandler.remove(id); + if (!obj.request) { + return; + } + // Try to abort + obj.request.then(function (response) { + response.abort(); + }).catch(function (e) { /* nothing to do */ }); + }, + + read: function (id) { + const obj = IDHandler.get(id); + if (!obj) { + return; + } + if (obj.reader && !obj.reading) { + if (obj.done) { + obj.reader = null; + return; + } + obj.reading = true; + obj.reader.read().then(GodotFetch.onread.bind(null, id)).catch(GodotFetch.onerror.bind(null, id)); + } + }, + }, + + godot_js_fetch_create__sig: 'iii', + godot_js_fetch_create: function (p_method, p_url, p_headers, p_headers_size, p_body, p_body_size) { + const method = GodotRuntime.parseString(p_method); + const url = GodotRuntime.parseString(p_url); + const headers = GodotRuntime.parseStringArray(p_headers, p_headers_size); + const body = p_body_size ? GodotRuntime.heapSlice(HEAP8, p_body, p_body_size) : null; + return GodotFetch.create(method, url, headers.map(function (hv) { + const idx = hv.indexOf(':'); + if (idx <= 0) { + return []; + } + return [ + hv.slice(0, idx).trim(), + hv.slice(idx + 1).trim(), + ]; + }).filter(function (v) { + return v.length === 2; + }), body); + }, + + godot_js_fetch_state_get__sig: 'ii', + godot_js_fetch_state_get: function (p_id) { + const obj = IDHandler.get(p_id); + if (!obj) { + return -1; + } + if (obj.error) { + return -1; + } + if (!obj.response) { + return 0; + } + if (obj.reader) { + return 1; + } + if (obj.done) { + return 2; + } + return -1; + }, + + godot_js_fetch_http_status_get__sig: 'ii', + godot_js_fetch_http_status_get: function (p_id) { + const obj = IDHandler.get(p_id); + if (!obj || !obj.response) { + return 0; + } + return obj.status; + }, + + godot_js_fetch_read_headers__sig: 'iii', + godot_js_fetch_read_headers: function (p_id, p_parse_cb, p_ref) { + const obj = IDHandler.get(p_id); + if (!obj || !obj.response) { + return 1; + } + const cb = GodotRuntime.get_func(p_parse_cb); + const arr = []; + obj.response.headers.forEach(function (v, h) { + arr.push(`${h}:${v}`); + }); + const c_ptr = GodotRuntime.allocStringArray(arr); + cb(arr.length, c_ptr, p_ref); + GodotRuntime.freeStringArray(c_ptr, arr.length); + return 0; + }, + + godot_js_fetch_read_chunk__sig: 'ii', + godot_js_fetch_read_chunk: function (p_id, p_buf, p_buf_size) { + const obj = IDHandler.get(p_id); + if (!obj || !obj.response) { + return 0; + } + let to_read = p_buf_size; + const chunks = obj.chunks; + while (to_read && chunks.length) { + const chunk = obj.chunks[0]; + if (chunk.length > to_read) { + GodotRuntime.heapCopy(HEAP8, chunk.slice(0, to_read), p_buf); + chunks[0] = chunk.slice(to_read); + to_read = 0; + } else { + GodotRuntime.heapCopy(HEAP8, chunk, p_buf); + to_read -= chunk.length; + chunks.pop(); + } + } + if (!chunks.length) { + GodotFetch.read(p_id); + } + return p_buf_size - to_read; + }, + + godot_js_fetch_body_length_get__sig: 'ii', + godot_js_fetch_body_length_get: function (p_id) { + const obj = IDHandler.get(p_id); + if (!obj || !obj.response) { + return -1; + } + return obj.bodySize; + }, + + godot_js_fetch_is_chunked__sig: 'ii', + godot_js_fetch_is_chunked: function (p_id) { + const obj = IDHandler.get(p_id); + if (!obj || !obj.response) { + return -1; + } + return obj.chunked ? 1 : 0; + }, + + godot_js_fetch_free__sig: 'vi', + godot_js_fetch_free: function (id) { + GodotFetch.free(id); + }, +}; + +autoAddDeps(GodotFetch, '$GodotFetch'); +mergeInto(LibraryManager.library, GodotFetch); diff --git a/platform/javascript/js/libs/library_godot_http_request.js b/platform/javascript/js/libs/library_godot_http_request.js deleted file mode 100644 index 7dc2a2df29..0000000000 --- a/platform/javascript/js/libs/library_godot_http_request.js +++ /dev/null @@ -1,142 +0,0 @@ -/*************************************************************************/ -/* http_request.js */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -const GodotHTTPRequest = { - $GodotHTTPRequest__deps: ['$GodotRuntime'], - $GodotHTTPRequest: { - requests: [], - - getUnusedRequestId: function () { - const idMax = GodotHTTPRequest.requests.length; - for (let potentialId = 0; potentialId < idMax; ++potentialId) { - if (GodotHTTPRequest.requests[potentialId] instanceof XMLHttpRequest) { - continue; - } - return potentialId; - } - GodotHTTPRequest.requests.push(null); - return idMax; - }, - - setupRequest: function (xhr) { - xhr.responseType = 'arraybuffer'; - }, - }, - - godot_xhr_new__sig: 'i', - godot_xhr_new: function () { - const newId = GodotHTTPRequest.getUnusedRequestId(); - GodotHTTPRequest.requests[newId] = new XMLHttpRequest(); - GodotHTTPRequest.setupRequest(GodotHTTPRequest.requests[newId]); - return newId; - }, - - godot_xhr_reset__sig: 'vi', - godot_xhr_reset: function (xhrId) { - GodotHTTPRequest.requests[xhrId] = new XMLHttpRequest(); - GodotHTTPRequest.setupRequest(GodotHTTPRequest.requests[xhrId]); - }, - - godot_xhr_free__sig: 'vi', - godot_xhr_free: function (xhrId) { - GodotHTTPRequest.requests[xhrId].abort(); - GodotHTTPRequest.requests[xhrId] = null; - }, - - godot_xhr_open__sig: 'viiiii', - godot_xhr_open: function (xhrId, method, url, p_user, p_password) { - const user = p_user > 0 ? GodotRuntime.parseString(p_user) : null; - const password = p_password > 0 ? GodotRuntime.parseString(p_password) : null; - GodotHTTPRequest.requests[xhrId].open(GodotRuntime.parseString(method), GodotRuntime.parseString(url), true, user, password); - }, - - godot_xhr_set_request_header__sig: 'viii', - godot_xhr_set_request_header: function (xhrId, header, value) { - GodotHTTPRequest.requests[xhrId].setRequestHeader(GodotRuntime.parseString(header), GodotRuntime.parseString(value)); - }, - - godot_xhr_send__sig: 'viii', - godot_xhr_send: function (xhrId, p_ptr, p_len) { - let data = null; - if (p_ptr && p_len) { - data = GodotRuntime.heapCopy(HEAP8, p_ptr, p_len); - } - GodotHTTPRequest.requests[xhrId].send(data); - }, - - godot_xhr_abort__sig: 'vi', - godot_xhr_abort: function (xhrId) { - GodotHTTPRequest.requests[xhrId].abort(); - }, - - godot_xhr_get_status__sig: 'ii', - godot_xhr_get_status: function (xhrId) { - return GodotHTTPRequest.requests[xhrId].status; - }, - - godot_xhr_get_ready_state__sig: 'ii', - godot_xhr_get_ready_state: function (xhrId) { - return GodotHTTPRequest.requests[xhrId].readyState; - }, - - godot_xhr_get_response_headers_length__sig: 'ii', - godot_xhr_get_response_headers_length: function (xhrId) { - const headers = GodotHTTPRequest.requests[xhrId].getAllResponseHeaders(); - return headers === null ? 0 : GodotRuntime.strlen(headers); - }, - - godot_xhr_get_response_headers__sig: 'viii', - godot_xhr_get_response_headers: function (xhrId, dst, len) { - const str = GodotHTTPRequest.requests[xhrId].getAllResponseHeaders(); - if (str === null) { - return; - } - GodotRuntime.stringToHeap(str, dst, len); - }, - - godot_xhr_get_response_length__sig: 'ii', - godot_xhr_get_response_length: function (xhrId) { - const body = GodotHTTPRequest.requests[xhrId].response; - return body === null ? 0 : body.byteLength; - }, - - godot_xhr_get_response__sig: 'viii', - godot_xhr_get_response: function (xhrId, dst, len) { - let buf = GodotHTTPRequest.requests[xhrId].response; - if (buf === null) { - return; - } - buf = new Uint8Array(buf).subarray(0, len); - HEAPU8.set(buf, dst); - }, -}; - -autoAddDeps(GodotHTTPRequest, '$GodotHTTPRequest'); -mergeInto(LibraryManager.library, GodotHTTPRequest); diff --git a/platform/javascript/js/libs/library_godot_runtime.js b/platform/javascript/js/libs/library_godot_runtime.js index 7e36ff8ab5..3da1ed8f06 100644 --- a/platform/javascript/js/libs/library_godot_runtime.js +++ b/platform/javascript/js/libs/library_godot_runtime.js @@ -72,11 +72,16 @@ const GodotRuntime = { return p_heap.subarray(p_ptr / bytes, p_ptr / bytes + p_len); }, - heapCopy: function (p_heap, p_ptr, p_len) { + heapSlice: function (p_heap, p_ptr, p_len) { const bytes = p_heap.BYTES_PER_ELEMENT; return p_heap.slice(p_ptr / bytes, p_ptr / bytes + p_len); }, + heapCopy: function (p_dst, p_src, p_ptr) { + const bytes = p_src.BYTES_PER_ELEMENT; + return p_dst.set(p_src, p_ptr / bytes); + }, + /* * Strings */ @@ -84,6 +89,15 @@ const GodotRuntime = { return UTF8ToString(p_ptr); // eslint-disable-line no-undef }, + parseStringArray: function (p_ptr, p_size) { + const strings = []; + const ptrs = GodotRuntime.heapSub(HEAP32, p_ptr, p_size); // TODO wasm64 + ptrs.forEach(function (ptr) { + strings.push(GodotRuntime.parseString(ptr)); + }); + return strings; + }, + strlen: function (p_str) { return lengthBytesUTF8(p_str); // eslint-disable-line no-undef }, diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 8f1afe0e66..09d185ae2b 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -70,6 +70,7 @@ def get_opts(): BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), + BoolVariable("use_msan", "Use LLVM/GCC compiler memory sanitizer (MSAN))", False), BoolVariable("pulseaudio", "Detect and use PulseAudio", True), BoolVariable("udev", "Use udev for gamepad connection callbacks", True), BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True), @@ -142,7 +143,7 @@ def configure(env): env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) - if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]: env.extra_suffix += "s" if env["use_ubsan"]: @@ -161,6 +162,10 @@ def configure(env): env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) + if env["use_msan"]: + env.Append(CCFLAGS=["-fsanitize=memory"]) + env.Append(LINKFLAGS=["-fsanitize=memory"]) + if env["use_lto"]: if not env["use_llvm"] and env.GetOption("num_jobs") > 1: env.Append(CCFLAGS=["-flto"]) diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index fceeb82325..3bc859e17d 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -727,9 +727,9 @@ Point2i DisplayServerX11::screen_get_position(int p_screen) const { int count; XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); - if (p_screen >= count) { - return Point2i(0, 0); - } + + // Check if screen is valid + ERR_FAIL_INDEX_V(p_screen, count, Point2i(0, 0)); Point2i position = Point2i(xsi[p_screen].x_org, xsi[p_screen].y_org); @@ -758,9 +758,9 @@ Rect2i DisplayServerX11::screen_get_usable_rect(int p_screen) const { int count; XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); - if (p_screen >= count) { - return Rect2i(0, 0, 0, 0); - } + + // Check if screen is valid + ERR_FAIL_INDEX_V(p_screen, count, Rect2i(0, 0, 0, 0)); Rect2i rect = Rect2i(xsi[p_screen].x_org, xsi[p_screen].y_org, xsi[p_screen].width, xsi[p_screen].height); XFree(xsi); @@ -1041,11 +1041,13 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; - int count = get_screen_count(); - if (p_screen >= count) { - return; + if (p_screen == SCREEN_OF_MAIN_WINDOW) { + p_screen = window_get_current_screen(); } + // Check if screen is valid + ERR_FAIL_INDEX(p_screen, get_screen_count()); + if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN) { Point2i position = screen_get_position(p_screen); Size2i size = screen_get_size(p_screen); @@ -4028,7 +4030,10 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode use_prime = 0; } - if (getenv("LD_LIBRARY_PATH")) { + // Some tools use fake libGL libraries and have them override the real one using + // LD_LIBRARY_PATH, so we skip them. *But* Steam also sets LD_LIBRARY_PATH for its + // runtime and includes system `/lib` and `/lib64`... so ignore Steam. + if (use_prime == -1 && getenv("LD_LIBRARY_PATH") && !getenv("STEAM_RUNTIME_LIBRARY_PATH")) { String ld_library_path(getenv("LD_LIBRARY_PATH")); Vector<String> libraries = ld_library_path.split(":"); diff --git a/platform/osx/detect.py b/platform/osx/detect.py index acea00c5ac..c39a4426be 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -35,6 +35,7 @@ def get_opts(): BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), + BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), ] @@ -131,7 +132,7 @@ def configure(env): env["AS"] = basecmd + "as" env.Append(CPPDEFINES=["__MACPORTS__"]) # hack to fix libvpx MM256_BROADCASTSI128_SI256 define - if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: env.extra_suffix += "s" if env["use_ubsan"]: @@ -142,6 +143,10 @@ def configure(env): env.Append(CCFLAGS=["-fsanitize=address"]) env.Append(LINKFLAGS=["-fsanitize=address"]) + if env["use_lsan"]: + env.Append(CCFLAGS=["-fsanitize=leak"]) + env.Append(LINKFLAGS=["-fsanitize=leak"]) + if env["use_tsan"]: env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 337cfd6808..f31d8b9b81 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -56,7 +56,7 @@ class EditorExportPlatformOSX : public EditorExportPlatform { void _make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data); Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path); - Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path); + Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path); Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name); void _zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name); @@ -114,7 +114,7 @@ public: virtual void get_platform_features(List<String> *r_features) override { r_features->push_back("pc"); r_features->push_back("s3tc"); - r_features->push_back("OSX"); + r_features->push_back("macOS"); } virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) override { @@ -159,7 +159,30 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_PLACEHOLDER_TEXT, "Type: Name (ID)"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/timestamp"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/hardened_runtime"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements", PROPERTY_HINT_GLOBAL_FILE, "*.plist"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements/custom_file", PROPERTY_HINT_GLOBAL_FILE, "*.plist"), "")); + + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_jit_code_execution"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_unsigned_executable_memory"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_dyld_environment_variables"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/disable_library_validation"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/audio_input"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/camera"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/location"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/address_book"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/calendars"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/photos_library"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/apple_events"), false)); + + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/enabled"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_server"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_client"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/device_usb"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/device_bluetooth"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_downloads", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_pictures", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_music", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_movies", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0)); + r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray())); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "notarization/enable"), false)); @@ -437,7 +460,7 @@ Error EditorExportPlatformOSX::_notarize(const Ref<EditorExportPreset> &p_preset return OK; } -Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path) { +Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path, const String &p_ent_path) { #ifdef OSX_ENABLED List<String> args; @@ -449,9 +472,9 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese args.push_back("runtime"); } - if ((p_preset->get("codesign/entitlements") != "") && (p_path.get_extension() != "dmg")) { + if (p_path.get_extension() != "dmg") { args.push_back("--entitlements"); - args.push_back(p_preset->get("codesign/entitlements")); + args.push_back(p_ent_path); } PackedStringArray user_args = p_preset->get("codesign/custom_options"); @@ -607,6 +630,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p // Now process our template. bool found_binary = false; int total_size = 0; + Vector<String> dylibs_found; while (ret == UNZ_OK && err == OK) { bool is_execute = false; @@ -678,14 +702,18 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p ret = unzGoToNextFile(src_pkg_zip); continue; // skip } - file = file.replace("/data.mono.osx.64.release_debug/", "/data_" + pkg_name + "/"); + file = file.replace("/data.mono.osx.64.release_debug/", "/GodotSharp/"); } if (file.find("/data.mono.osx.64.release/") != -1) { if (p_debug) { ret = unzGoToNextFile(src_pkg_zip); continue; // skip } - file = file.replace("/data.mono.osx.64.release/", "/data_" + pkg_name + "/"); + file = file.replace("/data.mono.osx.64.release/", "/GodotSharp/"); + } + + if (file.ends_with(".dylib")) { + dylibs_found.push_back(file); } print_line("ADDING: " + file + " size: " + itos(data.size())); @@ -735,22 +763,149 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p // See if we can code sign our new package. bool sign_enabled = p_preset->get("codesign/enable"); + String ent_path = p_preset->get("codesign/entitlements/custom_file"); + if (sign_enabled && (ent_path == "")) { + ent_path = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".entitlements"); + + FileAccess *ent_f = FileAccess::open(ent_path, FileAccess::WRITE); + if (ent_f) { + ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); + ent_f->store_line("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"); + ent_f->store_line("<plist version=\"1.0\">"); + ent_f->store_line("<dict>"); + if ((bool)p_preset->get("codesign/entitlements/allow_jit_code_execution")) { + ent_f->store_line("<key>com.apple.security.cs.allow-jit</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/allow_unsigned_executable_memory")) { + ent_f->store_line("<key>com.apple.security.cs.allow-unsigned-executable-memory</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/allow_dyld_environment_variables")) { + ent_f->store_line("<key>com.apple.security.cs.allow-dyld-environment-variables</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/disable_library_validation")) { + ent_f->store_line("<key>com.apple.security.cs.disable-library-validation</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/audio_input")) { + ent_f->store_line("<key>com.apple.security.device.audio-input</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/camera")) { + ent_f->store_line("<key>com.apple.security.device.camera</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/location")) { + ent_f->store_line("<key>com.apple.security.personal-information.location</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/address_book")) { + ent_f->store_line("<key>com.apple.security.personal-information.addressbook</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/calendars")) { + ent_f->store_line("<key>com.apple.security.personal-information.calendars</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/photos_library")) { + ent_f->store_line("<key>com.apple.security.personal-information.photos-library</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/apple_events")) { + ent_f->store_line("<key>com.apple.security.automation.apple-events</key>"); + ent_f->store_line("<true/>"); + } + + if ((bool)p_preset->get("codesign/entitlements/app_sandbox/enabled")) { + ent_f->store_line("<key>com.apple.security.app-sandbox</key>"); + ent_f->store_line("<true/>"); + + if ((bool)p_preset->get("codesign/entitlements/app_sandbox/network_server")) { + ent_f->store_line("<key>com.apple.security.network.server</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/app_sandbox/network_client")) { + ent_f->store_line("<key>com.apple.security.network.client</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/app_sandbox/device_usb")) { + ent_f->store_line("<key>com.apple.security.device.usb</key>"); + ent_f->store_line("<true/>"); + } + if ((bool)p_preset->get("codesign/entitlements/app_sandbox/device_bluetooth")) { + ent_f->store_line("<key>com.apple.security.device.bluetooth</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_downloads") == 1) { + ent_f->store_line("<key>com.apple.security.files.downloads.read-only</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_downloads") == 2) { + ent_f->store_line("<key>com.apple.security.files.downloads.read-write</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_pictures") == 1) { + ent_f->store_line("<key>com.apple.security.files.pictures.read-only</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_pictures") == 2) { + ent_f->store_line("<key>com.apple.security.files.pictures.read-write</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_music") == 1) { + ent_f->store_line("<key>com.apple.security.files.music.read-only</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_music") == 2) { + ent_f->store_line("<key>com.apple.security.files.music.read-write</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_movies") == 1) { + ent_f->store_line("<key>com.apple.security.files.movies.read-only</key>"); + ent_f->store_line("<true/>"); + } + if ((int)p_preset->get("codesign/entitlements/app_sandbox/files_movies") == 2) { + ent_f->store_line("<key>com.apple.security.files.movies.read-write</key>"); + ent_f->store_line("<true/>"); + } + } + + ent_f->store_line("</dict>"); + ent_f->store_line("</plist>"); + + ent_f->close(); + memdelete(ent_f); + } else { + err = ERR_CANT_CREATE; + } + } + if (err == OK) { DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); for (int i = 0; i < shared_objects.size(); i++) { err = da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file()); if (err == OK && sign_enabled) { - err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file()); + err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file(), ent_path); } } memdelete(da); } + if (sign_enabled) { + for (int i = 0; i < dylibs_found.size(); i++) { + if (err == OK) { + err = _code_sign(p_preset, tmp_app_path_name + "/" + dylibs_found[i], ent_path); + } + } + } + if (err == OK && sign_enabled) { if (ep.step("Code signing bundle", 2)) { return ERR_SKIP; } - err = _code_sign(p_preset, tmp_app_path_name + "/Contents/MacOS/" + pkg_name); + err = _code_sign(p_preset, tmp_app_path_name + "/Contents/MacOS/" + pkg_name, ent_path); } if (export_format == "dmg") { @@ -766,7 +921,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (ep.step("Code signing DMG", 3)) { return ERR_SKIP; } - err = _code_sign(p_preset, p_path); + err = _code_sign(p_preset, p_path, ent_path); } } else { // Create ZIP. diff --git a/platform/server/detect.py b/platform/server/detect.py index 5be7e81e7a..c799ce03e1 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -39,6 +39,7 @@ def get_opts(): BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True), + BoolVariable("use_msan", "Use LLVM/GCC compiler memory sanitizer (MSAN))", False), BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False), ] @@ -99,7 +100,7 @@ def configure(env): env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) - if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]: env.extra_suffix += "s" if env["use_ubsan"]: @@ -118,6 +119,10 @@ def configure(env): env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) + if env["use_msan"]: + env.Append(CCFLAGS=["-fsanitize=memory"]) + env.Append(LINKFLAGS=["-fsanitize=memory"]) + if env["use_lto"]: env.Append(CCFLAGS=["-flto"]) if not env["use_llvm"] and env.GetOption("num_jobs") > 1: diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index b4de12b113..9030cc4263 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -263,6 +263,7 @@ void Camera2D::_notification(int p_what) { viewport = nullptr; } break; +#ifdef TOOLS_ENABLED case NOTIFICATION_DRAW: { if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint()) { break; @@ -339,8 +340,8 @@ void Camera2D::_notification(int p_what) { draw_line(inv_transform.xform(margin_endpoints[i]), inv_transform.xform(margin_endpoints[(i + 1) % 4]), margin_drawing_color, margin_drawing_width); } } - } break; +#endif } } @@ -568,6 +569,7 @@ void Camera2D::_set_old_smoothing(float p_enable) { void Camera2D::set_enable_follow_smoothing(bool p_enabled) { smoothing_enabled = p_enabled; + notify_property_list_changed(); } bool Camera2D::is_follow_smoothing_enabled() const { @@ -610,7 +612,9 @@ Node *Camera2D::get_custom_viewport() const { void Camera2D::set_screen_drawing_enabled(bool enable) { screen_drawing_enabled = enable; +#ifdef TOOLS_ENABLED update(); +#endif } bool Camera2D::is_screen_drawing_enabled() const { @@ -619,7 +623,9 @@ bool Camera2D::is_screen_drawing_enabled() const { void Camera2D::set_limit_drawing_enabled(bool enable) { limit_drawing_enabled = enable; +#ifdef TOOLS_ENABLED update(); +#endif } bool Camera2D::is_limit_drawing_enabled() const { @@ -628,13 +634,21 @@ bool Camera2D::is_limit_drawing_enabled() const { void Camera2D::set_margin_drawing_enabled(bool enable) { margin_drawing_enabled = enable; +#ifdef TOOLS_ENABLED update(); +#endif } bool Camera2D::is_margin_drawing_enabled() const { return margin_drawing_enabled; } +void Camera2D::_validate_property(PropertyInfo &property) const { + if (!smoothing_enabled && property.name == "smoothing_speed") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void Camera2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Camera2D::set_offset); ClassDB::bind_method(D_METHOD("get_offset"), &Camera2D::get_offset); diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 252d2686fc..220e208eb0 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -97,8 +97,10 @@ protected: protected: virtual Transform2D get_camera_transform(); + void _notification(int p_what); static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: void set_offset(const Vector2 &p_offset); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 39d7705226..38198c496e 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -41,13 +41,13 @@ void CollisionPolygon2D::_build_polygon() { parent->shape_owner_clear_shapes(owner_id); - if (polygon.size() == 0) { - return; - } - bool solids = build_mode == BUILD_SOLIDS; if (solids) { + if (polygon.size() < 3) { + return; + } + //here comes the sun, lalalala //decompose concave into multiple convex polygons and add them Vector<Vector<Vector2>> decomp = _decompose_in_convex(); @@ -58,6 +58,10 @@ void CollisionPolygon2D::_build_polygon() { } } else { + if (polygon.size() < 2) { + return; + } + Ref<ConcavePolygonShape2D> concave = memnew(ConcavePolygonShape2D); Vector<Vector2> segments; @@ -132,25 +136,28 @@ void CollisionPolygon2D::_notification(int p_what) { break; } - for (int i = 0; i < polygon.size(); i++) { + int polygon_count = polygon.size(); + for (int i = 0; i < polygon_count; i++) { Vector2 p = polygon[i]; - Vector2 n = polygon[(i + 1) % polygon.size()]; + Vector2 n = polygon[(i + 1) % polygon_count]; // draw line with width <= 1, so it does not scale with zoom and break pixel exact editing draw_line(p, n, Color(0.9, 0.2, 0.0, 0.8), 1); } + + if (polygon_count > 2) { #define DEBUG_DECOMPOSE #if defined(TOOLS_ENABLED) && defined(DEBUG_DECOMPOSE) + Vector<Vector<Vector2>> decomp = _decompose_in_convex(); - Vector<Vector<Vector2>> decomp = _decompose_in_convex(); - - Color c(0.4, 0.9, 0.1); - for (int i = 0; i < decomp.size(); i++) { - c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5); - draw_colored_polygon(decomp[i], c); - } + Color c(0.4, 0.9, 0.1); + for (int i = 0; i < decomp.size(); i++) { + c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5); + draw_colored_polygon(decomp[i], c); + } #else - draw_colored_polygon(polygon, get_tree()->get_debug_collisions_color()); + draw_colored_polygon(polygon, get_tree()->get_debug_collisions_color()); #endif + } if (one_way_collision) { Color dcol = get_tree()->get_debug_collisions_color(); //0.9,0.2,0.2,0.4); @@ -211,6 +218,8 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) { _build_polygon(); _update_in_shape_owner(); } + update(); + update_configuration_warning(); } CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const { @@ -241,11 +250,27 @@ String CollisionPolygon2D::get_configuration_warning() const { warning += TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."); } - if (polygon.is_empty()) { + int polygon_count = polygon.size(); + if (polygon_count == 0) { if (!warning.is_empty()) { warning += "\n\n"; } warning += TTR("An empty CollisionPolygon2D has no effect on collision."); + } else { + bool solids = build_mode == BUILD_SOLIDS; + if (solids) { + if (polygon_count < 3) { + if (!warning.is_empty()) { + warning += "\n\n"; + } + warning += TTR("Invalid polygon. At least 3 points are needed in 'Solids' build mode."); + } + } else if (polygon_count < 2) { + if (!warning.is_empty()) { + warning += "\n\n"; + } + warning += TTR("Invalid polygon. At least 2 points are needed in 'Segments' build mode."); + } } return warning; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 0e51264171..48acee1bc4 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1032,66 +1032,64 @@ void CPUParticles2D::_update_render_thread() { } void CPUParticles2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - set_process_internal(emitting); - } - - if (p_what == NOTIFICATION_EXIT_TREE) { - _set_redraw(false); - } - - if (p_what == NOTIFICATION_DRAW) { - // first update before rendering to avoid one frame delay after emitting starts - if (emitting && (time == 0)) { - _update_internal(); - } - - if (!redraw) { - return; // don't add to render list - } - - RID texrid; - if (texture.is_valid()) { - texrid = texture->get_rid(); - } - - RS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid); - } - - if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - _update_internal(); - } - - if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - inv_emission_transform = get_global_transform().affine_inverse(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + set_process_internal(emitting); + } break; + case NOTIFICATION_EXIT_TREE: { + _set_redraw(false); + } break; + case NOTIFICATION_DRAW: { + // first update before rendering to avoid one frame delay after emitting starts + if (emitting && (time == 0)) { + _update_internal(); + } - if (!local_coords) { - int pc = particles.size(); + if (!redraw) { + return; // don't add to render list + } - float *w = particle_data.ptrw(); - const Particle *r = particles.ptr(); - float *ptr = w; + RID texrid; + if (texture.is_valid()) { + texrid = texture->get_rid(); + } - for (int i = 0; i < pc; i++) { - Transform2D t = inv_emission_transform * r[i].transform; + RS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid); + } break; + case NOTIFICATION_INTERNAL_PROCESS: { + _update_internal(); + } break; + case NOTIFICATION_TRANSFORM_CHANGED: { + inv_emission_transform = get_global_transform().affine_inverse(); - if (r[i].active) { - ptr[0] = t.elements[0][0]; - ptr[1] = t.elements[1][0]; - ptr[2] = 0; - ptr[3] = t.elements[2][0]; - ptr[4] = t.elements[0][1]; - ptr[5] = t.elements[1][1]; - ptr[6] = 0; - ptr[7] = t.elements[2][1]; + if (!local_coords) { + int pc = particles.size(); + + float *w = particle_data.ptrw(); + const Particle *r = particles.ptr(); + float *ptr = w; + + for (int i = 0; i < pc; i++) { + Transform2D t = inv_emission_transform * r[i].transform; + + if (r[i].active) { + ptr[0] = t.elements[0][0]; + ptr[1] = t.elements[1][0]; + ptr[2] = 0; + ptr[3] = t.elements[2][0]; + ptr[4] = t.elements[0][1]; + ptr[5] = t.elements[1][1]; + ptr[6] = 0; + ptr[7] = t.elements[2][1]; + + } else { + zeromem(ptr, sizeof(float) * 8); + } - } else { - zeromem(ptr, sizeof(float) * 8); + ptr += 16; } - - ptr += 16; } - } + } break; } } diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index f4f08674c9..7d9cdd52ac 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -49,19 +49,9 @@ void Joint2D::_disconnect_signals() { } } -void Joint2D::_body_exit_tree(const ObjectID &p_body_id) { +void Joint2D::_body_exit_tree() { _disconnect_signals(); - Object *object = ObjectDB::get_instance(p_body_id); - PhysicsBody2D *body = Object::cast_to<PhysicsBody2D>(object); - ERR_FAIL_NULL(body); - RID body_rid = body->get_rid(); - if (ba == body_rid) { - a = NodePath(); - } - if (bb == body_rid) { - b = NodePath(); - } - _update_joint(); + _update_joint(true); } void Joint2D::_update_joint(bool p_only_free) { @@ -142,8 +132,8 @@ void Joint2D::_update_joint(bool p_only_free) { ba = body_a->get_rid(); bb = body_b->get_rid(); - body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint2D::_body_exit_tree), make_binds(body_a->get_instance_id())); - body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint2D::_body_exit_tree), make_binds(body_b->get_instance_id())); + body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint2D::_body_exit_tree)); + body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint2D::_body_exit_tree)); PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); } diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index 3607a6c176..08e02ee29d 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -51,7 +51,7 @@ class Joint2D : public Node2D { protected: void _disconnect_signals(); - void _body_exit_tree(const ObjectID &p_body_id); + void _body_exit_tree(); void _update_joint(bool p_only_free = false); void _notification(int p_what); diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 15fcb08422..58e15e3cca 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -159,6 +159,7 @@ int Light2D::get_item_shadow_cull_mask() const { void Light2D::set_shadow_enabled(bool p_enabled) { shadow = p_enabled; RS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow); + notify_property_list_changed(); } bool Light2D::is_shadow_enabled() const { @@ -221,6 +222,12 @@ float Light2D::get_shadow_smooth() const { return shadow_smooth; } +void Light2D::_validate_property(PropertyInfo &property) const { + if (!shadow && (property.name == "shadow_color" || property.name == "shadow_filter" || property.name == "shadow_filter_smooth" || property.name == "shadow_item_cull_mask")) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void Light2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &Light2D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &Light2D::is_enabled); diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 4279baf15b..de8a2bb6d0 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -77,6 +77,7 @@ protected: _FORCE_INLINE_ RID _get_light() const { return canvas_light; } void _notification(int p_what); static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: void set_enabled(bool p_enabled); diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp deleted file mode 100644 index bec5ee7984..0000000000 --- a/scene/2d/navigation_2d.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*************************************************************************/ -/* navigation_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "navigation_2d.h" -#include "servers/navigation_server_2d.h" - -void Navigation2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_rid"), &Navigation2D::get_rid); - - ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation2D::get_simple_path, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_closest_point", "to_point"), &Navigation2D::get_closest_point); - ClassDB::bind_method(D_METHOD("get_closest_point_owner", "to_point"), &Navigation2D::get_closest_point_owner); - - ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &Navigation2D::set_cell_size); - ClassDB::bind_method(D_METHOD("get_cell_size"), &Navigation2D::get_cell_size); - - ClassDB::bind_method(D_METHOD("set_edge_connection_margin", "margin"), &Navigation2D::set_edge_connection_margin); - ClassDB::bind_method(D_METHOD("get_edge_connection_margin"), &Navigation2D::get_edge_connection_margin); - - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_size"), "set_cell_size", "get_cell_size"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "edge_connection_margin"), "set_edge_connection_margin", "get_edge_connection_margin"); -} - -void Navigation2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - NavigationServer2D::get_singleton()->map_set_active(map, true); - } break; - case NOTIFICATION_EXIT_TREE: { - NavigationServer2D::get_singleton()->map_set_active(map, false); - } break; - } -} - -void Navigation2D::set_cell_size(float p_cell_size) { - cell_size = p_cell_size; - NavigationServer2D::get_singleton()->map_set_cell_size(map, cell_size); -} - -void Navigation2D::set_edge_connection_margin(float p_edge_connection_margin) { - edge_connection_margin = p_edge_connection_margin; - NavigationServer2D::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin); -} - -Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) const { - return NavigationServer2D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); -} - -Vector2 Navigation2D::get_closest_point(const Vector2 &p_point) const { - return NavigationServer2D::get_singleton()->map_get_closest_point(map, p_point); -} - -RID Navigation2D::get_closest_point_owner(const Vector2 &p_point) const { - return NavigationServer2D::get_singleton()->map_get_closest_point_owner(map, p_point); -} - -Navigation2D::Navigation2D() { - map = NavigationServer2D::get_singleton()->map_create(); - set_cell_size(10); // Ten pixels - set_edge_connection_margin(100); -} - -Navigation2D::~Navigation2D() { - NavigationServer2D::get_singleton()->free(map); -} diff --git a/scene/2d/navigation_2d.h b/scene/2d/navigation_2d.h deleted file mode 100644 index 12847e52ac..0000000000 --- a/scene/2d/navigation_2d.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************/ -/* navigation_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef NAVIGATION_2D_H -#define NAVIGATION_2D_H - -#include "scene/2d/navigation_region_2d.h" -#include "scene/2d/node_2d.h" - -class Navigation2D : public Node2D { - GDCLASS(Navigation2D, Node2D); - - RID map; - real_t cell_size; - real_t edge_connection_margin; - -protected: - static void _bind_methods(); - void _notification(int p_what); - -public: - RID get_rid() const { - return map; - } - - void set_cell_size(float p_cell_size); - float get_cell_size() const { - return cell_size; - } - - void set_edge_connection_margin(float p_edge_connection_margin); - float get_edge_connection_margin() const { - return edge_connection_margin; - } - - Vector<Vector2> get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize = true) const; - Vector2 get_closest_point(const Vector2 &p_point) const; - RID get_closest_point_owner(const Vector2 &p_point) const; - - Navigation2D(); - ~Navigation2D(); -}; - -#endif // NAVIGATION_2D_H diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 534e31b1f2..064fcc91a4 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -32,7 +32,6 @@ #include "core/config/engine.h" #include "core/math/geometry_2d.h" -#include "scene/2d/navigation_2d.h" #include "servers/navigation_server_2d.h" void NavigationAgent2D::_bind_methods() { @@ -42,9 +41,6 @@ void NavigationAgent2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_radius", "radius"), &NavigationAgent2D::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &NavigationAgent2D::get_radius); - ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationAgent2D::set_navigation_node); - ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationAgent2D::get_navigation_node); - ClassDB::bind_method(D_METHOD("set_neighbor_dist", "neighbor_dist"), &NavigationAgent2D::set_neighbor_dist); ClassDB::bind_method(D_METHOD("get_neighbor_dist"), &NavigationAgent2D::get_neighbor_dist); @@ -95,27 +91,10 @@ void NavigationAgent2D::_notification(int p_what) { NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); - // Search the navigation node and set it - { - Navigation2D *nav = nullptr; - Node *p = get_parent(); - while (p != nullptr) { - nav = Object::cast_to<Navigation2D>(p); - if (nav != nullptr) { - p = nullptr; - } else { - p = p->get_parent(); - } - } - - set_navigation(nav); - } - set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { agent_parent = nullptr; - set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -146,23 +125,13 @@ NavigationAgent2D::~NavigationAgent2D() { agent = RID(); // Pointless } -void NavigationAgent2D::set_navigation(Navigation2D *p_nav) { - if (navigation == p_nav) { - return; // Pointless - } - - navigation = p_nav; - NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); -} - -void NavigationAgent2D::set_navigation_node(Node *p_nav) { - Navigation2D *nav = Object::cast_to<Navigation2D>(p_nav); - ERR_FAIL_COND(nav == nullptr); - set_navigation(nav); +void NavigationAgent2D::set_navigable_layers(uint32_t p_layers) { + navigable_layers = p_layers; + update_navigation(); } -Node *NavigationAgent2D::get_navigation_node() const { - return Object::cast_to<Node>(navigation); +uint32_t NavigationAgent2D::get_navigable_layers() const { + return navigable_layers; } void NavigationAgent2D::set_target_desired_distance(real_t p_dd) { @@ -287,7 +256,7 @@ void NavigationAgent2D::update_navigation() { if (agent_parent == nullptr) { return; } - if (navigation == nullptr) { + if (!agent_parent->is_inside_tree()) { return; } if (update_frame_id == Engine::get_singleton()->get_physics_frames()) { @@ -319,7 +288,7 @@ void NavigationAgent2D::update_navigation() { } if (reload_path) { - navigation_path = NavigationServer2D::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true); + navigation_path = NavigationServer2D::get_singleton()->map_get_path(agent_parent->get_world_2d()->get_navigation_map(), o, target_location, true, navigable_layers); navigation_finished = false; nav_path_index = 0; emit_signal("path_changed"); diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h index 6b7da4a5f2..153ede8cec 100644 --- a/scene/2d/navigation_agent_2d.h +++ b/scene/2d/navigation_agent_2d.h @@ -35,16 +35,16 @@ #include "scene/main/node.h" class Node2D; -class Navigation2D; class NavigationAgent2D : public Node { GDCLASS(NavigationAgent2D, Node); Node2D *agent_parent = nullptr; - Navigation2D *navigation = nullptr; RID agent; + uint32_t navigable_layers = 1; + real_t target_desired_distance = 1.0; real_t radius; real_t neighbor_dist; @@ -74,18 +74,13 @@ public: NavigationAgent2D(); virtual ~NavigationAgent2D(); - void set_navigation(Navigation2D *p_nav); - const Navigation2D *get_navigation() const { - return navigation; - } - - void set_navigation_node(Node *p_nav); - Node *get_navigation_node() const; - RID get_rid() const { return agent; } + void set_navigable_layers(uint32_t p_layers); + uint32_t get_navigable_layers() const; + void set_target_desired_distance(real_t p_dd); real_t get_target_desired_distance() const { return target_desired_distance; diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index 7e1aefe5e2..965e2b6dc1 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -31,48 +31,31 @@ #include "navigation_obstacle_2d.h" #include "scene/2d/collision_shape_2d.h" -#include "scene/2d/navigation_2d.h" #include "scene/2d/physics_body_2d.h" #include "servers/navigation_server_2d.h" void NavigationObstacle2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle2D::set_navigation_node); - ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle2D::get_navigation_node); } void NavigationObstacle2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - update_agent_shape(); - - // Search the navigation node and set it - { - Navigation2D *nav = nullptr; - Node *p = get_parent(); - while (p != nullptr) { - nav = Object::cast_to<Navigation2D>(p); - if (nav != nullptr) { - p = nullptr; - } else { - p = p->get_parent(); - } - } - - set_navigation(nav); - } - set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - set_navigation(nullptr); set_physics_process_internal(false); } break; + case NOTIFICATION_PARENTED: { + parent_node2d = Object::cast_to<Node2D>(get_parent()); + update_agent_shape(); + } break; + case NOTIFICATION_UNPARENTED: { + parent_node2d = nullptr; + } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - Node2D *node = Object::cast_to<Node2D>(get_parent()); - if (node) { - NavigationServer2D::get_singleton()->agent_set_position(agent, node->get_global_transform().get_origin()); + if (parent_node2d) { + NavigationServer2D::get_singleton()->agent_set_position(agent, parent_node2d->get_global_transform().get_origin()); } - } break; } } @@ -86,25 +69,6 @@ NavigationObstacle2D::~NavigationObstacle2D() { agent = RID(); // Pointless } -void NavigationObstacle2D::set_navigation(Navigation2D *p_nav) { - if (navigation == p_nav) { - return; // Pointless - } - - navigation = p_nav; - NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); -} - -void NavigationObstacle2D::set_navigation_node(Node *p_nav) { - Navigation2D *nav = Object::cast_to<Navigation2D>(p_nav); - ERR_FAIL_COND(nav == nullptr); - set_navigation(nav); -} - -Node *NavigationObstacle2D::get_navigation_node() const { - return Object::cast_to<Node>(navigation); -} - String NavigationObstacle2D::get_configuration_warning() const { String warning = Node::get_configuration_warning(); @@ -119,40 +83,37 @@ String NavigationObstacle2D::get_configuration_warning() const { } void NavigationObstacle2D::update_agent_shape() { - Node *node = get_parent(); - - // Estimate the radius of this physics body - real_t radius = 0.0; - for (int i(0); i < node->get_child_count(); i++) { - // For each collision shape - CollisionShape2D *cs = Object::cast_to<CollisionShape2D>(node->get_child(i)); - if (cs) { - // Take the distance between the Body center to the shape center - real_t r = cs->get_transform().get_origin().length(); - if (cs->get_shape().is_valid()) { - // and add the enclosing shape radius - r += cs->get_shape()->get_enclosing_radius(); + if (parent_node2d) { + // Estimate the radius of this physics body + real_t radius = 0.0; + for (int i(0); i < parent_node2d->get_child_count(); i++) { + // For each collision shape + CollisionShape2D *cs = Object::cast_to<CollisionShape2D>(parent_node2d->get_child(i)); + if (cs) { + // Take the distance between the Body center to the shape center + real_t r = cs->get_transform().get_origin().length(); + if (cs->get_shape().is_valid()) { + // and add the enclosing shape radius + r += cs->get_shape()->get_enclosing_radius(); + } + Size2 s = cs->get_global_transform().get_scale(); + r *= MAX(s.x, s.y); + // Takes the biggest radius + radius = MAX(radius, r); } - Size2 s = cs->get_global_transform().get_scale(); - r *= MAX(s.x, s.y); - // Takes the biggest radius - radius = MAX(radius, r); } - } - Node2D *node_2d = Object::cast_to<Node2D>(node); - if (node_2d) { - Vector2 s = node_2d->get_global_transform().get_scale(); + Vector2 s = parent_node2d->get_global_transform().get_scale(); radius *= MAX(s.x, s.y); - } - if (radius == 0.0) { - radius = 1.0; // Never a 0 radius - } + if (radius == 0.0) { + radius = 1.0; // Never a 0 radius + } - // Initialize the Agent as an object - NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, 0.0); - NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, 0); - NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, 0.0); - NavigationServer2D::get_singleton()->agent_set_radius(agent, radius); - NavigationServer2D::get_singleton()->agent_set_max_speed(agent, 0.0); + // Initialize the Agent as an object + NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, 0.0); + NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, 0); + NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, 0.0); + NavigationServer2D::get_singleton()->agent_set_radius(agent, radius); + NavigationServer2D::get_singleton()->agent_set_max_speed(agent, 0.0); + } } diff --git a/scene/2d/navigation_obstacle_2d.h b/scene/2d/navigation_obstacle_2d.h index 421f8ca7cd..135ca4651e 100644 --- a/scene/2d/navigation_obstacle_2d.h +++ b/scene/2d/navigation_obstacle_2d.h @@ -31,15 +31,13 @@ #ifndef NAVIGATION_OBSTACLE_2D_H #define NAVIGATION_OBSTACLE_2D_H +#include "scene/2d/node_2d.h" #include "scene/main/node.h" -class Navigation2D; - class NavigationObstacle2D : public Node { GDCLASS(NavigationObstacle2D, Node); - Navigation2D *navigation = nullptr; - + Node2D *parent_node2d = nullptr; RID agent; protected: @@ -50,14 +48,6 @@ public: NavigationObstacle2D(); virtual ~NavigationObstacle2D(); - void set_navigation(Navigation2D *p_nav); - const Navigation2D *get_navigation() const { - return navigation; - } - - void set_navigation_node(Node *p_nav); - Node *get_navigation_node() const; - RID get_rid() const { return agent; } diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index b02cdf12ad..794993f892 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -34,7 +34,6 @@ #include "core/core_string_names.h" #include "core/math/geometry_2d.h" #include "core/os/mutex.h" -#include "navigation_2d.h" #include "servers/navigation_server_2d.h" #include "thirdparty/misc/polypartition.h" @@ -366,9 +365,7 @@ void NavigationRegion2D::set_enabled(bool p_enabled) { if (!enabled) { NavigationServer2D::get_singleton()->region_set_map(region, RID()); } else { - if (navigation) { - NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); - } + NavigationServer2D::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map()); } if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) { @@ -380,6 +377,14 @@ bool NavigationRegion2D::is_enabled() const { return enabled; } +void NavigationRegion2D::set_layers(uint32_t p_layers) { + NavigationServer2D::get_singleton()->region_set_layers(region, p_layers); +} + +uint32_t NavigationRegion2D::get_layers() const { + return NavigationServer2D::get_singleton()->region_get_layers(region); +} + ///////////////////////////// #ifdef TOOLS_ENABLED Rect2 NavigationRegion2D::_edit_get_rect() const { @@ -394,29 +399,15 @@ bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, doubl void NavigationRegion2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Node2D *c = this; - while (c) { - navigation = Object::cast_to<Navigation2D>(c); - if (navigation) { - if (enabled) { - NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); - } - break; - } - - c = Object::cast_to<Node2D>(c->get_parent()); + if (enabled) { + NavigationServer2D::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map()); } - } break; case NOTIFICATION_TRANSFORM_CHANGED: { NavigationServer2D::get_singleton()->region_set_transform(region, get_global_transform()); - } break; case NOTIFICATION_EXIT_TREE: { - if (navigation) { - NavigationServer2D::get_singleton()->region_set_map(region, RID()); - } - navigation = nullptr; + NavigationServer2D::get_singleton()->region_set_map(region, RID()); } break; case NOTIFICATION_DRAW: { if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) { @@ -507,18 +498,8 @@ String NavigationRegion2D::get_configuration_warning() const { } warning += TTR("A NavigationPolygon resource must be set or created for this node to work. Please set a property or draw a polygon."); } - const Node2D *c = this; - while (c) { - if (Object::cast_to<Navigation2D>(c)) { - return warning; - } - c = Object::cast_to<Node2D>(c->get_parent()); - } - if (!warning.is_empty()) { - warning += "\n\n"; - } - return warning + TTR("NavigationRegion2D must be a child or grandchild to a Navigation2D node. It only provides navigation data."); + return warning; } void NavigationRegion2D::_bind_methods() { @@ -528,10 +509,14 @@ void NavigationRegion2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion2D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion2D::is_enabled); + ClassDB::bind_method(D_METHOD("set_layers", "layers"), &NavigationRegion2D::set_layers); + ClassDB::bind_method(D_METHOD("get_layers"), &NavigationRegion2D::get_layers); + ClassDB::bind_method(D_METHOD("_navpoly_changed"), &NavigationRegion2D::_navpoly_changed); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navpoly", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), "set_navigation_polygon", "get_navigation_polygon"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_layers", "get_layers"); } NavigationRegion2D::NavigationRegion2D() { diff --git a/scene/2d/navigation_region_2d.h b/scene/2d/navigation_region_2d.h index 0b9a258a25..7b471bd555 100644 --- a/scene/2d/navigation_region_2d.h +++ b/scene/2d/navigation_region_2d.h @@ -91,14 +91,11 @@ public: ~NavigationPolygon() {} }; -class Navigation2D; - class NavigationRegion2D : public Node2D { GDCLASS(NavigationRegion2D, Node2D); bool enabled = true; RID region; - Navigation2D *navigation = nullptr; Ref<NavigationPolygon> navpoly; void _navpoly_changed(); @@ -116,6 +113,9 @@ public: void set_enabled(bool p_enabled); bool is_enabled() const; + void set_layers(uint32_t p_layers); + uint32_t get_layers() const; + void set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly); Ref<NavigationPolygon> get_navigation_polygon() const; diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index ecc05fb931..2bb75e5967 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -90,6 +90,12 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler } #endif +void Polygon2D::_validate_property(PropertyInfo &property) const { + if (!invert && property.name == "invert_border") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void Polygon2D::_skeleton_bone_setup_changed() { update(); } @@ -455,6 +461,7 @@ Size2 Polygon2D::get_texture_scale() const { void Polygon2D::set_invert(bool p_invert) { invert = p_invert; update(); + notify_property_list_changed(); } bool Polygon2D::get_invert() const { diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index ab01a4ffd0..b329251277 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -75,6 +75,7 @@ class Polygon2D : public Node2D { protected: void _notification(int p_what); static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: #ifdef TOOLS_ENABLED diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index 2cc3a74270..50625a0f39 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -159,30 +159,7 @@ void RayCast2D::_notification(int p_what) { if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) { break; } - Transform2D xf; - xf.rotate(target_position.angle()); - xf.translate(Vector2(target_position.length(), 0)); - - // Draw an arrow indicating where the RayCast is pointing to - Color draw_col = get_tree()->get_debug_collisions_color(); - if (!enabled) { - float g = draw_col.get_v(); - draw_col.r = g; - draw_col.g = g; - draw_col.b = g; - } - draw_line(Vector2(), target_position, draw_col, 2); - Vector<Vector2> pts; - float tsize = 8.0; - pts.push_back(xf.xform(Vector2(tsize, 0))); - pts.push_back(xf.xform(Vector2(0, Math_SQRT12 * tsize))); - pts.push_back(xf.xform(Vector2(0, -Math_SQRT12 * tsize))); - Vector<Color> cols; - for (int i = 0; i < 3; i++) { - cols.push_back(draw_col); - } - - draw_primitive(pts, cols, Vector<Vector2>()); + _draw_debug_shape(); } break; @@ -212,7 +189,7 @@ void RayCast2D::_update_raycast_state() { } PhysicsDirectSpaceState2D::RayResult rr; - + bool prev_collision_state = collided; if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) { collided = true; against = rr.collider_id; @@ -224,6 +201,48 @@ void RayCast2D::_update_raycast_state() { against = ObjectID(); against_shape = 0; } + + if (prev_collision_state != collided) { + update(); + } +} + +void RayCast2D::_draw_debug_shape() { + Color draw_col = collided ? Color(1.0, 0.01, 0) : get_tree()->get_debug_collisions_color(); + if (!enabled) { + float g = draw_col.get_v(); + draw_col.r = g; + draw_col.g = g; + draw_col.b = g; + } + + // Draw an arrow indicating where the RayCast is pointing to + const float max_arrow_size = 6; + const float line_width = 1.4; + bool no_line = target_position.length() < line_width; + float arrow_size = CLAMP(target_position.length() * 2 / 3, line_width, max_arrow_size); + + if (no_line) { + arrow_size = target_position.length(); + } else { + draw_line(Vector2(), target_position - target_position.normalized() * arrow_size, draw_col, line_width); + } + + Transform2D xf; + xf.rotate(target_position.angle()); + xf.translate(Vector2(no_line ? 0 : target_position.length() - arrow_size, 0)); + + Vector<Vector2> pts; + pts.push_back(xf.xform(Vector2(arrow_size, 0))); + pts.push_back(xf.xform(Vector2(0, 0.5 * arrow_size))); + pts.push_back(xf.xform(Vector2(0, -0.5 * arrow_size))); + + Vector<Color> cols; + for (int i = 0; i < 3; i++) { + cols.push_back(draw_col); + } + + draw_primitive(pts, cols, Vector<Vector2>()); } void RayCast2D::force_raycast_update() { diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index dab3302e25..984c6bda49 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -51,6 +51,8 @@ class RayCast2D : public Node2D { bool collide_with_areas = false; bool collide_with_bodies = true; + void _draw_debug_shape(); + protected: void _notification(int p_what); void _update_raycast_state(); diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp index dde9790b44..31040020dd 100644 --- a/scene/2d/sprite_2d.cpp +++ b/scene/2d/sprite_2d.cpp @@ -206,6 +206,7 @@ void Sprite2D::set_region(bool p_region) { region = p_region; update(); + notify_property_list_changed(); } bool Sprite2D::is_region() const { @@ -383,6 +384,10 @@ void Sprite2D::_validate_property(PropertyInfo &property) const { if (property.name == "frame_coords") { property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } + + if (!region && (property.name == "region_rect" || property.name == "region_filter_clip")) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } } void Sprite2D::_texture_changed() { diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index d868ebae25..81a5b0b28c 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -48,16 +48,6 @@ int TileMap::_get_quadrant_size() const { void TileMap::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Node2D *c = this; - while (c) { - navigation = Object::cast_to<Navigation2D>(c); - if (navigation) { - break; - } - - c = Object::cast_to<Node2D>(c->get_parent()); - } - if (use_parent) { _clear_quadrants(); collision_parent = Object::cast_to<CollisionObject2D>(get_parent()); @@ -77,12 +67,10 @@ void TileMap::_notification(int p_what) { _update_quadrant_space(RID()); for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); - if (navigation) { - for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) { - NavigationServer2D::get_singleton()->region_set_map(F->get().region, RID()); - } - q.navpoly_ids.clear(); + for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) { + NavigationServer2D::get_singleton()->region_set_map(F->get().region, RID()); } + q.navpoly_ids.clear(); if (collision_parent) { collision_parent->remove_shape_owner(q.shape_owner_id); @@ -96,8 +84,6 @@ void TileMap::_notification(int p_what) { } collision_parent = nullptr; - navigation = nullptr; - } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -135,11 +121,6 @@ void TileMap::_update_quadrant_transform() { local_transform = get_transform(); } - Transform2D nav_rel; - if (navigation) { - nav_rel = get_relative_transform_to_parent(navigation); - } - for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); Transform2D xform; @@ -150,9 +131,9 @@ void TileMap::_update_quadrant_transform() { PhysicsServer2D::get_singleton()->body_set_state(q.body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform); } - if (navigation) { + if (bake_navigation) { for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) { - NavigationServer2D::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform); + NavigationServer2D::get_singleton()->region_set_transform(F->get().region, F->get().xform); } } @@ -315,11 +296,6 @@ void TileMap::update_dirty_quadrants() { RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); Vector2 tofs = get_cell_draw_offset(); - Transform2D nav_rel; - if (navigation) { - nav_rel = get_relative_transform_to_parent(navigation); - } - Vector2 qofs; SceneTree *st = SceneTree::get_singleton(); @@ -352,12 +328,10 @@ void TileMap::update_dirty_quadrants() { } int shape_idx = 0; - if (navigation) { - for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) { - NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); - } - q.navpoly_ids.clear(); + for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) { + NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); } + q.navpoly_ids.clear(); for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) { RS::get_singleton()->free(E->get().id); @@ -579,7 +553,7 @@ void TileMap::update_dirty_quadrants() { vs->canvas_item_add_set_transform(debug_canvas_item, Transform2D()); } - if (navigation) { + if (bake_navigation) { Ref<NavigationPolygon> navpoly; Vector2 npoly_ofs; if (tile_set->tile_get_tile_mode(c.id) == TileSet::AUTO_TILE || tile_set->tile_get_tile_mode(c.id) == TileSet::ATLAS_TILE) { @@ -596,8 +570,8 @@ void TileMap::update_dirty_quadrants() { _fix_cell_transform(xform, c, npoly_ofs, s); RID region = NavigationServer2D::get_singleton()->region_create(); - NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); - NavigationServer2D::get_singleton()->region_set_transform(region, nav_rel * xform); + NavigationServer2D::get_singleton()->region_set_map(region, get_world_2d()->get_navigation_map()); + NavigationServer2D::get_singleton()->region_set_transform(region, xform); NavigationServer2D::get_singleton()->region_set_navpoly(region, navpoly); Quadrant::NavPoly np; @@ -787,12 +761,10 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) { dirty_quadrant_list.remove(&q.dirty_list); } - if (navigation) { - for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) { - NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); - } - q.navpoly_ids.clear(); + for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) { + NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); } + q.navpoly_ids.clear(); for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) { RS::get_singleton()->free(E->get().id); @@ -1360,6 +1332,17 @@ float TileMap::get_collision_bounce() const { return bounce; } +void TileMap::set_bake_navigation(bool p_bake_navigation) { + bake_navigation = p_bake_navigation; + for (Map<PosKey, Quadrant>::Element *F = quadrant_map.front(); F; F = F->next()) { + _make_quadrant_dirty(F); + } +} + +bool TileMap::is_baking_navigation() { + return bake_navigation; +} + uint32_t TileMap::get_collision_layer() const { return collision_layer; } @@ -1784,6 +1767,9 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_collision_bounce", "value"), &TileMap::set_collision_bounce); ClassDB::bind_method(D_METHOD("get_collision_bounce"), &TileMap::get_collision_bounce); + ClassDB::bind_method(D_METHOD("set_bake_navigation", "bake_navigation"), &TileMap::set_bake_navigation); + ClassDB::bind_method(D_METHOD("is_baking_navigation"), &TileMap::is_baking_navigation); + ClassDB::bind_method(D_METHOD("set_occluder_light_mask", "mask"), &TileMap::set_occluder_light_mask); ClassDB::bind_method(D_METHOD("get_occluder_light_mask"), &TileMap::get_occluder_light_mask); @@ -1842,6 +1828,9 @@ void TileMap::_bind_methods() { ADD_GROUP("Occluder", "occluder_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "occluder_light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_occluder_light_mask", "get_occluder_light_mask"); + ADD_GROUP("Navigation", ""); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bake_navigation"), "set_bake_navigation", "is_baking_navigation"); + ADD_PROPERTY_DEFAULT("format", FORMAT_1); ADD_SIGNAL(MethodInfo("settings_changed")); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 3bf4587921..26c84a0bb9 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -33,7 +33,6 @@ #include "core/templates/self_list.h" #include "core/templates/vset.h" -#include "scene/2d/navigation_2d.h" #include "scene/2d/node_2d.h" #include "scene/resources/tile_set.h" @@ -78,7 +77,7 @@ private: bool use_parent = false; CollisionObject2D *collision_parent = nullptr; bool use_kinematic = false; - Navigation2D *navigation = nullptr; + bool bake_navigation = false; union PosKey { struct { @@ -295,6 +294,9 @@ public: void set_collision_bounce(float p_bounce); float get_collision_bounce() const; + void set_bake_navigation(bool p_bake_navigation); + bool is_baking_navigation(); + void set_mode(Mode p_mode); Mode get_mode() const; diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 578ea823f0..402e2b8f40 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -78,6 +78,7 @@ void BakedLightmapData::clear_users() { } void BakedLightmapData::_set_user_data(const Array &p_data) { + ERR_FAIL_COND(p_data.size() <= 0); ERR_FAIL_COND((p_data.size() % 4) != 0); for (int i = 0; i < p_data.size(); i += 4) { diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index 0f10f2b85f..7d6abe458a 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -109,6 +109,7 @@ Color Decal::get_modulate() const { void Decal::set_enable_distance_fade(bool p_enable) { distance_fade_enabled = p_enable; RS::get_singleton()->decal_set_distance_fade(decal, distance_fade_enabled, distance_fade_begin, distance_fade_length); + notify_property_list_changed(); } bool Decal::is_distance_fade_enabled() const { @@ -153,6 +154,12 @@ Vector<Face3> Decal::get_faces(uint32_t p_usage_flags) const { return Vector<Face3>(); } +void Decal::_validate_property(PropertyInfo &property) const { + if (!distance_fade_enabled && (property.name == "distance_fade_begin" || property.name == "distance_fade_length")) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void Decal::_bind_methods() { ClassDB::bind_method(D_METHOD("set_extents", "extents"), &Decal::set_extents); ClassDB::bind_method(D_METHOD("get_extents"), &Decal::get_extents); diff --git a/scene/3d/decal.h b/scene/3d/decal.h index 095579d775..ce19e76de1 100644 --- a/scene/3d/decal.h +++ b/scene/3d/decal.h @@ -64,6 +64,7 @@ private: protected: static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: void set_extents(const Vector3 &p_extents); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 8a8bfe50b9..43f820e5d4 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -415,13 +415,16 @@ Vector3i GIProbe::get_estimated_cell_size() const { void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 }; + p_from_node = p_from_node ? p_from_node : get_parent(); + ERR_FAIL_NULL(p_from_node); + Voxelizer baker; baker.begin_bake(subdiv_value[subdiv], AABB(-extents, extents * 2.0)); List<PlotMesh> mesh_list; - _find_meshes(p_from_node ? p_from_node : get_parent(), mesh_list); + _find_meshes(p_from_node, mesh_list); if (bake_begin_function) { bake_begin_function(mesh_list.size() + 1); diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index b0a10b5547..f109640aef 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -65,6 +65,8 @@ void Light3D::set_shadow(bool p_enable) { if (type == RenderingServer::LIGHT_SPOT || type == RenderingServer::LIGHT_OMNI) { update_configuration_warning(); } + + notify_property_list_changed(); } bool Light3D::has_shadow() const { @@ -202,6 +204,10 @@ bool Light3D::is_editor_only() const { } void Light3D::_validate_property(PropertyInfo &property) const { + if (!shadow && (property.name == "shadow_color" || property.name == "shadow_bias" || property.name == "shadow_normal_bias" || property.name == "shadow_reverse_cull_face" || property.name == "shadow_transmittance_bias" || property.name == "shadow_fog_fade" || property.name == "shadow_blur")) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } + if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_size") { property.usage = 0; } diff --git a/scene/3d/navigation_3d.cpp b/scene/3d/navigation_3d.cpp deleted file mode 100644 index eaddec7601..0000000000 --- a/scene/3d/navigation_3d.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/*************************************************************************/ -/* navigation_3d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "navigation_3d.h" - -#include "servers/navigation_server_3d.h" - -Vector<Vector3> Navigation3D::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const { - return NavigationServer3D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); -} - -Vector3 Navigation3D::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision) const { - return NavigationServer3D::get_singleton()->map_get_closest_point_to_segment(map, p_from, p_to, p_use_collision); -} - -Vector3 Navigation3D::get_closest_point(const Vector3 &p_point) const { - return NavigationServer3D::get_singleton()->map_get_closest_point(map, p_point); -} - -Vector3 Navigation3D::get_closest_point_normal(const Vector3 &p_point) const { - return NavigationServer3D::get_singleton()->map_get_closest_point_normal(map, p_point); -} - -RID Navigation3D::get_closest_point_owner(const Vector3 &p_point) const { - return NavigationServer3D::get_singleton()->map_get_closest_point_owner(map, p_point); -} - -void Navigation3D::set_up_vector(const Vector3 &p_up) { - up = p_up; - NavigationServer3D::get_singleton()->map_set_up(map, up); -} - -Vector3 Navigation3D::get_up_vector() const { - return up; -} - -void Navigation3D::set_cell_size(float p_cell_size) { - cell_size = p_cell_size; - NavigationServer3D::get_singleton()->map_set_cell_size(map, cell_size); -} - -void Navigation3D::set_edge_connection_margin(float p_edge_connection_margin) { - edge_connection_margin = p_edge_connection_margin; - NavigationServer3D::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin); -} - -void Navigation3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_rid"), &Navigation3D::get_rid); - - ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation3D::get_simple_path, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "start", "end", "use_collision"), &Navigation3D::get_closest_point_to_segment, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("get_closest_point", "to_point"), &Navigation3D::get_closest_point); - ClassDB::bind_method(D_METHOD("get_closest_point_normal", "to_point"), &Navigation3D::get_closest_point_normal); - ClassDB::bind_method(D_METHOD("get_closest_point_owner", "to_point"), &Navigation3D::get_closest_point_owner); - - ClassDB::bind_method(D_METHOD("set_up_vector", "up"), &Navigation3D::set_up_vector); - ClassDB::bind_method(D_METHOD("get_up_vector"), &Navigation3D::get_up_vector); - - ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &Navigation3D::set_cell_size); - ClassDB::bind_method(D_METHOD("get_cell_size"), &Navigation3D::get_cell_size); - - ClassDB::bind_method(D_METHOD("set_edge_connection_margin", "margin"), &Navigation3D::set_edge_connection_margin); - ClassDB::bind_method(D_METHOD("get_edge_connection_margin"), &Navigation3D::get_edge_connection_margin); - - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "up_vector"), "set_up_vector", "get_up_vector"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_size"), "set_cell_size", "get_cell_size"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "edge_connection_margin"), "set_edge_connection_margin", "get_edge_connection_margin"); -} - -void Navigation3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - NavigationServer3D::get_singleton()->map_set_active(map, true); - } break; - case NOTIFICATION_EXIT_TREE: { - NavigationServer3D::get_singleton()->map_set_active(map, false); - } break; - } -} - -Navigation3D::Navigation3D() { - map = NavigationServer3D::get_singleton()->map_create(); - - set_cell_size(0.3); - set_edge_connection_margin(5.0); // Five meters, depends a lot on the agent's radius -} - -Navigation3D::~Navigation3D() { - NavigationServer3D::get_singleton()->free(map); -} diff --git a/scene/3d/navigation_3d.h b/scene/3d/navigation_3d.h deleted file mode 100644 index b89725a3f5..0000000000 --- a/scene/3d/navigation_3d.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************/ -/* navigation_3d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef NAVIGATION_3D_H -#define NAVIGATION_3D_H - -#include "scene/3d/navigation_region_3d.h" -#include "scene/3d/node_3d.h" - -class Navigation3D : public Node3D { - GDCLASS(Navigation3D, Node3D); - - RID map; - - Vector3 up = Vector3(0, 1, 0); - real_t cell_size; - real_t edge_connection_margin; - -protected: - static void _bind_methods(); - void _notification(int p_what); - -public: - RID get_rid() const { - return map; - } - - void set_up_vector(const Vector3 &p_up); - Vector3 get_up_vector() const; - - void set_cell_size(float p_cell_size); - float get_cell_size() const { - return cell_size; - } - - void set_edge_connection_margin(float p_edge_connection_margin); - float get_edge_connection_margin() const { - return edge_connection_margin; - } - - Vector<Vector3> get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize = true) const; - Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision = false) const; - Vector3 get_closest_point(const Vector3 &p_point) const; - Vector3 get_closest_point_normal(const Vector3 &p_point) const; - RID get_closest_point_owner(const Vector3 &p_point) const; - - Navigation3D(); - ~Navigation3D(); -}; - -#endif // NAVIGATION_H diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 8917cc4664..21ca3d70dd 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -31,7 +31,6 @@ #include "navigation_agent_3d.h" #include "core/config/engine.h" -#include "scene/3d/navigation_3d.h" #include "servers/navigation_server_3d.h" void NavigationAgent3D::_bind_methods() { @@ -47,9 +46,6 @@ void NavigationAgent3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_ignore_y", "ignore"), &NavigationAgent3D::set_ignore_y); ClassDB::bind_method(D_METHOD("get_ignore_y"), &NavigationAgent3D::get_ignore_y); - ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationAgent3D::set_navigation_node); - ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationAgent3D::get_navigation_node); - ClassDB::bind_method(D_METHOD("set_neighbor_dist", "neighbor_dist"), &NavigationAgent3D::set_neighbor_dist); ClassDB::bind_method(D_METHOD("get_neighbor_dist"), &NavigationAgent3D::get_neighbor_dist); @@ -101,28 +97,10 @@ void NavigationAgent3D::_notification(int p_what) { agent_parent = Object::cast_to<Node3D>(get_parent()); NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); - - // Search the navigation node and set it - { - Navigation3D *nav = nullptr; - Node *p = get_parent(); - while (p != nullptr) { - nav = Object::cast_to<Navigation3D>(p); - if (nav != nullptr) { - p = nullptr; - } else { - p = p->get_parent(); - } - } - - set_navigation(nav); - } - set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { agent_parent = nullptr; - set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -154,25 +132,6 @@ NavigationAgent3D::~NavigationAgent3D() { agent = RID(); // Pointless } -void NavigationAgent3D::set_navigation(Navigation3D *p_nav) { - if (navigation == p_nav) { - return; // Pointless - } - - navigation = p_nav; - NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); -} - -void NavigationAgent3D::set_navigation_node(Node *p_nav) { - Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav); - ERR_FAIL_COND(nav == nullptr); - set_navigation(nav); -} - -Node *NavigationAgent3D::get_navigation_node() const { - return Object::cast_to<Node>(navigation); -} - void NavigationAgent3D::set_target_desired_distance(real_t p_dd) { target_desired_distance = p_dd; } @@ -303,7 +262,7 @@ void NavigationAgent3D::update_navigation() { if (agent_parent == nullptr) { return; } - if (navigation == nullptr) { + if (!agent_parent->is_inside_tree()) { return; } if (update_frame_id == Engine::get_singleton()->get_physics_frames()) { @@ -337,7 +296,7 @@ void NavigationAgent3D::update_navigation() { } if (reload_path) { - navigation_path = NavigationServer3D::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true); + navigation_path = NavigationServer3D::get_singleton()->map_get_path(agent_parent->get_world_3d()->get_navigation_map(), o, target_location, true); navigation_finished = false; nav_path_index = 0; emit_signal("path_changed"); diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h index bd890a051b..22db889618 100644 --- a/scene/3d/navigation_agent_3d.h +++ b/scene/3d/navigation_agent_3d.h @@ -35,13 +35,11 @@ #include "scene/main/node.h" class Node3D; -class Navigation3D; class NavigationAgent3D : public Node { GDCLASS(NavigationAgent3D, Node); Node3D *agent_parent = nullptr; - Navigation3D *navigation = nullptr; RID agent; @@ -76,14 +74,6 @@ public: NavigationAgent3D(); virtual ~NavigationAgent3D(); - void set_navigation(Navigation3D *p_nav); - const Navigation3D *get_navigation() const { - return navigation; - } - - void set_navigation_node(Node *p_nav); - Node *get_navigation_node() const; - RID get_rid() const { return agent; } diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index 01bf7de913..df03bca4fd 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -31,55 +31,38 @@ #include "navigation_obstacle_3d.h" #include "scene/3d/collision_shape_3d.h" -#include "scene/3d/navigation_3d.h" #include "scene/3d/physics_body_3d.h" #include "servers/navigation_server_3d.h" void NavigationObstacle3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle3D::set_navigation_node); - ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle3D::get_navigation_node); } void NavigationObstacle3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - update_agent_shape(); - - // Search the navigation node and set it - { - Navigation3D *nav = nullptr; - Node *p = get_parent(); - while (p != nullptr) { - nav = Object::cast_to<Navigation3D>(p); - if (nav != nullptr) { - p = nullptr; - } else { - p = p->get_parent(); - } - } - - set_navigation(nav); - } - set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - set_navigation(nullptr); set_physics_process_internal(false); } break; + case NOTIFICATION_PARENTED: { + parent_node3d = Object::cast_to<Node3D>(get_parent()); + update_agent_shape(); + } break; + case NOTIFICATION_UNPARENTED: { + parent_node3d = nullptr; + } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - Node3D *spatial = Object::cast_to<Node3D>(get_parent()); - if (spatial) { - NavigationServer3D::get_singleton()->agent_set_position(agent, spatial->get_global_transform().origin); - } - - PhysicsBody3D *rigid = Object::cast_to<PhysicsBody3D>(get_parent()); - if (rigid) { - Vector3 v = rigid->get_linear_velocity(); - NavigationServer3D::get_singleton()->agent_set_velocity(agent, v); - NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, v); + if (parent_node3d) { + NavigationServer3D::get_singleton()->agent_set_position(agent, parent_node3d->get_global_transform().origin); + + PhysicsBody3D *rigid = Object::cast_to<PhysicsBody3D>(get_parent()); + if (rigid) { + Vector3 v = rigid->get_linear_velocity(); + NavigationServer3D::get_singleton()->agent_set_velocity(agent, v); + NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, v); + } } - } break; } } @@ -93,29 +76,10 @@ NavigationObstacle3D::~NavigationObstacle3D() { agent = RID(); // Pointless } -void NavigationObstacle3D::set_navigation(Navigation3D *p_nav) { - if (navigation == p_nav) { - return; // Pointless - } - - navigation = p_nav; - NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); -} - -void NavigationObstacle3D::set_navigation_node(Node *p_nav) { - Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav); - ERR_FAIL_COND(nav == nullptr); - set_navigation(nav); -} - -Node *NavigationObstacle3D::get_navigation_node() const { - return Object::cast_to<Node>(navigation); -} - String NavigationObstacle3D::get_configuration_warning() const { String warning = Node::get_configuration_warning(); - if (!Object::cast_to<Node3D>(get_parent())) { + if (!parent_node3d) { if (!warning.is_empty()) { warning += "\n\n"; } @@ -126,40 +90,38 @@ String NavigationObstacle3D::get_configuration_warning() const { } void NavigationObstacle3D::update_agent_shape() { - Node *node = get_parent(); - - // Estimate the radius of this physics body - real_t radius = 0.0; - for (int i(0); i < node->get_child_count(); i++) { - // For each collision shape - CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(node->get_child(i)); - if (cs) { - // Take the distance between the Body center to the shape center - real_t r = cs->get_transform().origin.length(); - if (cs->get_shape().is_valid()) { - // and add the enclosing shape radius - r += cs->get_shape()->get_enclosing_radius(); + if (parent_node3d) { + // Estimate the radius of this physics body + real_t radius = 0.0; + for (int i(0); i < parent_node3d->get_child_count(); i++) { + // For each collision shape + CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(parent_node3d->get_child(i)); + if (cs) { + // Take the distance between the Body center to the shape center + real_t r = cs->get_transform().origin.length(); + if (cs->get_shape().is_valid()) { + // and add the enclosing shape radius + r += cs->get_shape()->get_enclosing_radius(); + } + Vector3 s = cs->get_global_transform().basis.get_scale(); + r *= MAX(s.x, MAX(s.y, s.z)); + // Takes the biggest radius + radius = MAX(radius, r); } - Vector3 s = cs->get_global_transform().basis.get_scale(); - r *= MAX(s.x, MAX(s.y, s.z)); - // Takes the biggest radius - radius = MAX(radius, r); } - } - Node3D *spa = Object::cast_to<Node3D>(node); - if (spa) { - Vector3 s = spa->get_global_transform().basis.get_scale(); + + Vector3 s = parent_node3d->get_global_transform().basis.get_scale(); radius *= MAX(s.x, MAX(s.y, s.z)); - } - if (radius == 0.0) { - radius = 1.0; // Never a 0 radius - } + if (radius == 0.0) { + radius = 1.0; // Never a 0 radius + } - // Initialize the Agent as an object - NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, 0.0); - NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, 0); - NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, 0.0); - NavigationServer3D::get_singleton()->agent_set_radius(agent, radius); - NavigationServer3D::get_singleton()->agent_set_max_speed(agent, 0.0); + // Initialize the Agent as an object + NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, 0.0); + NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, 0); + NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, 0.0); + NavigationServer3D::get_singleton()->agent_set_radius(agent, radius); + NavigationServer3D::get_singleton()->agent_set_max_speed(agent, 0.0); + } } diff --git a/scene/3d/navigation_obstacle_3d.h b/scene/3d/navigation_obstacle_3d.h index b8d05b8a87..b1bb53724a 100644 --- a/scene/3d/navigation_obstacle_3d.h +++ b/scene/3d/navigation_obstacle_3d.h @@ -31,15 +31,13 @@ #ifndef NAVIGATION_OBSTACLE_H #define NAVIGATION_OBSTACLE_H +#include "scene/3d/node_3d.h" #include "scene/main/node.h" -class Navigation3D; - class NavigationObstacle3D : public Node { GDCLASS(NavigationObstacle3D, Node); - Navigation3D *navigation = nullptr; - + Node3D *parent_node3d = nullptr; RID agent; protected: @@ -50,14 +48,6 @@ public: NavigationObstacle3D(); virtual ~NavigationObstacle3D(); - void set_navigation(Navigation3D *p_nav); - const Navigation3D *get_navigation() const { - return navigation; - } - - void set_navigation_node(Node *p_nav); - Node *get_navigation_node() const; - RID get_rid() const { return agent; } diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 19bde94222..3ca704e4b8 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -32,7 +32,6 @@ #include "core/os/thread.h" #include "mesh_instance_3d.h" -#include "navigation_3d.h" #include "servers/navigation_server_3d.h" void NavigationRegion3D::set_enabled(bool p_enabled) { @@ -48,9 +47,7 @@ void NavigationRegion3D::set_enabled(bool p_enabled) { if (!enabled) { NavigationServer3D::get_singleton()->region_set_map(region, RID()); } else { - if (navigation) { - NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); - } + NavigationServer3D::get_singleton()->region_set_map(region, get_world_3d()->get_navigation_map()); } if (debug_view) { @@ -69,22 +66,21 @@ bool NavigationRegion3D::is_enabled() const { return enabled; } +void NavigationRegion3D::set_layers(uint32_t p_layers) { + NavigationServer3D::get_singleton()->region_set_layers(region, p_layers); +} + +uint32_t NavigationRegion3D::get_layers() const { + return NavigationServer3D::get_singleton()->region_get_layers(region); +} + ///////////////////////////// void NavigationRegion3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Node3D *c = this; - while (c) { - navigation = Object::cast_to<Navigation3D>(c); - if (navigation) { - if (enabled) { - NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); - } - break; - } - - c = c->get_parent_spatial(); + if (enabled) { + NavigationServer3D::get_singleton()->region_set_map(region, get_world_3d()->get_navigation_map()); } if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) { @@ -105,15 +101,12 @@ void NavigationRegion3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - if (navigation) { - NavigationServer3D::get_singleton()->region_set_map(region, RID()); - } + NavigationServer3D::get_singleton()->region_set_map(region, RID()); if (debug_view) { debug_view->queue_delete(); debug_view = nullptr; } - navigation = nullptr; } break; } } @@ -198,19 +191,7 @@ String NavigationRegion3D::get_configuration_warning() const { warning += TTR("A NavigationMesh resource must be set or created for this node to work."); } - const Node3D *c = this; - while (c) { - if (Object::cast_to<Navigation3D>(c)) { - return warning; - } - - c = Object::cast_to<Node3D>(c->get_parent()); - } - - if (!warning.is_empty()) { - warning += "\n\n"; - } - return warning + TTR("NavigationRegion3D must be a child or grandchild to a Navigation3D node. It only provides navigation data."); + return warning; } void NavigationRegion3D::_bind_methods() { @@ -220,11 +201,15 @@ void NavigationRegion3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion3D::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion3D::is_enabled); + ClassDB::bind_method(D_METHOD("set_layers", "layers"), &NavigationRegion3D::set_layers); + ClassDB::bind_method(D_METHOD("get_layers"), &NavigationRegion3D::get_layers); + ClassDB::bind_method(D_METHOD("bake_navigation_mesh"), &NavigationRegion3D::bake_navigation_mesh); ClassDB::bind_method(D_METHOD("_bake_finished", "nav_mesh"), &NavigationRegion3D::_bake_finished); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_layers", "get_layers"); ADD_SIGNAL(MethodInfo("navigation_mesh_changed")); ADD_SIGNAL(MethodInfo("bake_finished")); diff --git a/scene/3d/navigation_region_3d.h b/scene/3d/navigation_region_3d.h index 6ae15c9360..52fa2d6159 100644 --- a/scene/3d/navigation_region_3d.h +++ b/scene/3d/navigation_region_3d.h @@ -35,8 +35,6 @@ #include "scene/resources/mesh.h" #include "scene/resources/navigation_mesh.h" -class Navigation3D; - class NavigationRegion3D : public Node3D { GDCLASS(NavigationRegion3D, Node3D); @@ -44,7 +42,6 @@ class NavigationRegion3D : public Node3D { RID region; Ref<NavigationMesh> navmesh; - Navigation3D *navigation = nullptr; Node *debug_view = nullptr; Thread bake_thread; @@ -58,6 +55,9 @@ public: void set_enabled(bool p_enabled); bool is_enabled() const; + void set_layers(uint32_t p_layers); + uint32_t get_layers() const; + void set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh); Ref<NavigationMesh> get_navigation_mesh() const; diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index 0463bed9d6..de9c75621b 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -46,24 +46,15 @@ void Joint3D::_disconnect_signals() { } } -void Joint3D::_body_exit_tree(const ObjectID &p_body_id) { +void Joint3D::_body_exit_tree() { _disconnect_signals(); - Object *object = ObjectDB::get_instance(p_body_id); - PhysicsBody3D *body = Object::cast_to<PhysicsBody3D>(object); - ERR_FAIL_NULL(body); - RID body_rid = body->get_rid(); - if (ba == body_rid) { - a = NodePath(); - } - if (bb == body_rid) { - b = NodePath(); - } - _update_joint(); + _update_joint(true); } void Joint3D::_update_joint(bool p_only_free) { if (ba.is_valid() && bb.is_valid()) { PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb); + PhysicsServer3D::get_singleton()->body_remove_collision_exception(bb, ba); } ba = RID(); @@ -133,12 +124,12 @@ void Joint3D::_update_joint(bool p_only_free) { if (body_a) { ba = body_a->get_rid(); - body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree), make_binds(body_a->get_instance_id())); + body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree)); } if (body_b) { bb = body_b->get_rid(); - body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree), make_binds(body_b->get_instance_id())); + body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree)); } PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h index 8d0a16e432..f624ba602b 100644 --- a/scene/3d/physics_joint_3d.h +++ b/scene/3d/physics_joint_3d.h @@ -51,7 +51,7 @@ class Joint3D : public Node3D { protected: void _disconnect_signals(); - void _body_exit_tree(const ObjectID &p_body_id); + void _body_exit_tree(); void _update_joint(bool p_only_free = false); void _notification(int p_what); diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index bfe79f15f5..465de2cb47 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -37,10 +37,13 @@ void RayCast3D::set_target_position(const Vector3 &p_point) { target_position = p_point; - if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) { - update_gizmo(); - } - if (is_inside_tree() && get_tree()->is_debugging_collisions_hint()) { + update_gizmo(); + + if (Engine::get_singleton()->is_editor_hint()) { + if (is_inside_tree()) { + _update_debug_shape_vertices(); + } + } else if (debug_shape) { _update_debug_shape(); } } @@ -146,6 +149,9 @@ bool RayCast3D::get_exclude_parent_body() const { void RayCast3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { + if (Engine::get_singleton()->is_editor_hint()) { + _update_debug_shape_vertices(); + } if (enabled && !Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(true); } else { @@ -183,10 +189,7 @@ void RayCast3D::_notification(int p_what) { bool prev_collision_state = collided; _update_raycast_state(); if (prev_collision_state != collided && get_tree()->is_debugging_collisions_hint()) { - if (debug_material.is_valid()) { - Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D>>(debug_material); - line_material->set_albedo(collided ? Color(1.0, 0, 0) : Color(1.0, 0.8, 0.6)); - } + _update_debug_shape_material(true); } } break; @@ -310,6 +313,12 @@ void RayCast3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &RayCast3D::set_collide_with_bodies); ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &RayCast3D::is_collide_with_bodies_enabled); + ClassDB::bind_method(D_METHOD("set_debug_shape_custom_color", "debug_shape_custom_color"), &RayCast3D::set_debug_shape_custom_color); + ClassDB::bind_method(D_METHOD("get_debug_shape_custom_color"), &RayCast3D::get_debug_shape_custom_color); + + ClassDB::bind_method(D_METHOD("set_debug_shape_thickness", "debug_shape_thickness"), &RayCast3D::set_debug_shape_thickness); + ClassDB::bind_method(D_METHOD("get_debug_shape_thickness"), &RayCast3D::get_debug_shape_thickness); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclude_parent"), "set_exclude_parent_body", "get_exclude_parent_body"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position"); @@ -318,16 +327,80 @@ void RayCast3D::_bind_methods() { ADD_GROUP("Collide With", "collide_with"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_areas", "is_collide_with_areas_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_bodies", "is_collide_with_bodies_enabled"); + + ADD_GROUP("Debug Shape", "debug_shape"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_shape_custom_color"), "set_debug_shape_custom_color", "get_debug_shape_custom_color"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_shape_thickness", PROPERTY_HINT_RANGE, "1,5"), "set_debug_shape_thickness", "get_debug_shape_thickness"); } -void RayCast3D::_create_debug_shape() { - if (!debug_material.is_valid()) { - debug_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); +float RayCast3D::get_debug_shape_thickness() const { + return debug_shape_thickness; +} + +void RayCast3D::_update_debug_shape_vertices() { + debug_shape_vertices.clear(); + debug_line_vertices.clear(); + + if (target_position == Vector3()) { + return; + } + + debug_line_vertices.push_back(Vector3()); + debug_line_vertices.push_back(target_position); + + if (debug_shape_thickness > 1) { + float scale_factor = 100.0; + Vector3 dir = Vector3(target_position).normalized(); + // Draw truncated pyramid + Vector3 normal = (fabs(dir.x) + fabs(dir.y) > CMP_EPSILON) ? Vector3(-dir.y, dir.x, 0).normalized() : Vector3(0, -dir.z, dir.y).normalized(); + normal *= debug_shape_thickness / scale_factor; + int vertices_strip_order[14] = { 4, 5, 0, 1, 2, 5, 6, 4, 7, 0, 3, 2, 7, 6 }; + for (int v = 0; v < 14; v++) { + Vector3 vertex = vertices_strip_order[v] < 4 ? normal : normal / 3.0 + target_position; + debug_shape_vertices.push_back(vertex.rotated(dir, Math_PI * (0.5 * (vertices_strip_order[v] % 4) + 0.25))); + } + } +} + +void RayCast3D::set_debug_shape_thickness(const float p_debug_shape_thickness) { + debug_shape_thickness = p_debug_shape_thickness; + update_gizmo(); + + if (Engine::get_singleton()->is_editor_hint()) { + if (is_inside_tree()) { + _update_debug_shape_vertices(); + } + } else if (debug_shape) { + _update_debug_shape(); + } +} + +const Vector<Vector3> &RayCast3D::get_debug_shape_vertices() const { + return debug_shape_vertices; +} - Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D>>(debug_material); - line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - line_material->set_albedo(Color(1.0, 0.8, 0.6)); +const Vector<Vector3> &RayCast3D::get_debug_line_vertices() const { + return debug_line_vertices; +} + +void RayCast3D::set_debug_shape_custom_color(const Color &p_color) { + debug_shape_custom_color = p_color; + if (debug_material.is_valid()) { + _update_debug_shape_material(); } +} + +Ref<StandardMaterial3D> RayCast3D::get_debug_material() { + _update_debug_shape_material(); + return debug_material; +} + +const Color &RayCast3D::get_debug_shape_custom_color() const { + return debug_shape_custom_color; +} + +void RayCast3D::_create_debug_shape() { + _update_debug_shape_material(); Ref<ArrayMesh> mesh = memnew(ArrayMesh); @@ -338,6 +411,35 @@ void RayCast3D::_create_debug_shape() { debug_shape = mi; } +void RayCast3D::_update_debug_shape_material(bool p_check_collision) { + if (!debug_material.is_valid()) { + Ref<StandardMaterial3D> material = memnew(StandardMaterial3D); + debug_material = material; + + material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + material->set_transparency(BaseMaterial3D::TRANSPARENCY_ALPHA); + } + + Color color = debug_shape_custom_color; + if (color == Color(0.0, 0.0, 0.0)) { + // Use the default debug shape color defined in the Project Settings. + color = get_tree()->get_debug_collisions_color(); + } + + if (p_check_collision) { + if ((color.get_h() < 0.055 || color.get_h() > 0.945) && color.get_s() > 0.5 && color.get_v() > 0.5) { + // If base color is already quite reddish, hightlight collision with green color + color = Color(0.0, 1.0, 0.0, color.a); + } else { + // Else, hightlight collision with red color + color = Color(1.0, 0, 0, color.a); + } + } + + Ref<StandardMaterial3D> material = static_cast<Ref<StandardMaterial3D>>(debug_material); + material->set_albedo(color); +} + void RayCast3D::_update_debug_shape() { if (!enabled) { return; @@ -353,26 +455,28 @@ void RayCast3D::_update_debug_shape() { return; } - Vector<Vector3> verts; - verts.push_back(Vector3()); - verts.push_back(target_position); + _update_debug_shape_vertices(); - if (mesh->get_surface_count() == 0) { - Array a; - a.resize(Mesh::ARRAY_MAX); - a[Mesh::ARRAY_VERTEX] = verts; + mesh->clear_surfaces(); - uint32_t flags = Mesh::ARRAY_FLAG_USE_DYNAMIC_UPDATE; + Array a; + a.resize(Mesh::ARRAY_MAX); + uint32_t flags = 0; + int surface_count = 0; + + if (!debug_line_vertices.is_empty()) { + a[Mesh::ARRAY_VERTEX] = debug_line_vertices; mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, a, Array(), Dictionary(), flags); - mesh->surface_set_material(0, debug_material); - } else { - Vector<uint8_t> byte_array; - int array_size = sizeof(Vector3) * verts.size(); - byte_array.resize(array_size); - copymem(byte_array.ptrw(), verts.ptr(), array_size); + mesh->surface_set_material(surface_count, debug_material); + ++surface_count; + } - RS::get_singleton()->mesh_surface_update_region(mesh->get_rid(), 0, 0, byte_array); + if (!debug_shape_vertices.is_empty()) { + a[Mesh::ARRAY_VERTEX] = debug_shape_vertices; + mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_STRIP, a, Array(), Dictionary(), flags); + mesh->surface_set_material(surface_count, debug_material); + ++surface_count; } } diff --git a/scene/3d/ray_cast_3d.h b/scene/3d/ray_cast_3d.h index ae92189527..968cede9f2 100644 --- a/scene/3d/ray_cast_3d.h +++ b/scene/3d/ray_cast_3d.h @@ -51,9 +51,15 @@ class RayCast3D : public Node3D { Node *debug_shape = nullptr; Ref<Material> debug_material; + Color debug_shape_custom_color = Color(0.0, 0.0, 0.0); + int debug_shape_thickness = 2; + Vector<Vector3> debug_shape_vertices; + Vector<Vector3> debug_line_vertices; void _create_debug_shape(); void _update_debug_shape(); + void _update_debug_shape_material(bool p_check_collision = false); + void _update_debug_shape_vertices(); void _clear_debug_shape(); bool collide_with_areas = false; @@ -86,6 +92,17 @@ public: void set_exclude_parent_body(bool p_exclude_parent_body); bool get_exclude_parent_body() const; + const Color &get_debug_shape_custom_color() const; + void set_debug_shape_custom_color(const Color &p_color); + + const Vector<Vector3> &get_debug_shape_vertices() const; + const Vector<Vector3> &get_debug_line_vertices() const; + + Ref<StandardMaterial3D> get_debug_material(); + + float get_debug_shape_thickness() const; + void set_debug_shape_thickness(const float p_debug_thickness); + void force_raycast_update(); bool is_colliding() const; Object *get_collider() const; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index cb2df9130f..b7a3135bd5 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -518,6 +518,7 @@ void Sprite3D::set_region(bool p_region) { region = p_region; _queue_update(); + notify_property_list_changed(); } bool Sprite3D::is_region() const { @@ -623,6 +624,10 @@ void Sprite3D::_validate_property(PropertyInfo &property) const { if (property.name == "frame_coords") { property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } + + if (!region && property.name == "region_rect") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } } void Sprite3D::_bind_methods() { diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index 0d25e2f21f..8b774444b9 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -407,7 +407,7 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) { PhysicsDirectSpaceState3D *ss = s->get_space_state(); - bool col = ss->intersect_ray(source, target, rr, exclude); + bool col = ss->intersect_ray(source, target, rr, exclude, get_collision_mask()); wheel.m_raycastInfo.m_groundObject = nullptr; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 9b98f3d031..eb35979a47 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -869,8 +869,21 @@ void Tween::start() { return; } + pending_update++; + for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { + InterpolateData &data = E->get(); + data.active = true; + } + pending_update--; + // We want to be activated set_active(true); + + // Don't resume from current position if stop_all() function has been used + if (was_stopped) { + seek(0); + } + was_stopped = false; } void Tween::reset(Object *p_object, StringName p_key) { @@ -939,7 +952,7 @@ void Tween::stop(Object *p_object, StringName p_key) { void Tween::stop_all() { // We no longer need to be active since all tweens have been stopped set_active(false); - + was_stopped = true; // For each interpolation... pending_update++; for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 88c02be0bc..142c0c65e0 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -107,6 +107,7 @@ private: float speed_scale = 1.0; mutable int pending_update = 0; int uid = 0; + bool was_stopped = false; List<InterpolateData> interpolates; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index e8586b72e9..bddbe30f53 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -113,6 +113,24 @@ void ColorPicker::_update_controls() { btn_hsv->set_disabled(false); } + if (raw_mode_enabled) { + for (int i = 0; i < 3; i++) { + scroll[i]->add_theme_icon_override("grabber", Ref<Texture2D>()); + scroll[i]->add_theme_icon_override("grabber_highlight", Ref<Texture2D>()); + scroll[i]->add_theme_style_override("slider", Ref<StyleBox>()); + scroll[i]->add_theme_style_override("grabber_area", Ref<StyleBox>()); + scroll[i]->add_theme_style_override("grabber_area_highlight", Ref<StyleBox>()); + } + } else { + for (int i = 0; i < 3; i++) { + scroll[i]->add_theme_icon_override("grabber", get_theme_icon("bar_arrow")); + scroll[i]->add_theme_icon_override("grabber_highlight", get_theme_icon("bar_arrow")); + scroll[i]->add_theme_style_override("slider", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); + scroll[i]->add_theme_style_override("grabber_area", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); + scroll[i]->add_theme_style_override("grabber_area_highlight", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); + } + } + if (edit_alpha) { values[3]->show(); scroll[3]->show(); @@ -243,6 +261,9 @@ void ColorPicker::_update_color(bool p_update_sliders) { sample->update(); uv_edit->update(); w_edit->update(); + for (int i = 0; i < 4; i++) { + scroll[i]->update(); + } updating = false; } @@ -456,6 +477,69 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { } } +void ColorPicker::_slider_draw(int p_which) { + Vector<Vector2> pos; + pos.resize(4); + Vector<Color> col; + col.resize(4); + Size2 size = scroll[p_which]->get_size(); + Color left_color; + Color right_color; +#ifdef TOOLS_ENABLED + const real_t margin = 4 * EDSCALE; +#else + const real_t margin = 4; +#endif + + if (p_which == 3) { + scroll[p_which]->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), Rect2(Point2(0, margin), Size2(size.x, margin)), true); + + left_color = color; + left_color.a = 0; + right_color = color; + right_color.a = 1; + } else { + if (raw_mode_enabled) { + return; + } + if (hsv_mode_enabled) { + if (p_which == 0) { + Ref<Texture2D> hue = get_theme_icon("color_hue", "ColorPicker"); + scroll[p_which]->draw_set_transform(Point2(), -Math_PI / 2, Size2(1.0, 1.0)); + scroll[p_which]->draw_texture_rect(hue, Rect2(Vector2(margin * -2, 0), Vector2(scroll[p_which]->get_size().x, margin)), false, Color(1, 1, 1), true); + return; + } + Color s_col; + Color v_col; + s_col.set_hsv(h, 0, v); + left_color = (p_which == 1) ? s_col : Color(0, 0, 0); + s_col.set_hsv(h, 1, v); + v_col.set_hsv(h, s, 1); + right_color = (p_which == 1) ? s_col : v_col; + } else { + left_color = Color( + p_which == 0 ? 0 : color.r, + p_which == 1 ? 0 : color.g, + p_which == 2 ? 0 : color.b); + right_color = Color( + p_which == 0 ? 1 : color.r, + p_which == 1 ? 1 : color.g, + p_which == 2 ? 1 : color.b); + } + } + + col.set(0, left_color); + col.set(1, right_color); + col.set(2, right_color); + col.set(3, left_color); + pos.set(0, Vector2(0, margin)); + pos.set(1, Vector2(size.x, margin)); + pos.set(2, Vector2(size.x, margin * 2)); + pos.set(3, Vector2(0, margin * 2)); + + scroll[p_which]->draw_polygon(pos, col); +} + void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> bev = p_event; @@ -799,10 +883,16 @@ ColorPicker::ColorPicker() : scroll[i]->set_h_size_flags(SIZE_EXPAND_FILL); scroll[i]->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed)); + scroll[i]->connect("draw", callable_mp(this, &ColorPicker::_slider_draw), make_binds(i)); vbr->add_child(hbc); } labels[3]->set_text("A"); + scroll[3]->add_theme_icon_override("grabber", get_theme_icon("bar_arrow")); + scroll[3]->add_theme_icon_override("grabber_highlight", get_theme_icon("bar_arrow")); + scroll[3]->add_theme_style_override("slider", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); + scroll[3]->add_theme_style_override("grabber_area", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); + scroll[3]->add_theme_style_override("grabber_area_highlight", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); HBoxContainer *hhb = memnew(HBoxContainer); vbr->add_child(hhb); diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 7915527bc0..24e1746c41 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -91,6 +91,7 @@ private: void _text_type_toggled(); void _sample_draw(); void _hsv_draw(int p_which, Control *c); + void _slider_draw(int p_which); void _uv_input(const Ref<InputEvent> &p_event); void _w_input(const Ref<InputEvent> &p_event); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0c104bf318..bff3024e38 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -93,7 +93,7 @@ void Control::_edit_set_state(const Dictionary &p_state) { void Control::_edit_set_position(const Point2 &p_position) { #ifdef TOOLS_ENABLED - set_position(p_position, CanvasItemEditor::get_singleton()->is_anchors_mode_enabled()); + set_position(p_position, CanvasItemEditor::get_singleton()->is_anchors_mode_enabled() && Object::cast_to<Control>(data.parent)); #else // Unlikely to happen. TODO: enclose all _edit_ functions into TOOLS_ENABLED set_position(p_position); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 9c8669fff0..331f0380c5 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1558,7 +1558,12 @@ bool GraphEdit::is_minimap_enabled() const { } void GraphEdit::_minimap_toggled() { - minimap->update(); + if (is_minimap_enabled()) { + minimap->set_visible(true); + minimap->update(); + } else { + minimap->set_visible(false); + } } void GraphEdit::set_connection_lines_thickness(float p_thickness) { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index b98caf3562..be73fd8f51 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -260,7 +260,8 @@ void Label::_notification(int p_what) { } } } - visible_glyphs = total_glyphs * percent_visible; + + visible_glyphs = MIN(total_glyphs, visible_chars); } Vector2 ofs; @@ -541,6 +542,8 @@ void Label::set_visible_characters(int p_amount) { visible_chars = p_amount; if (get_total_character_count() > 0) { percent_visible = (float)p_amount / (float)get_total_character_count(); + } else { + percent_visible = 1.0; } update(); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ba08aae8e3..830ffc092f 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -255,11 +255,30 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { selection.creating = true; } else { - if (b->is_doubleclick() && selecting_enabled) { - selection.enabled = true; - selection.begin = 0; - selection.end = text.length(); - selection.doubleclick = true; + if (selecting_enabled) { + if (!b->is_doubleclick() && (OS::get_singleton()->get_ticks_msec() - selection.last_dblclk) < 600) { + // Triple-click select all. + selection.enabled = true; + selection.begin = 0; + selection.end = text.length(); + selection.doubleclick = true; + selection.last_dblclk = 0; + cursor_pos = selection.begin; + } else if (b->is_doubleclick()) { + // Double-click select word. + Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text_rid); + for (int i = 0; i < words.size(); i++) { + if (words[i].x < cursor_pos && words[i].y > cursor_pos) { + selection.enabled = true; + selection.begin = words[i].x; + selection.end = words[i].y; + selection.doubleclick = true; + selection.last_dblclk = OS::get_singleton()->get_ticks_msec(); + cursor_pos = selection.end; + break; + } + } + } } selection.drag_attempt = false; @@ -1135,6 +1154,8 @@ void LineEdit::cursor_set_blink_enabled(const bool p_enabled) { } draw_caret = true; + + notify_property_list_changed(); } bool LineEdit::cursor_get_force_displayed() const { @@ -2056,6 +2077,12 @@ void LineEdit::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); } +void LineEdit::_validate_property(PropertyInfo &property) const { + if (!caret_blink_enabled && property.name == "caret_blink_speed") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index cbadf818cd..ef36377f2e 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -136,6 +136,7 @@ private: bool creating = false; bool doubleclick = false; bool drag_attempt = false; + uint64_t last_dblclk = 0; } selection; struct TextOperation { @@ -197,15 +198,15 @@ private: void _backspace(bool p_word = false, bool p_all_to_left = false); void _delete(bool p_word = false, bool p_all_to_right = false); - void _gui_input(Ref<InputEvent> p_event); - void _notification(int p_what); - protected: + void _notification(int p_what); static void _bind_methods(); + void _gui_input(Ref<InputEvent> p_event); bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; + void _validate_property(PropertyInfo &property) const override; public: void set_align(Align p_align); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 682584d73f..ed319f9fd0 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -3634,6 +3634,7 @@ void RichTextLabel::set_use_bbcode(bool p_enable) { } use_bbcode = p_enable; set_bbcode(bbcode); + notify_property_list_changed(); } bool RichTextLabel::is_using_bbcode() const { @@ -3771,6 +3772,12 @@ int RichTextLabel::get_content_height() const { return total_height; } +void RichTextLabel::_validate_property(PropertyInfo &property) const { + if (!use_bbcode && property.name == "bbcode_text") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input); ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 2351aff0a4..e3e457d1f2 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -81,7 +81,9 @@ public: }; protected: + void _notification(int p_what); static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; private: struct Item; @@ -441,9 +443,6 @@ private: bool fit_content_height = false; -protected: - void _notification(int p_what); - public: String get_text(); void add_text(const String &p_text); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 2c9720e4b6..d82cc98e01 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -91,6 +91,14 @@ void SpinBox::_range_click_timeout() { } } +void SpinBox::_release_mouse() { + if (drag.enabled) { + drag.enabled = false; + Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); + warp_mouse(drag.capture_pos); + } +} + void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { if (!is_editable()) { return; @@ -136,12 +144,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { //set_default_cursor_shape(CURSOR_ARROW); range_click_timer->stop(); - - if (drag.enabled) { - drag.enabled = false; - Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); - warp_mouse(drag.capture_pos); - } + _release_mouse(); drag.allowed = false; } @@ -199,6 +202,8 @@ void SpinBox::_notification(int p_what) { } else if (p_what == NOTIFICATION_ENTER_TREE) { _adjust_width_for_icon(get_theme_icon("updown")); _value_changed(0); + } else if (p_what == NOTIFICATION_EXIT_TREE) { + _release_mouse(); } else if (p_what == NOTIFICATION_TRANSLATION_CHANGED) { _value_changed(0); } else if (p_what == NOTIFICATION_THEME_CHANGED) { diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 4c3adf30e8..e116adb64c 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -43,6 +43,7 @@ class SpinBox : public Range { Timer *range_click_timer; void _range_click_timeout(); + void _release_mouse(); void _text_entered(const String &p_string); virtual void _value_changed(double) override; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 36aa18417d..e488e7a914 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -412,25 +412,16 @@ void TextEdit::_update_selection_mode_word() { _get_mouse_pos(Point2i(mp.x, mp.y), row, col); String line = text[row]; - int beg = CLAMP(col, 0, line.length()); - // If its the first selection and on whitespace make sure we grab the word instead. - if (!selection.active) { - while (beg > 0 && line[beg] <= 32) { - beg--; - } - } + int cursor_pos = CLAMP(col, 0, line.length()); + int beg = cursor_pos; int end = beg; - bool symbol = beg < line.length() && _is_symbol(line[beg]); - - // Get the word end and begin points. - while (beg > 0 && line[beg - 1] > 32 && (symbol == _is_symbol(line[beg - 1]))) { - beg--; - } - while (end < line.length() && line[end + 1] > 32 && (symbol == _is_symbol(line[end + 1]))) { - end++; - } - if (end < line.length()) { - end += 1; + Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text.get_line_data(row)->get_rid()); + for (int i = 0; i < words.size(); i++) { + if (words[i].x < cursor_pos && words[i].y > cursor_pos) { + beg = words[i].x; + end = words[i].y; + break; + } } // Initial selection. @@ -2199,9 +2190,14 @@ void TextEdit::_new_line(bool p_split_current_line, bool p_above) { // No need to move the brace below if we are not taking the text with us. char32_t closing_char = _get_right_pair_symbol(indent_char); - if ((closing_char != 0) && (closing_char == text[cursor.line][cursor.column]) && !p_split_current_line) { - brace_indent = true; - ins += "\n" + ins.substr(1, ins.length() - 2); + if ((closing_char != 0) && (closing_char == text[cursor.line][cursor.column])) { + if (p_split_current_line) { + brace_indent = true; + ins += "\n" + ins.substr(1, ins.length() - 2); + } else { + brace_indent = false; + ins = "\n" + ins.substr(1, ins.length() - 2); + } } } } @@ -2993,8 +2989,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else { if (cursor.line < selection.selecting_line || (cursor.line == selection.selecting_line && cursor.column < selection.selecting_column)) { if (selection.shiftclick_left) { - SWAP(selection.from_column, selection.to_column); - SWAP(selection.from_line, selection.to_line); selection.shiftclick_left = !selection.shiftclick_left; } selection.from_column = cursor.column; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 17fe001b5d..6ac4d7fd2f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3354,10 +3354,10 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { void Tree::item_deselected(int p_column, TreeItem *p_item) { if (selected_item == p_item) { selected_item = nullptr; - } - if (selected_col == p_column) { - selected_col = -1; + if (selected_col == p_column) { + selected_col = -1; + } } if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) { diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 91daa08ff8..85d7edd64b 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -231,6 +231,7 @@ void CanvasLayer::set_follow_viewport(bool p_enable) { follow_viewport = p_enable; _update_follow_viewport(); + notify_property_list_changed(); } bool CanvasLayer::is_following_viewport() const { @@ -257,6 +258,12 @@ void CanvasLayer::_update_follow_viewport(bool p_force_exit) { } } +void CanvasLayer::_validate_property(PropertyInfo &property) const { + if (!follow_viewport && property.name == "follow_viewport_scale") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void CanvasLayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_layer", "layer"), &CanvasLayer::set_layer); ClassDB::bind_method(D_METHOD("get_layer"), &CanvasLayer::get_layer); diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index 181d1dd659..899039340a 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -64,6 +64,7 @@ class CanvasLayer : public Node { protected: void _notification(int p_what); static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: void set_layer(int p_xform); diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 77bdf09426..71c372aec2 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -387,6 +387,9 @@ bool HTTPRequest::_update_connection() { } client->poll(); + if (client->get_status() != HTTPClient::STATUS_BODY) { + return false; + } PackedByteArray chunk = client->read_response_body_chunk(); downloaded.add(chunk.size()); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index be3e3a5637..4c6bcb10b2 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1021,22 +1021,8 @@ void Node::_set_name_nocheck(const StringName &p_name) { data.name = p_name; } -String Node::invalid_character = ". : @ / \""; - -bool Node::_validate_node_name(String &p_name) { - String name = p_name; - Vector<String> chars = Node::invalid_character.split(" "); - for (int i = 0; i < chars.size(); i++) { - name = name.replace(chars[i], ""); - } - bool is_valid = name == p_name; - p_name = name; - return is_valid; -} - void Node::set_name(const String &p_name) { - String name = p_name; - _validate_node_name(name); + String name = p_name.validate_node_name(); ERR_FAIL_COND(name == ""); data.name = name; @@ -2275,74 +2261,6 @@ void Node::remap_nested_resources(RES p_resource, const Map<RES, RES> &p_resourc } #endif -void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const { - if (get_owner() != get_parent()->get_owner()) { - return; - } - - Node *node = nullptr; - - if (get_filename() != "") { - Ref<PackedScene> res = ResourceLoader::load(get_filename()); - ERR_FAIL_COND_MSG(res.is_null(), "Cannot load scene: " + get_filename()); - node = res->instance(); - ERR_FAIL_COND(!node); - } else { - Object *obj = ClassDB::instance(get_class()); - ERR_FAIL_COND_MSG(!obj, "Node: Could not duplicate: " + String(get_class()) + "."); - node = Object::cast_to<Node>(obj); - if (!node) { - memdelete(obj); - ERR_FAIL_MSG("Node: Could not duplicate: " + String(get_class()) + "."); - } - } - - List<PropertyInfo> plist; - - get_property_list(&plist); - - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { - continue; - } - String name = E->get().name; - - Variant value = get(name).duplicate(true); - - node->set(name, value); - } - - List<GroupInfo> groups; - get_groups(&groups); - - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - node->add_to_group(E->get().name, E->get().persistent); - } - - node->set_name(get_name()); - p_new_parent->add_child(node); - - Node *owner = get_owner(); - - if (p_reown_map.has(owner)) { - owner = p_reown_map[owner]; - } - - if (owner) { - NodePath p = get_path_to(owner); - if (owner != this) { - Node *new_owner = node->get_node(p); - if (new_owner) { - node->set_owner(new_owner); - } - } - } - - for (int i = 0; i < get_child_count(); i++) { - get_child(i)->_duplicate_and_reown(node, p_reown_map); - } -} - // Duplication of signals must happen after all the node descendants have been copied, // because re-targeting of connections from some descendant to another is not possible // if the emitter node comes later in tree order than the receiver @@ -2397,49 +2315,6 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { } } -Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const { - ERR_FAIL_COND_V(get_filename() != "", nullptr); - - Object *obj = ClassDB::instance(get_class()); - ERR_FAIL_COND_V_MSG(!obj, nullptr, "Node: Could not duplicate: " + String(get_class()) + "."); - - Node *node = Object::cast_to<Node>(obj); - if (!node) { - memdelete(obj); - ERR_FAIL_V_MSG(nullptr, "Node: Could not duplicate: " + String(get_class()) + "."); - } - node->set_name(get_name()); - - List<PropertyInfo> plist; - - get_property_list(&plist); - - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { - continue; - } - String name = E->get().name; - node->set(name, get(name)); - } - - List<GroupInfo> groups; - get_groups(&groups); - - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - node->add_to_group(E->get().name, E->get().persistent); - } - - for (int i = 0; i < get_child_count(); i++) { - get_child(i)->_duplicate_and_reown(node, p_reown_map); - } - - // Duplication of signals must happen after all the node descendants have been copied, - // because re-targeting of connections from some descendant to another is not possible - // if the emitter node comes later in tree order than the receiver - _duplicate_signals(this, node); - return node; -} - static void find_owned_by(Node *p_by, Node *p_node, List<Node *> *p_owned) { if (p_node->get_owner() == p_by) { p_owned->push_back(p_node); diff --git a/scene/main/node.h b/scene/main/node.h index 249a0ff86e..b1e51d2aee 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -173,7 +173,6 @@ private: Array _get_node_and_resource(const NodePath &p_path); void _duplicate_signals(const Node *p_original, Node *p_copy) const; - void _duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const; Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = nullptr) const; TypedArray<Node> _get_children() const; @@ -191,12 +190,6 @@ private: _FORCE_INLINE_ bool _can_process(bool p_paused) const; -#ifdef TOOLS_ENABLED - friend class SceneTreeEditor; -#endif - static String invalid_character; - static bool _validate_node_name(String &p_name); - protected: void _block() { data.blocked++; } void _unblock() { data.blocked--; } @@ -366,7 +359,6 @@ public: bool is_processing_unhandled_key_input() const; Node *duplicate(int p_flags = DUPLICATE_GROUPS | DUPLICATE_SIGNALS | DUPLICATE_SCRIPTS) const; - Node *duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const; #ifdef TOOLS_ENABLED Node *duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const; Node *duplicate_from_editor(Map<const Node *, Node *> &r_duplimap, const Map<RES, RES> &p_resource_remap) const; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 8198fa41c5..d697a1a5dd 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -826,6 +826,9 @@ bool Window::is_using_font_oversampling() const { } DisplayServer::WindowID Window::get_window_id() const { + if (embedder) { + return parent->get_window_id(); + } return window_id; } @@ -1035,6 +1038,9 @@ void Window::popup_centered_ratio(float p_ratio) { void Window::popup(const Rect2i &p_screen_rect) { emit_signal("about_to_popup"); + // Update window size to calculate the actual window size based on contents minimum size and minimum size. + _update_window_size(); + if (p_screen_rect != Rect2i()) { set_position(p_screen_rect.position); set_size(p_screen_rect.size); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 51d4643883..fe8591e3d9 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -50,7 +50,6 @@ #include "scene/2d/line_2d.h" #include "scene/2d/mesh_instance_2d.h" #include "scene/2d/multimesh_instance_2d.h" -#include "scene/2d/navigation_2d.h" #include "scene/2d/navigation_agent_2d.h" #include "scene/2d/navigation_obstacle_2d.h" #include "scene/2d/parallax_background.h" @@ -206,7 +205,6 @@ #include "scene/3d/listener_3d.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/multimesh_instance_3d.h" -#include "scene/3d/navigation_3d.h" #include "scene/3d/navigation_agent_3d.h" #include "scene/3d/navigation_obstacle_3d.h" #include "scene/3d/navigation_region_3d.h" @@ -516,7 +514,6 @@ void register_scene_types() { ClassDB::register_class<ConeTwistJoint3D>(); ClassDB::register_class<Generic6DOFJoint3D>(); - ClassDB::register_class<Navigation3D>(); ClassDB::register_class<NavigationRegion3D>(); ClassDB::register_class<NavigationAgent3D>(); ClassDB::register_class<NavigationObstacle3D>(); @@ -793,7 +790,6 @@ void register_scene_types() { ClassDB::register_class<PathFollow2D>(); ClassDB::register_class<NavigationMesh>(); - ClassDB::register_class<Navigation2D>(); ClassDB::register_class<NavigationPolygon>(); ClassDB::register_class<NavigationRegion2D>(); ClassDB::register_class<NavigationAgent2D>(); @@ -814,6 +810,8 @@ void register_scene_types() { ClassDB::add_compatibility_class("DynamicFont", "Font"); ClassDB::add_compatibility_class("DynamicFontData", "FontData"); ClassDB::add_compatibility_class("ToolButton", "Button"); + ClassDB::add_compatibility_class("Navigation3D", "Node3D"); + ClassDB::add_compatibility_class("Navigation2D", "Node2D"); // Renamed in 4.0. // Keep alphabetical ordering to easily locate classes and avoid duplicates. @@ -865,7 +863,6 @@ void register_scene_types() { ClassDB::add_compatibility_class("Listener", "Listener3D"); ClassDB::add_compatibility_class("MeshInstance", "MeshInstance3D"); ClassDB::add_compatibility_class("MultiMeshInstance", "MultiMeshInstance3D"); - ClassDB::add_compatibility_class("Navigation", "Navigation3D"); ClassDB::add_compatibility_class("NavigationAgent", "NavigationAgent3D"); ClassDB::add_compatibility_class("NavigationMeshInstance", "NavigationRegion3D"); ClassDB::add_compatibility_class("NavigationObstacle", "NavigationObstacle3D"); @@ -950,8 +947,10 @@ void register_scene_types() { for (int i = 0; i < 20; i++) { GLOBAL_DEF_BASIC(vformat("layer_names/2d_render/layer_%d", i), ""); GLOBAL_DEF_BASIC(vformat("layer_names/2d_physics/layer_%d", i), ""); + GLOBAL_DEF_BASIC(vformat("layer_names/2d_navigation/layer_%d", i), ""); GLOBAL_DEF_BASIC(vformat("layer_names/3d_render/layer_%d", i), ""); GLOBAL_DEF_BASIC(vformat("layer_names/3d_physics/layer_%d", i), ""); + GLOBAL_DEF_BASIC(vformat("layer_names/3d_navigation/layer_%d", i), ""); } bool default_theme_hidpi = GLOBAL_DEF("gui/theme/use_hidpi", false); diff --git a/scene/resources/animation.h b/scene/resources/animation.h index fd22cc445c..66bc71c834 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -70,7 +70,7 @@ private: bool loop_wrap = true; NodePath path; // path to something bool imported = false; - bool enabled = false; + bool enabled = true; Track() {} virtual ~Track() {} }; diff --git a/scene/resources/camera_effects.cpp b/scene/resources/camera_effects.cpp index 4038338e1e..34c6bc05bc 100644 --- a/scene/resources/camera_effects.cpp +++ b/scene/resources/camera_effects.cpp @@ -120,6 +120,7 @@ void CameraEffects::_update_dof_blur() { void CameraEffects::set_override_exposure_enabled(bool p_enabled) { override_exposure_enabled = p_enabled; _update_override_exposure(); + notify_property_list_changed(); } bool CameraEffects::is_override_exposure_enabled() const { @@ -144,6 +145,14 @@ void CameraEffects::_update_override_exposure() { // Private methods, constructor and destructor +void CameraEffects::_validate_property(PropertyInfo &property) const { + if ((!dof_blur_far_enabled && (property.name == "dof_blur_far_distance" || property.name == "dof_blur_far_transition")) || + (!dof_blur_near_enabled && (property.name == "dof_blur_near_distance" || property.name == "dof_blur_near_transition")) || + (!override_exposure_enabled && property.name == "override_exposure")) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void CameraEffects::_bind_methods() { // DOF blur diff --git a/scene/resources/camera_effects.h b/scene/resources/camera_effects.h index 28aa6b8660..b9338f4806 100644 --- a/scene/resources/camera_effects.h +++ b/scene/resources/camera_effects.h @@ -59,6 +59,7 @@ private: protected: static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: virtual RID get_rid() const override; diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index d331f83daf..6e56f6e7fc 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -72,6 +72,10 @@ void ConvexPolygonShape2D::_bind_methods() { } void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) { + if (points.size() < 3) { + return; + } + Vector<Color> col; col.push_back(p_color); RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); diff --git a/scene/resources/default_theme/bar_arrow.png b/scene/resources/default_theme/bar_arrow.png Binary files differnew file mode 100644 index 0000000000..7cf146b8da --- /dev/null +++ b/scene/resources/default_theme/bar_arrow.png diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index a94209c75f..0c661cc17d 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -884,6 +884,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_icon("color_sample", "ColorPicker", make_icon(color_picker_sample_png)); theme->set_icon("preset_bg", "ColorPicker", make_icon(mini_checkerboard_png)); theme->set_icon("overbright_indicator", "ColorPicker", make_icon(overbright_indicator_png)); + theme->set_icon("bar_arrow", "ColorPicker", make_icon(bar_arrow_png)); theme->set_icon("bg", "ColorPickerButton", make_icon(mini_checkerboard_png)); @@ -1017,7 +1018,7 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) { Ref<StyleBox> default_style; Ref<Texture2D> default_icon; Ref<Font> default_font; - int default_font_size = 16; + int default_font_size = 14; if (p_font.is_valid()) { default_font = p_font; } else if (p_hidpi) { diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index b905c9db69..6b78ba7933 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -14,6 +14,10 @@ static const unsigned char arrow_right_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x4, 0x0, 0x0, 0x0, 0xfc, 0x7c, 0x94, 0x6c, 0x0, 0x0, 0x0, 0x2e, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0x20, 0x17, 0x3c, 0xf8, 0xf, 0x82, 0xf7, 0x13, 0x70, 0x48, 0x3c, 0xf8, 0xf2, 0x50, 0x1b, 0x43, 0x2, 0xa, 0xaf, 0xbe, 0xe0, 0xc6, 0x2e, 0xf1, 0xff, 0xe1, 0x7c, 0x12, 0x24, 0x10, 0x46, 0x11, 0xb6, 0x1c, 0xe1, 0x5c, 0xa, 0x0, 0x0, 0xe0, 0x14, 0x48, 0xb1, 0x3d, 0x1b, 0x7a, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; +static const unsigned char bar_arrow_png[] = { + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x14, 0x8, 0x4, 0x0, 0x0, 0x0, 0x2e, 0x6b, 0x75, 0xfc, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x1, 0x73, 0x52, 0x47, 0x42, 0x0, 0xae, 0xce, 0x1c, 0xe9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xe, 0xc0, 0x0, 0x0, 0xe, 0xc0, 0x1, 0x6a, 0xd6, 0x89, 0x9, 0x0, 0x0, 0x0, 0x65, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0xfc, 0xcf, 0x80, 0x1f, 0x30, 0x8e, 0x20, 0x5, 0x8c, 0x38, 0x24, 0xff, 0x53, 0x5f, 0xc1, 0xb, 0xee, 0x9f, 0x53, 0x18, 0x18, 0xd8, 0x73, 0x24, 0xbe, 0x62, 0x55, 0x70, 0x5f, 0x83, 0x61, 0x15, 0xa3, 0x2e, 0x3, 0x3, 0xc3, 0xd, 0xe6, 0x30, 0xd9, 0xcb, 0x18, 0xa, 0x1e, 0xc6, 0xfd, 0x9f, 0xc6, 0xc0, 0xd, 0x35, 0xea, 0x3b, 0x63, 0x81, 0xfc, 0x2c, 0x14, 0x5, 0xf, 0x2a, 0x18, 0xda, 0xd1, 0x1c, 0x50, 0xa9, 0xd0, 0x1, 0x57, 0xf0, 0x10, 0x53, 0x9a, 0x81, 0x81, 0x81, 0xa1, 0x52, 0xbe, 0x83, 0x81, 0x81, 0xf1, 0x3f, 0x2e, 0x69, 0xa8, 0x12, 0x3a, 0x4, 0x14, 0x0, 0x7b, 0xda, 0x34, 0x1, 0xbb, 0xb5, 0x3e, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; + static const unsigned char bookmark_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x6, 0x0, 0x0, 0x0, 0x1f, 0xf3, 0xff, 0x61, 0x0, 0x0, 0x0, 0x4, 0x73, 0x42, 0x49, 0x54, 0x8, 0x8, 0x8, 0x8, 0x7c, 0x8, 0x64, 0x88, 0x0, 0x0, 0x0, 0x57, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xed, 0x93, 0x31, 0xa, 0xc0, 0x30, 0xc, 0x3, 0xa5, 0xd0, 0xff, 0x7f, 0x59, 0x1d, 0x8a, 0x42, 0x8, 0x9, 0x95, 0xc9, 0xd2, 0xa1, 0x9a, 0x8c, 0xf1, 0xdd, 0x62, 0x1b, 0x38, 0xc, 0x87, 0x5a, 0x5, 0xae, 0x79, 0xde, 0x2, 0x1, 0x80, 0x94, 0x39, 0x48, 0x76, 0x49, 0x17, 0xa4, 0xf0, 0x24, 0x61, 0x2b, 0x51, 0x8b, 0xfc, 0x82, 0xcf, 0xb, 0x48, 0x7a, 0xdf, 0x75, 0x81, 0xf, 0xe5, 0x29, 0xf7, 0x92, 0x6b, 0x3, 0x1a, 0x1e, 0xda, 0x7c, 0x3d, 0x77, 0x21, 0x7b, 0xa8, 0x74, 0x2e, 0xcb, 0xd, 0xc8, 0x75, 0x13, 0x28, 0x9, 0xed, 0xc2, 0xc8, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 6f6af93848..c04b271d81 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -441,6 +441,7 @@ void Environment::_update_ssao() { void Environment::set_sdfgi_enabled(bool p_enabled) { sdfgi_enabled = p_enabled; _update_sdfgi(); + notify_property_list_changed(); } bool Environment::is_sdfgi_enabled() const { @@ -983,6 +984,7 @@ void Environment::_validate_property(PropertyInfo &property) const { "auto_exposure_", "ss_reflections_", "ssao_", + "sdfgi_", "glow_", "adjustment_", nullptr diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 062d921855..9931757cc4 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1584,7 +1584,7 @@ void BaseMaterial3D::set_flag(Flags p_flag, bool p_enabled) { } flags[p_flag] = p_enabled; - if (p_flag == FLAG_USE_SHADOW_TO_OPACITY || p_flag == FLAG_USE_TEXTURE_REPEAT || p_flag == FLAG_SUBSURFACE_MODE_SKIN) { + if (p_flag == FLAG_USE_SHADOW_TO_OPACITY || p_flag == FLAG_USE_TEXTURE_REPEAT || p_flag == FLAG_SUBSURFACE_MODE_SKIN || p_flag == FLAG_USE_POINT_SIZE) { notify_property_list_changed(); } _queue_shader_change(); @@ -1650,7 +1650,7 @@ BaseMaterial3D::TextureFilter BaseMaterial3D::get_texture_filter() const { void BaseMaterial3D::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { if (property.name.begins_with(text) && property.name != text + "_enabled" && !features[feature]) { - property.usage = 0; + property.usage = PROPERTY_USAGE_NOEDITOR; } } @@ -1683,16 +1683,24 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const { property.usage = 0; } - if (property.name == "params_grow_amount" && !grow_enabled) { - property.usage = 0; + if (property.name == "billboard_keep_scale" && billboard_mode == BILLBOARD_DISABLED) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } + + if (property.name == "grow_amount" && !grow_enabled) { + property.usage = PROPERTY_USAGE_NOEDITOR; + } + + if (property.name == "point_size" && !flags[FLAG_USE_POINT_SIZE]) { + property.usage = PROPERTY_USAGE_NOEDITOR; } if (property.name == "proximity_fade_distance" && !proximity_fade_enabled) { - property.usage = 0; + property.usage = PROPERTY_USAGE_NOEDITOR; } if ((property.name == "distance_fade_max_distance" || property.name == "distance_fade_min_distance") && distance_fade == DISTANCE_FADE_DISABLED) { - property.usage = 0; + property.usage = PROPERTY_USAGE_NOEDITOR; } // you can only enable anti-aliasing (in mataerials) on alpha scissor and alpha hash diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp index 84f3c23f77..8c12f59a00 100644 --- a/scene/resources/navigation_mesh.cpp +++ b/scene/resources/navigation_mesh.cpp @@ -31,6 +31,8 @@ #include "navigation_mesh.h" void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) { + ERR_FAIL_COND(p_mesh.is_null()); + vertices = Vector<Vector3>(); clear_polygons(); diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 9b80224c3f..2159f1bc97 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -460,6 +460,7 @@ Point2 StyleBoxFlat::get_shadow_offset() const { void StyleBoxFlat::set_anti_aliased(const bool &p_anti_aliased) { anti_aliased = p_anti_aliased; emit_changed(); + notify_property_list_changed(); } bool StyleBoxFlat::is_anti_aliased() const { @@ -781,6 +782,12 @@ float StyleBoxFlat::get_style_margin(Side p_side) const { return border_width[p_side]; } +void StyleBoxFlat::_validate_property(PropertyInfo &property) const { + if (!anti_aliased && property.name == "anti_aliasing_size") { + property.usage = PROPERTY_USAGE_NOEDITOR; + } +} + void StyleBoxFlat::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &StyleBoxFlat::set_bg_color); ClassDB::bind_method(D_METHOD("get_bg_color"), &StyleBoxFlat::get_bg_color); diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 8a273afbfd..dd5c873a00 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -159,6 +159,7 @@ class StyleBoxFlat : public StyleBox { protected: virtual float get_style_margin(Side p_side) const override; static void _bind_methods(); + void _validate_property(PropertyInfo &property) const override; public: //Color diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 8cccf81659..d2bb1338d8 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -151,7 +151,7 @@ void ImageTexture::_reload_hook(const RID &p_hook) { } void ImageTexture::create_from_image(const Ref<Image> &p_image) { - ERR_FAIL_COND_MSG(p_image.is_null(), "Invalid image"); + ERR_FAIL_COND_MSG(p_image.is_null() || p_image->is_empty(), "Invalid image"); w = p_image->get_width(); h = p_image->get_height(); format = p_image->get_format(); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index d6200059f6..a99c09e89c 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -2742,8 +2742,6 @@ int VisualShaderNodeClamp::get_input_port_count() const { VisualShaderNodeClamp::PortType VisualShaderNodeClamp::get_input_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_FLOAT: - return PORT_TYPE_SCALAR; case OP_TYPE_INT: return PORT_TYPE_SCALAR_INT; case OP_TYPE_VECTOR: @@ -2771,8 +2769,6 @@ int VisualShaderNodeClamp::get_output_port_count() const { VisualShaderNodeClamp::PortType VisualShaderNodeClamp::get_output_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_FLOAT: - return PORT_TYPE_SCALAR; case OP_TYPE_INT: return PORT_TYPE_SCALAR_INT; case OP_TYPE_VECTOR: @@ -2954,18 +2950,11 @@ int VisualShaderNodeStep::get_input_port_count() const { VisualShaderNodeStep::PortType VisualShaderNodeStep::get_input_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_SCALAR: - return PORT_TYPE_SCALAR; case OP_TYPE_VECTOR: return PORT_TYPE_VECTOR; case OP_TYPE_VECTOR_SCALAR: - switch (p_port) { - case 0: - return PORT_TYPE_SCALAR; - case 1: - return PORT_TYPE_VECTOR; - default: - break; + if (p_port == 1) { + return PORT_TYPE_VECTOR; } break; default: @@ -2989,8 +2978,6 @@ int VisualShaderNodeStep::get_output_port_count() const { VisualShaderNodeStep::PortType VisualShaderNodeStep::get_output_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_SCALAR: - return PORT_TYPE_SCALAR; case OP_TYPE_VECTOR: return PORT_TYPE_VECTOR; case OP_TYPE_VECTOR_SCALAR: @@ -3032,7 +3019,7 @@ void VisualShaderNodeStep::set_op_type(OpType p_op_type) { set_input_port_default_value(0, 0.0); // edge } if (op_type == OP_TYPE_SCALAR) { - set_input_port_default_value(1, 0.0); // x + set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0)); // x } break; default: @@ -3085,20 +3072,11 @@ int VisualShaderNodeSmoothStep::get_input_port_count() const { VisualShaderNodeSmoothStep::PortType VisualShaderNodeSmoothStep::get_input_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_SCALAR: - return PORT_TYPE_SCALAR; case OP_TYPE_VECTOR: return PORT_TYPE_VECTOR; case OP_TYPE_VECTOR_SCALAR: - switch (p_port) { - case 0: - return PORT_TYPE_SCALAR; // edge0 - case 1: - return PORT_TYPE_SCALAR; // edge1 - case 2: - return PORT_TYPE_VECTOR; // x - default: - break; + if (p_port == 2) { + return PORT_TYPE_VECTOR; // x } break; default: @@ -3124,8 +3102,6 @@ int VisualShaderNodeSmoothStep::get_output_port_count() const { VisualShaderNodeSmoothStep::PortType VisualShaderNodeSmoothStep::get_output_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_SCALAR: - return PORT_TYPE_SCALAR; case OP_TYPE_VECTOR: return PORT_TYPE_VECTOR; case OP_TYPE_VECTOR_SCALAR: @@ -3319,16 +3295,11 @@ int VisualShaderNodeMix::get_input_port_count() const { VisualShaderNodeMix::PortType VisualShaderNodeMix::get_input_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_SCALAR: - return PORT_TYPE_SCALAR; case OP_TYPE_VECTOR: - if (p_port == 2) { - return PORT_TYPE_VECTOR; - } return PORT_TYPE_VECTOR; case OP_TYPE_VECTOR_SCALAR: if (p_port == 2) { - return PORT_TYPE_SCALAR; + break; } return PORT_TYPE_VECTOR; default: @@ -3353,8 +3324,6 @@ int VisualShaderNodeMix::get_output_port_count() const { VisualShaderNodeMix::PortType VisualShaderNodeMix::get_output_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_SCALAR: - return PORT_TYPE_SCALAR; case OP_TYPE_VECTOR: return PORT_TYPE_VECTOR; case OP_TYPE_VECTOR_SCALAR: @@ -4540,9 +4509,7 @@ int VisualShaderNodeTextureUniformTriplanar::get_input_port_count() const { } VisualShaderNodeTextureUniform::PortType VisualShaderNodeTextureUniformTriplanar::get_input_port_type(int p_port) const { - if (p_port == 0) { - return PORT_TYPE_VECTOR; - } else if (p_port == 1) { + if (p_port == 0 || p_port == 1) { return PORT_TYPE_VECTOR; } return PORT_TYPE_SCALAR; @@ -4923,8 +4890,6 @@ VisualShaderNodeSwitch::PortType VisualShaderNodeSwitch::get_input_port_type(int } if (p_port == 1 || p_port == 2) { switch (op_type) { - case OP_TYPE_FLOAT: - return PORT_TYPE_SCALAR; case OP_TYPE_INT: return PORT_TYPE_SCALAR_INT; case OP_TYPE_VECTOR: @@ -4959,8 +4924,6 @@ int VisualShaderNodeSwitch::get_output_port_count() const { VisualShaderNodeSwitch::PortType VisualShaderNodeSwitch::get_output_port_type(int p_port) const { switch (op_type) { - case OP_TYPE_FLOAT: - return PORT_TYPE_SCALAR; case OP_TYPE_INT: return PORT_TYPE_SCALAR_INT; case OP_TYPE_VECTOR: @@ -5238,9 +5201,6 @@ int VisualShaderNodeCompare::get_input_port_count() const { } VisualShaderNodeCompare::PortType VisualShaderNodeCompare::get_input_port_type(int p_port) const { - if (p_port == 2) { - return PORT_TYPE_SCALAR; - } switch (ctype) { case CTYPE_SCALAR: return PORT_TYPE_SCALAR; @@ -5252,8 +5212,9 @@ VisualShaderNodeCompare::PortType VisualShaderNodeCompare::get_input_port_type(i return PORT_TYPE_BOOLEAN; case CTYPE_TRANSFORM: return PORT_TYPE_TRANSFORM; + default: + return PORT_TYPE_SCALAR; } - return PORT_TYPE_VECTOR; } String VisualShaderNodeCompare::get_input_port_name(int p_port) const { @@ -5472,10 +5433,10 @@ int VisualShaderNodeMultiplyAdd::get_input_port_count() const { } VisualShaderNodeMultiplyAdd::PortType VisualShaderNodeMultiplyAdd::get_input_port_type(int p_port) const { - if (op_type == OP_TYPE_SCALAR) { - return PORT_TYPE_SCALAR; + if (op_type == OP_TYPE_VECTOR) { + return PORT_TYPE_VECTOR; } - return PORT_TYPE_VECTOR; + return PORT_TYPE_SCALAR; } String VisualShaderNodeMultiplyAdd::get_input_port_name(int p_port) const { diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 156c7d0576..a064ade362 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -34,6 +34,7 @@ #include "scene/2d/camera_2d.h" #include "scene/2d/visibility_notifier_2d.h" #include "scene/main/window.h" +#include "servers/navigation_server_2d.h" #include "servers/physics_server_2d.h" #include "servers/rendering_server.h" @@ -315,14 +316,18 @@ void World2D::_update() { indexer->_update(); } -RID World2D::get_canvas() { +RID World2D::get_canvas() const { return canvas; } -RID World2D::get_space() { +RID World2D::get_space() const { return space; } +RID World2D::get_navigation_map() const { + return navigation_map; +} + void World2D::get_viewport_list(List<Viewport *> *r_viewports) { for (Map<Viewport *, SpatialIndexer2D::ViewportData>::Element *E = indexer->viewports.front(); E; E = E->next()) { r_viewports->push_back(E->key()); @@ -332,11 +337,13 @@ void World2D::get_viewport_list(List<Viewport *> *r_viewports) { void World2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_canvas"), &World2D::get_canvas); ClassDB::bind_method(D_METHOD("get_space"), &World2D::get_space); + ClassDB::bind_method(D_METHOD("get_navigation_map"), &World2D::get_navigation_map); ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World2D::get_direct_space_state); ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", 0), "", "get_canvas"); ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", 0), "", "get_navigation_map"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", 0), "", "get_direct_space_state"); } @@ -346,9 +353,9 @@ PhysicsDirectSpaceState2D *World2D::get_direct_space_state() { World2D::World2D() { canvas = RenderingServer::get_singleton()->canvas_create(); - space = PhysicsServer2D::get_singleton()->space_create(); - //set space2D to be more friendly with pixels than meters, by adjusting some constants + // Create and configure space2D to be more friendly with pixels than meters + space = PhysicsServer2D::get_singleton()->space_create(); PhysicsServer2D::get_singleton()->space_set_active(space, true); PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/2d/default_gravity", 98)); PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/2d/default_gravity_vector", Vector2(0, 1))); @@ -356,11 +363,19 @@ World2D::World2D() { ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/default_linear_damp", PropertyInfo(Variant::FLOAT, "physics/2d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/2d/default_angular_damp", 1.0)); ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/2d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); + + // Create and configure the navigation_map to be more friendly with pixels than meters. + navigation_map = NavigationServer2D::get_singleton()->map_create(); + NavigationServer2D::get_singleton()->map_set_active(navigation_map, true); + NavigationServer2D::get_singleton()->map_set_cell_size(navigation_map, GLOBAL_DEF("navigation/2d/default_cell_size", 10)); + NavigationServer2D::get_singleton()->map_set_edge_connection_margin(navigation_map, GLOBAL_DEF("navigation/2d/default_edge_connection_margin", 100)); + indexer = memnew(SpatialIndexer2D); } World2D::~World2D() { RenderingServer::get_singleton()->free(canvas); PhysicsServer2D::get_singleton()->free(space); + NavigationServer2D::get_singleton()->free(navigation_map); memdelete(indexer); } diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h index ae13367421..38abf3d7ad 100644 --- a/scene/resources/world_2d.h +++ b/scene/resources/world_2d.h @@ -44,6 +44,7 @@ class World2D : public Resource { RID canvas; RID space; + RID navigation_map; SpatialIndexer2D *indexer; @@ -63,8 +64,9 @@ protected: void _update(); public: - RID get_canvas(); - RID get_space(); + RID get_canvas() const; + RID get_space() const; + RID get_navigation_map() const; PhysicsDirectSpaceState2D *get_direct_space_state(); diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp index 9c0317454b..0e9f7a6cf2 100644 --- a/scene/resources/world_3d.cpp +++ b/scene/resources/world_3d.cpp @@ -35,6 +35,7 @@ #include "scene/3d/camera_3d.h" #include "scene/3d/visibility_notifier_3d.h" #include "scene/scene_string_names.h" +#include "servers/navigation_server_3d.h" struct SpatialIndexer { Octree<VisibilityNotifier3D> octree; @@ -243,6 +244,10 @@ RID World3D::get_space() const { return space; } +RID World3D::get_navigation_map() const { + return navigation_map; +} + RID World3D::get_scenario() const { return scenario; } @@ -310,6 +315,7 @@ void World3D::get_camera_list(List<Camera3D *> *r_cameras) { void World3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_space"), &World3D::get_space); + ClassDB::bind_method(D_METHOD("get_navigation_map"), &World3D::get_navigation_map); ClassDB::bind_method(D_METHOD("get_scenario"), &World3D::get_scenario); ClassDB::bind_method(D_METHOD("set_environment", "env"), &World3D::set_environment); ClassDB::bind_method(D_METHOD("get_environment"), &World3D::get_environment); @@ -322,6 +328,7 @@ void World3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback_environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_fallback_environment", "get_fallback_environment"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_effects", PROPERTY_HINT_RESOURCE_TYPE, "CameraEffects"), "set_camera_effects", "get_camera_effects"); ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", 0), "", "get_navigation_map"); ADD_PROPERTY(PropertyInfo(Variant::RID, "scenario", PROPERTY_HINT_NONE, "", 0), "", "get_scenario"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", 0), "", "get_direct_space_state"); } @@ -338,6 +345,11 @@ World3D::World3D() { PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/3d/default_angular_damp", 0.1)); ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/3d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); + navigation_map = NavigationServer3D::get_singleton()->map_create(); + NavigationServer3D::get_singleton()->map_set_active(navigation_map, true); + NavigationServer3D::get_singleton()->map_set_cell_size(navigation_map, GLOBAL_DEF("navigation/3d/default_cell_size", 0.3)); + NavigationServer3D::get_singleton()->map_set_edge_connection_margin(navigation_map, GLOBAL_DEF("navigation/3d/default_edge_connection_margin", 5.0)); // Five meters, depends a lot on the agent's radius + #ifdef _3D_DISABLED indexer = nullptr; #else @@ -348,6 +360,7 @@ World3D::World3D() { World3D::~World3D() { PhysicsServer3D::get_singleton()->free(space); RenderingServer::get_singleton()->free(scenario); + NavigationServer3D::get_singleton()->free(navigation_map); #ifndef _3D_DISABLED memdelete(indexer); diff --git a/scene/resources/world_3d.h b/scene/resources/world_3d.h index 3d6c33997e..4e2717a2bb 100644 --- a/scene/resources/world_3d.h +++ b/scene/resources/world_3d.h @@ -46,6 +46,7 @@ class World3D : public Resource { private: RID space; + RID navigation_map; RID scenario; SpatialIndexer *indexer; Ref<Environment> environment; @@ -70,6 +71,7 @@ protected: public: RID get_space() const; + RID get_navigation_map() const; RID get_scenario() const; void set_environment(const Ref<Environment> &p_environment); diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp index df348d2add..fee74f3dbc 100644 --- a/servers/navigation_server_2d.cpp +++ b/servers/navigation_server_2d.cpp @@ -80,6 +80,18 @@ NavigationServer2D *NavigationServer2D::singleton = nullptr; return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3)); \ } +#define FORWARD_5_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, T_4, D_4, CONV_0, CONV_1, CONV_2, CONV_3, CONV_4) \ + NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3, T_4 D_4) \ + const { \ + return CONV_R(NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3), CONV_4(D_4))); \ + } + +#define FORWARD_5_C(FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, T_4, D_4, CONV_0, CONV_1, CONV_2, CONV_3, CONV_4) \ + NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3, T_4 D_4) \ + const { \ + return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3), CONV_4(D_4)); \ + } + static RID rid_to_rid(const RID d) { return d; } @@ -92,6 +104,10 @@ static int int_to_int(const int d) { return d; } +static uint32_t uint32_to_uint32(const uint32_t d) { + return d; +} + static real_t real_to_real(const real_t d) { return d; } @@ -148,12 +164,14 @@ void NavigationServer2D::_bind_methods() { ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer2D::map_get_cell_size); ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer2D::map_set_edge_connection_margin); ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer2D::map_get_edge_connection_margin); - ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer2D::map_get_path); + ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize", "layers"), &NavigationServer2D::map_get_path, DEFVAL(1)); ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer2D::map_get_closest_point); ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer2D::map_get_closest_point_owner); ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer2D::region_create); ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer2D::region_set_map); + ClassDB::bind_method(D_METHOD("region_set_layers", "region", "layers"), &NavigationServer2D::region_set_layers); + ClassDB::bind_method(D_METHOD("region_get_layers", "region"), &NavigationServer2D::region_get_layers); ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer2D::region_set_transform); ClassDB::bind_method(D_METHOD("region_set_navpoly", "region", "nav_poly"), &NavigationServer2D::region_set_navpoly); @@ -193,14 +211,15 @@ real_t FORWARD_1_C(map_get_cell_size, RID, p_map, rid_to_rid); void FORWARD_2_C(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin, rid_to_rid, real_to_real); real_t FORWARD_1_C(map_get_edge_connection_margin, RID, p_map, rid_to_rid); -Vector<Vector2> FORWARD_4_R_C(vector_v3_to_v2, map_get_path, RID, p_map, Vector2, p_origin, Vector2, p_destination, bool, p_optimize, rid_to_rid, v2_to_v3, v2_to_v3, bool_to_bool); +Vector<Vector2> FORWARD_5_R_C(vector_v3_to_v2, map_get_path, RID, p_map, Vector2, p_origin, Vector2, p_destination, bool, p_optimize, uint32_t, p_layers, rid_to_rid, v2_to_v3, v2_to_v3, bool_to_bool, uint32_to_uint32); Vector2 FORWARD_2_R_C(v3_to_v2, map_get_closest_point, RID, p_map, const Vector2 &, p_point, rid_to_rid, v2_to_v3); RID FORWARD_2_C(map_get_closest_point_owner, RID, p_map, const Vector2 &, p_point, rid_to_rid, v2_to_v3); RID FORWARD_0_C(region_create); void FORWARD_2_C(region_set_map, RID, p_region, RID, p_map, rid_to_rid, rid_to_rid); - +void FORWARD_2_C(region_set_layers, RID, p_region, uint32_t, p_layers, rid_to_rid, uint32_to_uint32); +uint32_t FORWARD_1_C(region_get_layers, RID, p_region, rid_to_rid); void FORWARD_2_C(region_set_transform, RID, p_region, Transform2D, p_transform, rid_to_rid, trf2_to_trf3); void NavigationServer2D::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) const { diff --git a/servers/navigation_server_2d.h b/servers/navigation_server_2d.h index 7be5a74cb3..46c8f6a71d 100644 --- a/servers/navigation_server_2d.h +++ b/servers/navigation_server_2d.h @@ -77,7 +77,7 @@ public: virtual real_t map_get_edge_connection_margin(RID p_map) const; /// Returns the navigation path to reach the destination from the origin. - virtual Vector<Vector2> map_get_path(RID p_map, Vector2 p_origin, Vector2 p_destination, bool p_optimize) const; + virtual Vector<Vector2> map_get_path(RID p_map, Vector2 p_origin, Vector2 p_destination, bool p_optimize, uint32_t p_layers = 1) const; virtual Vector2 map_get_closest_point(RID p_map, const Vector2 &p_point) const; virtual RID map_get_closest_point_owner(RID p_map, const Vector2 &p_point) const; @@ -88,6 +88,10 @@ public: /// Set the map of this region. virtual void region_set_map(RID p_region, RID p_map) const; + /// Set the region's layers + virtual void region_set_layers(RID p_region, uint32_t p_layers) const; + virtual uint32_t region_get_layers(RID p_region) const; + /// Set the global transformation of this region. virtual void region_set_transform(RID p_region, Transform2D p_transform) const; diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp index 0e5ae82b0d..d81ce70af6 100644 --- a/servers/navigation_server_3d.cpp +++ b/servers/navigation_server_3d.cpp @@ -46,7 +46,7 @@ void NavigationServer3D::_bind_methods() { ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer3D::map_get_cell_size); ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer3D::map_set_edge_connection_margin); ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer3D::map_get_edge_connection_margin); - ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer3D::map_get_path); + ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize", "layers"), &NavigationServer3D::map_get_path, DEFVAL(1)); ClassDB::bind_method(D_METHOD("map_get_closest_point_to_segment", "map", "start", "end", "use_collision"), &NavigationServer3D::map_get_closest_point_to_segment, DEFVAL(false)); ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer3D::map_get_closest_point); ClassDB::bind_method(D_METHOD("map_get_closest_point_normal", "map", "to_point"), &NavigationServer3D::map_get_closest_point_normal); @@ -54,6 +54,8 @@ void NavigationServer3D::_bind_methods() { ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer3D::region_create); ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer3D::region_set_map); + ClassDB::bind_method(D_METHOD("region_set_layers", "region", "layers"), &NavigationServer3D::region_set_layers); + ClassDB::bind_method(D_METHOD("region_get_layers", "region"), &NavigationServer3D::region_get_layers); ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer3D::region_set_transform); ClassDB::bind_method(D_METHOD("region_set_navmesh", "region", "nav_mesh"), &NavigationServer3D::region_set_navmesh); ClassDB::bind_method(D_METHOD("region_bake_navmesh", "mesh", "node"), &NavigationServer3D::region_bake_navmesh); diff --git a/servers/navigation_server_3d.h b/servers/navigation_server_3d.h index 3761c3871a..beed19d563 100644 --- a/servers/navigation_server_3d.h +++ b/servers/navigation_server_3d.h @@ -88,7 +88,7 @@ public: virtual real_t map_get_edge_connection_margin(RID p_map) const = 0; /// Returns the navigation path to reach the destination from the origin. - virtual Vector<Vector3> map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const = 0; + virtual Vector<Vector3> map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_navigable_layers = 1) const = 0; virtual Vector3 map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision = false) const = 0; virtual Vector3 map_get_closest_point(RID p_map, const Vector3 &p_point) const = 0; @@ -101,6 +101,10 @@ public: /// Set the map of this region. virtual void region_set_map(RID p_region, RID p_map) const = 0; + /// Set the region's layers + virtual void region_set_layers(RID p_region, uint32_t p_layers) const = 0; + virtual uint32_t region_get_layers(RID p_region) const = 0; + /// Set the global transformation of this region. virtual void region_set_transform(RID p_region, Transform p_transform) const = 0; diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index f503868ba5..c7b556deba 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -205,15 +205,6 @@ PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p } } -PinJoint2DSW::~PinJoint2DSW() { - if (A) { - A->remove_constraint(this, 0); - } - if (B) { - B->remove_constraint(this, 1); - } -} - ////////////////////////////////////////////// ////////////////////////////////////////////// ////////////////////////////////////////////// @@ -346,11 +337,6 @@ GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_ B->add_constraint(this, 1); } -GrooveJoint2DSW::~GrooveJoint2DSW() { - A->remove_constraint(this, 0); - B->remove_constraint(this, 1); -} - ////////////////////////////////////////////// ////////////////////////////////////////////// ////////////////////////////////////////////// @@ -442,8 +428,3 @@ DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Ve A->add_constraint(this, 0); B->add_constraint(this, 1); } - -DampedSpringJoint2DSW::~DampedSpringJoint2DSW() { - A->remove_constraint(this, 0); - B->remove_constraint(this, 1); -} diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h index 6050dc2775..628de972ae 100644 --- a/servers/physics_2d/joints_2d_sw.h +++ b/servers/physics_2d/joints_2d_sw.h @@ -60,6 +60,15 @@ public: bias = 0; max_force = max_bias = 3.40282e+38; }; + + virtual ~Joint2DSW() { + for (int i = 0; i < get_body_count(); i++) { + Body2DSW *body = get_body_ptr()[i]; + if (body) { + body->remove_constraint(this, i); + } + } + }; }; class PinJoint2DSW : public Joint2DSW { @@ -90,7 +99,6 @@ public: real_t get_param(PhysicsServer2D::PinJointParam p_param) const; PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b = nullptr); - ~PinJoint2DSW(); }; class GrooveJoint2DSW : public Joint2DSW { @@ -124,7 +132,6 @@ public: virtual void solve(real_t p_step); GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, Body2DSW *p_body_a, Body2DSW *p_body_b); - ~GrooveJoint2DSW(); }; class DampedSpringJoint2DSW : public Joint2DSW { @@ -160,7 +167,6 @@ public: real_t get_param(PhysicsServer2D::DampedSpringParam p_param) const; DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b); - ~DampedSpringJoint2DSW(); }; #endif // JOINTS_2D_SW_H diff --git a/servers/physics_3d/body_3d_sw.cpp b/servers/physics_3d/body_3d_sw.cpp index 82356e77ef..9eff14bbeb 100644 --- a/servers/physics_3d/body_3d_sw.cpp +++ b/servers/physics_3d/body_3d_sw.cpp @@ -51,18 +51,18 @@ void Body3DSW::_update_transform_dependant() { } void Body3DSW::update_inertias() { - //update shapes and motions + // Update shapes and motions. switch (mode) { case PhysicsServer3D::BODY_MODE_RIGID: { - //update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet) + // Update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet) real_t total_area = 0; for (int i = 0; i < get_shape_count(); i++) { total_area += get_shape_area(i); } - // We have to recompute the center of mass + // We have to recompute the center of mass. center_of_mass_local.zero(); for (int i = 0; i < get_shape_count(); i++) { @@ -70,21 +70,24 @@ void Body3DSW::update_inertias() { real_t mass = area * this->mass / total_area; - // NOTE: we assume that the shape origin is also its center of mass + // NOTE: we assume that the shape origin is also its center of mass. center_of_mass_local += mass * get_shape_transform(i).origin; } center_of_mass_local /= mass; - // Recompute the inertia tensor + // Recompute the inertia tensor. Basis inertia_tensor; inertia_tensor.set_zero(); + bool inertia_set = false; for (int i = 0; i < get_shape_count(); i++) { if (is_shape_disabled(i)) { continue; } + inertia_set = true; + const Shape3DSW *shape = get_shape(i); real_t area = get_shape_area(i); @@ -102,7 +105,12 @@ void Body3DSW::update_inertias() { inertia_tensor += shape_inertia_tensor + (Basis() * shape_origin.dot(shape_origin) - shape_origin.outer(shape_origin)) * mass; } - // Compute the principal axes of inertia + // Set the inertia to a valid value when there are no valid shapes. + if (!inertia_set) { + inertia_tensor.set_diagonal(Vector3(1.0, 1.0, 1.0)); + } + + // Compute the principal axes of inertia. principal_inertia_axes_local = inertia_tensor.diagonalize().transposed(); _inv_inertia = inertia_tensor.get_main_diagonal().inverse(); diff --git a/servers/physics_3d/collision_solver_3d_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp index f507cacdc3..651961433c 100644 --- a/servers/physics_3d/collision_solver_3d_sat.cpp +++ b/servers/physics_3d/collision_solver_3d_sat.cpp @@ -845,7 +845,7 @@ static void _collision_sphere_capsule(const Shape3DSW *p_a, const Transform &p_t //capsule sphere 1, sphere - Vector3 capsule_axis = p_transform_b.basis.get_axis(2) * (capsule_B->get_height() * 0.5); + Vector3 capsule_axis = p_transform_b.basis.get_axis(1) * (capsule_B->get_height() * 0.5); Vector3 capsule_ball_1 = p_transform_b.origin + capsule_axis; @@ -1148,7 +1148,7 @@ static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_tran } } - Vector3 cyl_axis = p_transform_b.basis.get_axis(2).normalized(); + Vector3 cyl_axis = p_transform_b.basis.get_axis(1).normalized(); // edges of A, capsule cylinder @@ -1193,7 +1193,7 @@ static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_tran // capsule balls, edges of A for (int i = 0; i < 2; i++) { - Vector3 capsule_axis = p_transform_b.basis.get_axis(2) * (capsule_B->get_height() * 0.5); + Vector3 capsule_axis = p_transform_b.basis.get_axis(1) * (capsule_B->get_height() * 0.5); Vector3 sphere_pos = p_transform_b.origin + ((i == 0) ? capsule_axis : -capsule_axis); @@ -1569,8 +1569,8 @@ static void _collision_capsule_capsule(const Shape3DSW *p_a, const Transform &p_ // some values - Vector3 capsule_A_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5); - Vector3 capsule_B_axis = p_transform_b.basis.get_axis(2) * (capsule_B->get_height() * 0.5); + Vector3 capsule_A_axis = p_transform_a.basis.get_axis(1) * (capsule_A->get_height() * 0.5); + Vector3 capsule_B_axis = p_transform_b.basis.get_axis(1) * (capsule_B->get_height() * 0.5); Vector3 capsule_A_ball_1 = p_transform_a.origin + capsule_A_axis; Vector3 capsule_A_ball_2 = p_transform_a.origin - capsule_A_axis; @@ -1670,7 +1670,7 @@ static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transf for (int i = 0; i < edge_count; i++) { // cylinder Vector3 edge_axis = p_transform_b.basis.xform(vertices[edges[i].a]) - p_transform_b.basis.xform(vertices[edges[i].b]); - Vector3 axis = edge_axis.cross(p_transform_a.basis.get_axis(2)).normalized(); + Vector3 axis = edge_axis.cross(p_transform_a.basis.get_axis(1)).normalized(); if (!separator.test_axis(axis)) { return; @@ -1682,7 +1682,7 @@ static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transf for (int i = 0; i < 2; i++) { // edges of B, capsule cylinder - Vector3 capsule_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5); + Vector3 capsule_axis = p_transform_a.basis.get_axis(1) * (capsule_A->get_height() * 0.5); Vector3 sphere_pos = p_transform_a.origin + ((i == 0) ? capsule_axis : -capsule_axis); @@ -1720,7 +1720,7 @@ static void _collision_capsule_face(const Shape3DSW *p_a, const Transform &p_tra // edges of B, capsule cylinder - Vector3 capsule_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5); + Vector3 capsule_axis = p_transform_a.basis.get_axis(1) * (capsule_A->get_height() * 0.5); for (int i = 0; i < 3; i++) { // edge-cylinder diff --git a/servers/physics_3d/joints_3d_sw.h b/servers/physics_3d/joints_3d_sw.h index 1fe573c69e..225a71aca9 100644 --- a/servers/physics_3d/joints_3d_sw.h +++ b/servers/physics_3d/joints_3d_sw.h @@ -49,6 +49,15 @@ public: _FORCE_INLINE_ Joint3DSW(Body3DSW **p_body_ptr = nullptr, int p_body_count = 0) : Constraint3DSW(p_body_ptr, p_body_count) { } + + virtual ~Joint3DSW() { + for (int i = 0; i < get_body_count(); i++) { + Body3DSW *body = get_body_ptr()[i]; + if (body) { + body->remove_constraint(this); + } + } + } }; #endif // JOINTS_SW_H diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp index 735e9094d2..6bbef09907 100644 --- a/servers/physics_3d/physics_server_3d_sw.cpp +++ b/servers/physics_3d/physics_server_3d_sw.cpp @@ -1312,9 +1312,6 @@ void PhysicsServer3DSW::free(RID p_rid) { } else if (joint_owner.owns(p_rid)) { Joint3DSW *joint = joint_owner.getornull(p_rid); - for (int i = 0; i < joint->get_body_count(); i++) { - joint->get_body_ptr()[i]->remove_constraint(joint); - } joint_owner.free(p_rid); memdelete(joint); diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp index 5bac4f19b9..02d0c66215 100644 --- a/servers/physics_3d/shape_3d_sw.cpp +++ b/servers/physics_3d/shape_3d_sw.cpp @@ -491,10 +491,10 @@ BoxShape3DSW::BoxShape3DSW() { void CapsuleShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { Vector3 n = p_transform.basis.xform_inv(p_normal).normalized(); - real_t h = (n.z > 0) ? height : -height; + real_t h = (n.y > 0) ? height : -height; n *= radius; - n.z += h * 0.5; + n.y += h * 0.5; r_max = p_normal.dot(p_transform.xform(n)); r_min = p_normal.dot(p_transform.xform(-n)); @@ -503,36 +503,36 @@ void CapsuleShape3DSW::project_range(const Vector3 &p_normal, const Transform &p Vector3 CapsuleShape3DSW::get_support(const Vector3 &p_normal) const { Vector3 n = p_normal; - real_t h = (n.z > 0) ? height : -height; + real_t h = (n.y > 0) ? height : -height; n *= radius; - n.z += h * 0.5; + n.y += h * 0.5; return n; } void CapsuleShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { Vector3 n = p_normal; - real_t d = n.z; + real_t d = n.y; if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { // make it flat - n.z = 0.0; + n.y = 0.0; n.normalize(); n *= radius; r_amount = 2; r_type = FEATURE_EDGE; r_supports[0] = n; - r_supports[0].z += height * 0.5; + r_supports[0].y += height * 0.5; r_supports[1] = n; - r_supports[1].z -= height * 0.5; + r_supports[1].y -= height * 0.5; } else { real_t h = (d > 0) ? height : -height; n *= radius; - n.z += h * 0.5; + n.y += h * 0.5; r_amount = 1; r_type = FEATURE_POINT; *r_supports = n; @@ -551,7 +551,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 & // test against cylinder and spheres :-| - collided = Geometry3D::segment_intersects_cylinder(p_begin, p_end, height, radius, &auxres, &auxn); + collided = Geometry3D::segment_intersects_cylinder(p_begin, p_end, height, radius, &auxres, &auxn, 1); if (collided) { real_t d = norm.dot(auxres); @@ -563,7 +563,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 & } } - collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * 0.5), radius, &auxres, &auxn); + collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, height * 0.5, 0), radius, &auxres, &auxn); if (collided) { real_t d = norm.dot(auxres); @@ -575,7 +575,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 & } } - collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * -0.5), radius, &auxres, &auxn); + collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, height * -0.5, 0), radius, &auxres, &auxn); if (collided) { real_t d = norm.dot(auxres); @@ -596,19 +596,19 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 & } bool CapsuleShape3DSW::intersect_point(const Vector3 &p_point) const { - if (Math::abs(p_point.z) < height * 0.5) { - return Vector3(p_point.x, p_point.y, 0).length() < radius; + if (Math::abs(p_point.y) < height * 0.5) { + return Vector3(p_point.x, 0, p_point.z).length() < radius; } else { Vector3 p = p_point; - p.z = Math::abs(p.z) - height * 0.5; + p.y = Math::abs(p.y) - height * 0.5; return p.length() < radius; } } Vector3 CapsuleShape3DSW::get_closest_point_to(const Vector3 &p_point) const { Vector3 s[2] = { - Vector3(0, 0, -height * 0.5), - Vector3(0, 0, height * 0.5), + Vector3(0, -height * 0.5, 0), + Vector3(0, height * 0.5, 0), }; Vector3 p = Geometry3D::get_closest_point_to_segment(p_point, s); @@ -633,7 +633,7 @@ Vector3 CapsuleShape3DSW::get_moment_of_inertia(real_t p_mass) const { void CapsuleShape3DSW::_setup(real_t p_height, real_t p_radius) { height = p_height; radius = p_radius; - configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0))); + configure(AABB(Vector3(-radius, -height * 0.5 - radius, -radius), Vector3(radius * 2, height + radius * 2.0, radius * 2))); } void CapsuleShape3DSW::set_data(const Variant &p_data) { diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index e34bc9acb8..7f3fc2f8f4 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -148,6 +148,8 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2 } else { ci->final_clip_rect = global_rect; } + ci->final_clip_rect.position = ci->final_clip_rect.position.round(); + ci->final_clip_rect.size = ci->final_clip_rect.size.round(); ci->final_clip_owner = ci; } else { @@ -525,11 +527,11 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from, Item::CommandPrimitive *line = canvas_item->alloc_command<Item::CommandPrimitive>(); ERR_FAIL_COND(!line); if (p_width > 1.001) { - Vector2 t = (p_from - p_to).orthogonal().normalized(); - line->points[0] = p_from + t * p_width; - line->points[1] = p_from - t * p_width; - line->points[2] = p_to - t * p_width; - line->points[3] = p_to + t * p_width; + Vector2 t = (p_from - p_to).orthogonal().normalized() * p_width * 0.5; + line->points[0] = p_from + t; + line->points[1] = p_from - t; + line->points[2] = p_to - t; + line->points[3] = p_to + t; line->point_count = 4; } else { line->point_count = 2; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index be2552bd32..d5ac05d1d1 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -175,5 +175,5 @@ RendererCompositorRD::RendererCompositorRD() { storage = memnew(RendererStorageRD); canvas = memnew(RendererCanvasRenderRD(storage)); - scene = memnew(RendererSceneRenderForward(storage)); + scene = memnew(RendererSceneRenderForwardClustered(storage)); } diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index cb85fc79e0..67a843452b 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -35,14 +35,14 @@ #include "core/templates/thread_work_pool.h" #include "servers/rendering/renderer_compositor.h" #include "servers/rendering/renderer_rd/renderer_canvas_render_rd.h" -#include "servers/rendering/renderer_rd/renderer_scene_render_forward.h" +#include "servers/rendering/renderer_rd/renderer_scene_render_forward_clustered.h" #include "servers/rendering/renderer_rd/renderer_storage_rd.h" class RendererCompositorRD : public RendererCompositor { protected: RendererCanvasRenderRD *canvas; RendererStorageRD *storage; - RendererSceneRenderForward *scene; + RendererSceneRenderRD *scene; RID copy_viewports_rd_shader; RID copy_viewports_rd_pipeline; diff --git a/servers/rendering/renderer_rd/renderer_scene_environment_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_environment_rd.cpp new file mode 100644 index 0000000000..d631cb4bac --- /dev/null +++ b/servers/rendering/renderer_rd/renderer_scene_environment_rd.cpp @@ -0,0 +1,126 @@ +/*************************************************************************/ +/* renderer_scene_environment_rd.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "servers/rendering/renderer_rd/renderer_scene_environment_rd.h" + +uint64_t RendererSceneEnvironmentRD::auto_exposure_counter = 2; + +void RendererSceneEnvironmentRD::set_ambient_light(const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) { + ambient_light = p_color; + ambient_source = p_ambient; + ambient_light_energy = p_energy; + ambient_sky_contribution = p_sky_contribution; + reflection_source = p_reflection_source; + ao_color = p_ao_color; +} + +void RendererSceneEnvironmentRD::set_tonemap(RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { + exposure = p_exposure; + tone_mapper = p_tone_mapper; + if (!auto_exposure && p_auto_exposure) { + auto_exposure_version = ++auto_exposure_counter; + } + auto_exposure = p_auto_exposure; + white = p_white; + min_luminance = p_min_luminance; + max_luminance = p_max_luminance; + auto_exp_speed = p_auto_exp_speed; + auto_exp_scale = p_auto_exp_scale; +} + +void RendererSceneEnvironmentRD::set_glow(bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) { + ERR_FAIL_COND_MSG(p_levels.size() != 7, "Size of array of glow levels must be 7"); + glow_enabled = p_enable; + glow_levels = p_levels; + glow_intensity = p_intensity; + glow_strength = p_strength; + glow_mix = p_mix; + glow_bloom = p_bloom_threshold; + glow_blend_mode = p_blend_mode; + glow_hdr_bleed_threshold = p_hdr_bleed_threshold; + glow_hdr_bleed_scale = p_hdr_bleed_scale; + glow_hdr_luminance_cap = p_hdr_luminance_cap; +} + +void RendererSceneEnvironmentRD::set_sdfgi(bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) { + sdfgi_enabled = p_enable; + sdfgi_cascades = p_cascades; + sdfgi_min_cell_size = p_min_cell_size; + sdfgi_use_occlusion = p_use_occlusion; + sdfgi_bounce_feedback = p_bounce_feedback; + sdfgi_read_sky_light = p_read_sky; + sdfgi_energy = p_energy; + sdfgi_normal_bias = p_normal_bias; + sdfgi_probe_bias = p_probe_bias; + sdfgi_y_scale = p_y_scale; +} + +void RendererSceneEnvironmentRD::set_fog(bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective) { + fog_enabled = p_enable; + fog_light_color = p_light_color; + fog_light_energy = p_light_energy; + fog_sun_scatter = p_sun_scatter; + fog_density = p_density; + fog_height = p_height; + fog_height_density = p_height_density; + fog_aerial_perspective = p_fog_aerial_perspective; +} + +void RendererSceneEnvironmentRD::set_volumetric_fog(bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) { + volumetric_fog_enabled = p_enable; + volumetric_fog_density = p_density; + volumetric_fog_light = p_light; + volumetric_fog_light_energy = p_light_energy; + volumetric_fog_length = p_length; + volumetric_fog_detail_spread = p_detail_spread; + volumetric_fog_gi_inject = p_gi_inject; + volumetric_fog_temporal_reprojection = p_temporal_reprojection; + volumetric_fog_temporal_reprojection_amount = p_temporal_reprojection_amount; +} + +void RendererSceneEnvironmentRD::set_ssr(bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) { + ssr_enabled = p_enable; + ssr_max_steps = p_max_steps; + ssr_fade_in = p_fade_int; + ssr_fade_out = p_fade_out; + ssr_depth_tolerance = p_depth_tolerance; +} + +void RendererSceneEnvironmentRD::set_ssao(bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) { + ssao_enabled = p_enable; + ssao_radius = p_radius; + ssao_intensity = p_intensity; + ssao_power = p_power; + ssao_detail = p_detail; + ssao_horizon = p_horizon; + ssao_sharpness = p_sharpness; + ssao_direct_light_affect = p_light_affect; + ssao_ao_channel_affect = p_ao_channel_affect; +} diff --git a/servers/rendering/renderer_rd/renderer_scene_environment_rd.h b/servers/rendering/renderer_rd/renderer_scene_environment_rd.h new file mode 100644 index 0000000000..992c4bf471 --- /dev/null +++ b/servers/rendering/renderer_rd/renderer_scene_environment_rd.h @@ -0,0 +1,155 @@ +/*************************************************************************/ +/* renderer_scene_environment_rd.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H +#define RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H + +#include "servers/rendering/renderer_scene_render.h" +#include "servers/rendering/rendering_device.h" + +class RendererSceneEnvironmentRD { +private: + static uint64_t auto_exposure_counter; + +public: + // BG + RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR; + RID sky; + float sky_custom_fov = 0.0; + Basis sky_orientation; + Color bg_color; + float bg_energy = 1.0; + int canvas_max_layer = 0; + RS::EnvironmentAmbientSource ambient_source = RS::ENV_AMBIENT_SOURCE_BG; + Color ambient_light; + float ambient_light_energy = 1.0; + float ambient_sky_contribution = 1.0; + RS::EnvironmentReflectionSource reflection_source = RS::ENV_REFLECTION_SOURCE_BG; + Color ao_color; + + /// Tonemap + + RS::EnvironmentToneMapper tone_mapper; + float exposure = 1.0; + float white = 1.0; + bool auto_exposure = false; + float min_luminance = 0.2; + float max_luminance = 8.0; + float auto_exp_speed = 0.2; + float auto_exp_scale = 0.5; + uint64_t auto_exposure_version = 0; + + // Fog + bool fog_enabled = false; + Color fog_light_color = Color(0.5, 0.6, 0.7); + float fog_light_energy = 1.0; + float fog_sun_scatter = 0.0; + float fog_density = 0.001; + float fog_height = 0.0; + float fog_height_density = 0.0; //can be negative to invert effect + float fog_aerial_perspective = 0.0; + + /// Volumetric Fog + /// + bool volumetric_fog_enabled = false; + float volumetric_fog_density = 0.01; + Color volumetric_fog_light = Color(0, 0, 0); + float volumetric_fog_light_energy = 0.0; + float volumetric_fog_length = 64.0; + float volumetric_fog_detail_spread = 2.0; + float volumetric_fog_gi_inject = 0.0; + bool volumetric_fog_temporal_reprojection = true; + float volumetric_fog_temporal_reprojection_amount = 0.9; + + /// Glow + + bool glow_enabled = false; + Vector<float> glow_levels; + float glow_intensity = 0.8; + float glow_strength = 1.0; + float glow_bloom = 0.0; + float glow_mix = 0.01; + RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT; + float glow_hdr_bleed_threshold = 1.0; + float glow_hdr_luminance_cap = 12.0; + float glow_hdr_bleed_scale = 2.0; + + /// SSAO + + bool ssao_enabled = false; + float ssao_radius = 1.0; + float ssao_intensity = 2.0; + float ssao_power = 1.5; + float ssao_detail = 0.5; + float ssao_horizon = 0.06; + float ssao_sharpness = 0.98; + float ssao_direct_light_affect = 0.0; + float ssao_ao_channel_affect = 0.0; + + /// SSR + /// + bool ssr_enabled = false; + int ssr_max_steps = 64; + float ssr_fade_in = 0.15; + float ssr_fade_out = 2.0; + float ssr_depth_tolerance = 0.2; + + /// SDFGI + bool sdfgi_enabled = false; + RS::EnvironmentSDFGICascades sdfgi_cascades; + float sdfgi_min_cell_size = 0.2; + bool sdfgi_use_occlusion = false; + float sdfgi_bounce_feedback = 0.0; + bool sdfgi_read_sky_light = false; + float sdfgi_energy = 1.0; + float sdfgi_normal_bias = 1.1; + float sdfgi_probe_bias = 1.1; + RS::EnvironmentSDFGIYScale sdfgi_y_scale = RS::ENV_SDFGI_Y_SCALE_DISABLED; + + /// Adjustments + + bool adjustments_enabled = false; + float adjustments_brightness = 1.0f; + float adjustments_contrast = 1.0f; + float adjustments_saturation = 1.0f; + bool use_1d_color_correction = false; + RID color_correction = RID(); + + void set_ambient_light(const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color); + void set_tonemap(RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale); + void set_glow(bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap); + void set_sdfgi(bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias); + void set_fog(bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective); + void set_volumetric_fog(bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount); + void set_ssr(bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance); + void set_ssao(bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect); +}; + +#endif /* !RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H */ diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp new file mode 100644 index 0000000000..4e4e553605 --- /dev/null +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -0,0 +1,3403 @@ +/*************************************************************************/ +/* renderer_scene_gi_rd.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "renderer_scene_gi_rd.h" + +#include "core/config/project_settings.h" +#include "servers/rendering/renderer_rd/renderer_scene_render_rd.h" +#include "servers/rendering/rendering_server_default.h" + +const Vector3i RendererSceneGIRD::SDFGI::Cascade::DIRTY_ALL = Vector3i(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF); + +//////////////////////////////////////////////////////////////////////////////// +// SDFGI + +void RendererSceneGIRD::SDFGI::create(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size, RendererSceneGIRD *p_gi) { + storage = p_gi->storage; + gi = p_gi; + cascade_mode = p_env->sdfgi_cascades; + min_cell_size = p_env->sdfgi_min_cell_size; + uses_occlusion = p_env->sdfgi_use_occlusion; + y_scale_mode = p_env->sdfgi_y_scale; + static const float y_scale[3] = { 1.0, 1.5, 2.0 }; + y_mult = y_scale[y_scale_mode]; + static const int cascasde_size[3] = { 4, 6, 8 }; + cascades.resize(cascasde_size[cascade_mode]); + probe_axis_count = SDFGI::PROBE_DIVISOR + 1; + solid_cell_ratio = gi->sdfgi_solid_cell_ratio; + solid_cell_count = uint32_t(float(cascade_size * cascade_size * cascade_size) * solid_cell_ratio); + + float base_cell_size = min_cell_size; + + RD::TextureFormat tf_sdf; + tf_sdf.format = RD::DATA_FORMAT_R8_UNORM; + tf_sdf.width = cascade_size; // Always 64x64 + tf_sdf.height = cascade_size; + tf_sdf.depth = cascade_size; + tf_sdf.texture_type = RD::TEXTURE_TYPE_3D; + tf_sdf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; + + { + RD::TextureFormat tf_render = tf_sdf; + tf_render.format = RD::DATA_FORMAT_R16_UINT; + render_albedo = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + tf_render.format = RD::DATA_FORMAT_R32_UINT; + render_emission = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + render_emission_aniso = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + + tf_render.format = RD::DATA_FORMAT_R8_UNORM; //at least its easy to visualize + + for (int i = 0; i < 8; i++) { + render_occlusion[i] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + } + + tf_render.format = RD::DATA_FORMAT_R32_UINT; + render_geom_facing = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + + tf_render.format = RD::DATA_FORMAT_R8G8B8A8_UINT; + render_sdf[0] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + render_sdf[1] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + + tf_render.width /= 2; + tf_render.height /= 2; + tf_render.depth /= 2; + + render_sdf_half[0] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + render_sdf_half[1] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); + } + + RD::TextureFormat tf_occlusion = tf_sdf; + tf_occlusion.format = RD::DATA_FORMAT_R16_UINT; + tf_occlusion.shareable_formats.push_back(RD::DATA_FORMAT_R16_UINT); + tf_occlusion.shareable_formats.push_back(RD::DATA_FORMAT_R4G4B4A4_UNORM_PACK16); + tf_occlusion.depth *= cascades.size(); //use depth for occlusion slices + tf_occlusion.width *= 2; //use width for the other half + + RD::TextureFormat tf_light = tf_sdf; + tf_light.format = RD::DATA_FORMAT_R32_UINT; + tf_light.shareable_formats.push_back(RD::DATA_FORMAT_R32_UINT); + tf_light.shareable_formats.push_back(RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32); + + RD::TextureFormat tf_aniso0 = tf_sdf; + tf_aniso0.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; + RD::TextureFormat tf_aniso1 = tf_sdf; + tf_aniso1.format = RD::DATA_FORMAT_R8G8_UNORM; + + int passes = nearest_shift(cascade_size) - 1; + + //store lightprobe SH + RD::TextureFormat tf_probes; + tf_probes.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf_probes.width = probe_axis_count * probe_axis_count; + tf_probes.height = probe_axis_count * SDFGI::SH_SIZE; + tf_probes.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; + tf_probes.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; + + history_size = p_requested_history_size; + + RD::TextureFormat tf_probe_history = tf_probes; + tf_probe_history.format = RD::DATA_FORMAT_R16G16B16A16_SINT; //signed integer because SH are signed + tf_probe_history.array_layers = history_size; + + RD::TextureFormat tf_probe_average = tf_probes; + tf_probe_average.format = RD::DATA_FORMAT_R32G32B32A32_SINT; //signed integer because SH are signed + tf_probe_average.texture_type = RD::TEXTURE_TYPE_2D; + + lightprobe_history_scroll = RD::get_singleton()->texture_create(tf_probe_history, RD::TextureView()); + lightprobe_average_scroll = RD::get_singleton()->texture_create(tf_probe_average, RD::TextureView()); + + { + //octahedral lightprobes + RD::TextureFormat tf_octprobes = tf_probes; + tf_octprobes.array_layers = cascades.size() * 2; + tf_octprobes.format = RD::DATA_FORMAT_R32_UINT; //pack well with RGBE + tf_octprobes.width = probe_axis_count * probe_axis_count * (SDFGI::LIGHTPROBE_OCT_SIZE + 2); + tf_octprobes.height = probe_axis_count * (SDFGI::LIGHTPROBE_OCT_SIZE + 2); + tf_octprobes.shareable_formats.push_back(RD::DATA_FORMAT_R32_UINT); + tf_octprobes.shareable_formats.push_back(RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32); + //lightprobe texture is an octahedral texture + + lightprobe_data = RD::get_singleton()->texture_create(tf_octprobes, RD::TextureView()); + RD::TextureView tv; + tv.format_override = RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32; + lightprobe_texture = RD::get_singleton()->texture_create_shared(tv, lightprobe_data); + + //texture handling ambient data, to integrate with volumetric foc + RD::TextureFormat tf_ambient = tf_probes; + tf_ambient.array_layers = cascades.size(); + tf_ambient.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; //pack well with RGBE + tf_ambient.width = probe_axis_count * probe_axis_count; + tf_ambient.height = probe_axis_count; + tf_ambient.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; + //lightprobe texture is an octahedral texture + ambient_texture = RD::get_singleton()->texture_create(tf_ambient, RD::TextureView()); + } + + cascades_ubo = RD::get_singleton()->uniform_buffer_create(sizeof(SDFGI::Cascade::UBO) * SDFGI::MAX_CASCADES); + + occlusion_data = RD::get_singleton()->texture_create(tf_occlusion, RD::TextureView()); + { + RD::TextureView tv; + tv.format_override = RD::DATA_FORMAT_R4G4B4A4_UNORM_PACK16; + occlusion_texture = RD::get_singleton()->texture_create_shared(tv, occlusion_data); + } + + for (uint32_t i = 0; i < cascades.size(); i++) { + SDFGI::Cascade &cascade = cascades[i]; + + /* 3D Textures */ + + cascade.sdf_tex = RD::get_singleton()->texture_create(tf_sdf, RD::TextureView()); + + cascade.light_data = RD::get_singleton()->texture_create(tf_light, RD::TextureView()); + + cascade.light_aniso_0_tex = RD::get_singleton()->texture_create(tf_aniso0, RD::TextureView()); + cascade.light_aniso_1_tex = RD::get_singleton()->texture_create(tf_aniso1, RD::TextureView()); + + { + RD::TextureView tv; + tv.format_override = RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32; + cascade.light_tex = RD::get_singleton()->texture_create_shared(tv, cascade.light_data); + + RD::get_singleton()->texture_clear(cascade.light_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(cascade.light_aniso_0_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(cascade.light_aniso_1_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); + } + + cascade.cell_size = base_cell_size; + Vector3 world_position = p_world_position; + world_position.y *= y_mult; + int32_t probe_cells = cascade_size / SDFGI::PROBE_DIVISOR; + Vector3 probe_size = Vector3(1, 1, 1) * cascade.cell_size * probe_cells; + Vector3i probe_pos = Vector3i((world_position / probe_size + Vector3(0.5, 0.5, 0.5)).floor()); + cascade.position = probe_pos * probe_cells; + + cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL; + + base_cell_size *= 2.0; + + /* Probe History */ + + cascade.lightprobe_history_tex = RD::get_singleton()->texture_create(tf_probe_history, RD::TextureView()); + RD::get_singleton()->texture_clear(cascade.lightprobe_history_tex, Color(0, 0, 0, 0), 0, 1, 0, tf_probe_history.array_layers); //needs to be cleared for average to work + + cascade.lightprobe_average_tex = RD::get_singleton()->texture_create(tf_probe_average, RD::TextureView()); + RD::get_singleton()->texture_clear(cascade.lightprobe_average_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); //needs to be cleared for average to work + + /* Buffers */ + + cascade.solid_cell_buffer = RD::get_singleton()->storage_buffer_create(sizeof(SDFGI::Cascade::SolidCell) * solid_cell_count); + cascade.solid_cell_dispatch_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * 4, Vector<uint8_t>(), RD::STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT); + cascade.lights_buffer = RD::get_singleton()->storage_buffer_create(sizeof(SDFGIShader::Light) * MAX(SDFGI::MAX_STATIC_LIGHTS, SDFGI::MAX_DYNAMIC_LIGHTS)); + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_sdf[(passes & 1) ? 1 : 0]); //if passes are even, we read from buffer 0, else we read from buffer 1 + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 3; + for (int j = 0; j < 8; j++) { + u.ids.push_back(render_occlusion[j]); + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 4; + u.ids.push_back(render_emission); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 5; + u.ids.push_back(render_emission_aniso); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 6; + u.ids.push_back(render_geom_facing); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 7; + u.ids.push_back(cascade.sdf_tex); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 8; + u.ids.push_back(occlusion_data); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 10; + u.ids.push_back(cascade.solid_cell_dispatch_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 11; + u.ids.push_back(cascade.solid_cell_buffer); + uniforms.push_back(u); + } + + cascade.sdf_store_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_STORE), 0); + } + + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_geom_facing); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 3; + u.ids.push_back(render_emission); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 4; + u.ids.push_back(render_emission_aniso); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 5; + u.ids.push_back(cascade.solid_cell_dispatch_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 6; + u.ids.push_back(cascade.solid_cell_buffer); + uniforms.push_back(u); + } + + cascade.scroll_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_SCROLL), 0); + } + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + for (int j = 0; j < 8; j++) { + u.ids.push_back(render_occlusion[j]); + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(occlusion_data); + uniforms.push_back(u); + } + + cascade.scroll_occlusion_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_SCROLL_OCCLUSION), 0); + } + } + + //direct light + for (uint32_t i = 0; i < cascades.size(); i++) { + SDFGI::Cascade &cascade = cascades[i]; + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.binding = 1; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (j < cascades.size()) { + u.ids.push_back(cascades[j].sdf_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 2; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.ids.push_back(cascade.solid_cell_dispatch_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.ids.push_back(cascade.solid_cell_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 5; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.ids.push_back(cascade.light_data); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 6; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.ids.push_back(cascade.light_aniso_0_tex); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 7; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.ids.push_back(cascade.light_aniso_1_tex); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 8; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.ids.push_back(cascades_ubo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 9; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.ids.push_back(cascade.lights_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 10; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.ids.push_back(lightprobe_texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 11; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.ids.push_back(occlusion_texture); + uniforms.push_back(u); + } + + cascade.sdf_direct_light_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.direct_light.version_get_shader(gi->sdfgi_shader.direct_light_shader, 0), 0); + } + + //preprocess initialize uniform set + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_sdf[0]); + uniforms.push_back(u); + } + + sdf_initialize_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE), 0); + } + + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_sdf_half[0]); + uniforms.push_back(u); + } + + sdf_initialize_half_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE_HALF), 0); + } + + //jump flood uniform set + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_sdf[0]); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_sdf[1]); + uniforms.push_back(u); + } + + jump_flood_uniform_set[0] = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD), 0); + SWAP(uniforms.write[0].ids.write[0], uniforms.write[1].ids.write[0]); + jump_flood_uniform_set[1] = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD), 0); + } + //jump flood half uniform set + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_sdf_half[0]); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_sdf_half[1]); + uniforms.push_back(u); + } + + jump_flood_half_uniform_set[0] = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD), 0); + SWAP(uniforms.write[0].ids.write[0], uniforms.write[1].ids.write[0]); + jump_flood_half_uniform_set[1] = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD), 0); + } + + //upscale half size sdf + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + u.ids.push_back(render_sdf_half[(passes & 1) ? 0 : 1]); //reverse pass order because half size + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 3; + u.ids.push_back(render_sdf[(passes & 1) ? 0 : 1]); //reverse pass order because it needs an extra JFA pass + uniforms.push_back(u); + } + + upscale_jfa_uniform_set_index = (passes & 1) ? 0 : 1; + sdf_upscale_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_JUMP_FLOOD_UPSCALE), 0); + } + + //occlusion uniform set + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(render_albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 2; + for (int i = 0; i < 8; i++) { + u.ids.push_back(render_occlusion[i]); + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 3; + u.ids.push_back(render_geom_facing); + uniforms.push_back(u); + } + + occlusion_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.preprocess.version_get_shader(gi->sdfgi_shader.preprocess_shader, SDFGIShader::PRE_PROCESS_OCCLUSION), 0); + } + + for (uint32_t i = 0; i < cascades.size(); i++) { + //integrate uniform + + Vector<RD::Uniform> uniforms; + + { + RD::Uniform u; + u.binding = 1; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (j < cascades.size()) { + u.ids.push_back(cascades[j].sdf_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 2; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (j < cascades.size()) { + u.ids.push_back(cascades[j].light_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (j < cascades.size()) { + u.ids.push_back(cascades[j].light_aniso_0_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (j < cascades.size()) { + u.ids.push_back(cascades[j].light_aniso_1_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 6; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.binding = 7; + u.ids.push_back(cascades_ubo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 8; + u.ids.push_back(lightprobe_data); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 9; + u.ids.push_back(cascades[i].lightprobe_history_tex); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 10; + u.ids.push_back(cascades[i].lightprobe_average_tex); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 11; + u.ids.push_back(lightprobe_history_scroll); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 12; + u.ids.push_back(lightprobe_average_scroll); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 13; + RID parent_average; + if (i < cascades.size() - 1) { + parent_average = cascades[i + 1].lightprobe_average_tex; + } else { + parent_average = cascades[i - 1].lightprobe_average_tex; //to use something, but it won't be used + } + u.ids.push_back(parent_average); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 14; + u.ids.push_back(ambient_texture); + uniforms.push_back(u); + } + + cascades[i].integrate_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.integrate.version_get_shader(gi->sdfgi_shader.integrate_shader, 0), 0); + } + + bounce_feedback = p_env->sdfgi_bounce_feedback; + energy = p_env->sdfgi_energy; + normal_bias = p_env->sdfgi_normal_bias; + probe_bias = p_env->sdfgi_probe_bias; + reads_sky = p_env->sdfgi_read_sky_light; +} + +void RendererSceneGIRD::SDFGI::erase() { + for (uint32_t i = 0; i < cascades.size(); i++) { + const SDFGI::Cascade &c = cascades[i]; + RD::get_singleton()->free(c.light_data); + RD::get_singleton()->free(c.light_aniso_0_tex); + RD::get_singleton()->free(c.light_aniso_1_tex); + RD::get_singleton()->free(c.sdf_tex); + RD::get_singleton()->free(c.solid_cell_dispatch_buffer); + RD::get_singleton()->free(c.solid_cell_buffer); + RD::get_singleton()->free(c.lightprobe_history_tex); + RD::get_singleton()->free(c.lightprobe_average_tex); + RD::get_singleton()->free(c.lights_buffer); + } + + RD::get_singleton()->free(render_albedo); + RD::get_singleton()->free(render_emission); + RD::get_singleton()->free(render_emission_aniso); + + RD::get_singleton()->free(render_sdf[0]); + RD::get_singleton()->free(render_sdf[1]); + + RD::get_singleton()->free(render_sdf_half[0]); + RD::get_singleton()->free(render_sdf_half[1]); + + for (int i = 0; i < 8; i++) { + RD::get_singleton()->free(render_occlusion[i]); + } + + RD::get_singleton()->free(render_geom_facing); + + RD::get_singleton()->free(lightprobe_data); + RD::get_singleton()->free(lightprobe_history_scroll); + RD::get_singleton()->free(occlusion_data); + RD::get_singleton()->free(ambient_texture); + + RD::get_singleton()->free(cascades_ubo); +} + +void RendererSceneGIRD::SDFGI::update(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position) { + bounce_feedback = p_env->sdfgi_bounce_feedback; + energy = p_env->sdfgi_energy; + normal_bias = p_env->sdfgi_normal_bias; + probe_bias = p_env->sdfgi_probe_bias; + reads_sky = p_env->sdfgi_read_sky_light; + + int32_t drag_margin = (cascade_size / SDFGI::PROBE_DIVISOR) / 2; + + for (uint32_t i = 0; i < cascades.size(); i++) { + SDFGI::Cascade &cascade = cascades[i]; + cascade.dirty_regions = Vector3i(); + + Vector3 probe_half_size = Vector3(1, 1, 1) * cascade.cell_size * float(cascade_size / SDFGI::PROBE_DIVISOR) * 0.5; + probe_half_size = Vector3(0, 0, 0); + + Vector3 world_position = p_world_position; + world_position.y *= y_mult; + Vector3i pos_in_cascade = Vector3i((world_position + probe_half_size) / cascade.cell_size); + + for (int j = 0; j < 3; j++) { + if (pos_in_cascade[j] < cascade.position[j]) { + while (pos_in_cascade[j] < (cascade.position[j] - drag_margin)) { + cascade.position[j] -= drag_margin * 2; + cascade.dirty_regions[j] += drag_margin * 2; + } + } else if (pos_in_cascade[j] > cascade.position[j]) { + while (pos_in_cascade[j] > (cascade.position[j] + drag_margin)) { + cascade.position[j] += drag_margin * 2; + cascade.dirty_regions[j] -= drag_margin * 2; + } + } + + if (cascade.dirty_regions[j] == 0) { + continue; // not dirty + } else if (uint32_t(ABS(cascade.dirty_regions[j])) >= cascade_size) { + //moved too much, just redraw everything (make all dirty) + cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL; + break; + } + } + + if (cascade.dirty_regions != Vector3i() && cascade.dirty_regions != SDFGI::Cascade::DIRTY_ALL) { + //see how much the total dirty volume represents from the total volume + uint32_t total_volume = cascade_size * cascade_size * cascade_size; + uint32_t safe_volume = 1; + for (int j = 0; j < 3; j++) { + safe_volume *= cascade_size - ABS(cascade.dirty_regions[j]); + } + uint32_t dirty_volume = total_volume - safe_volume; + if (dirty_volume > (safe_volume / 2)) { + //more than half the volume is dirty, make all dirty so its only rendered once + cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL; + } + } + } +} + +void RendererSceneGIRD::SDFGI::update_light() { + RD::get_singleton()->draw_command_begin_label("SDFGI Update dynamic Light"); + + /* Update dynamic light */ + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.direct_light_pipeline[SDFGIShader::DIRECT_LIGHT_MODE_DYNAMIC]); + + SDFGIShader::DirectLightPushConstant push_constant; + + push_constant.grid_size[0] = cascade_size; + push_constant.grid_size[1] = cascade_size; + push_constant.grid_size[2] = cascade_size; + push_constant.max_cascades = cascades.size(); + push_constant.probe_axis_size = probe_axis_count; + push_constant.bounce_feedback = bounce_feedback; + push_constant.y_mult = y_mult; + push_constant.use_occlusion = uses_occlusion; + + for (uint32_t i = 0; i < cascades.size(); i++) { + SDFGI::Cascade &cascade = cascades[i]; + push_constant.light_count = cascade_dynamic_light_count[i]; + push_constant.cascade = i; + + if (cascades[i].all_dynamic_lights_dirty || gi->sdfgi_frames_to_update_light == RS::ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME) { + push_constant.process_offset = 0; + push_constant.process_increment = 1; + } else { + static uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = { + 1, 2, 4, 8, 16 + }; + + uint32_t frames_to_update = frames_to_update_table[gi->sdfgi_frames_to_update_light]; + + push_constant.process_offset = RSG::rasterizer->get_frame_number() % frames_to_update; + push_constant.process_increment = frames_to_update; + } + cascades[i].all_dynamic_lights_dirty = false; + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascade.sdf_direct_light_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::DirectLightPushConstant)); + RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cascade.solid_cell_dispatch_buffer, 0); + } + RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_COMPUTE); + RD::get_singleton()->draw_command_end_label(); +} + +void RendererSceneGIRD::SDFGI::update_probes(RendererSceneEnvironmentRD *p_env, RendererSceneSkyRD::Sky *p_sky) { + RD::get_singleton()->draw_command_begin_label("SDFGI Update Probes"); + + SDFGIShader::IntegratePushConstant push_constant; + push_constant.grid_size[1] = cascade_size; + push_constant.grid_size[2] = cascade_size; + push_constant.grid_size[0] = cascade_size; + push_constant.max_cascades = cascades.size(); + push_constant.probe_axis_size = probe_axis_count; + push_constant.history_index = render_pass % history_size; + push_constant.history_size = history_size; + static const uint32_t ray_count[RS::ENV_SDFGI_RAY_COUNT_MAX] = { 4, 8, 16, 32, 64, 96, 128 }; + push_constant.ray_count = ray_count[gi->sdfgi_ray_count]; + push_constant.ray_bias = probe_bias; + push_constant.image_size[0] = probe_axis_count * probe_axis_count; + push_constant.image_size[1] = probe_axis_count; + push_constant.store_ambient_texture = p_env->volumetric_fog_enabled; + + RID sky_uniform_set = gi->sdfgi_shader.integrate_default_sky_uniform_set; + push_constant.sky_mode = SDFGIShader::IntegratePushConstant::SKY_MODE_DISABLED; + push_constant.y_mult = y_mult; + + if (reads_sky && p_env) { + push_constant.sky_energy = p_env->bg_energy; + + if (p_env->background == RS::ENV_BG_CLEAR_COLOR) { + push_constant.sky_mode = SDFGIShader::IntegratePushConstant::SKY_MODE_COLOR; + Color c = storage->get_default_clear_color().to_linear(); + push_constant.sky_color[0] = c.r; + push_constant.sky_color[1] = c.g; + push_constant.sky_color[2] = c.b; + } else if (p_env->background == RS::ENV_BG_COLOR) { + push_constant.sky_mode = SDFGIShader::IntegratePushConstant::SKY_MODE_COLOR; + Color c = p_env->bg_color; + push_constant.sky_color[0] = c.r; + push_constant.sky_color[1] = c.g; + push_constant.sky_color[2] = c.b; + + } else if (p_env->background == RS::ENV_BG_SKY) { + if (p_sky && p_sky->radiance.is_valid()) { + if (integrate_sky_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(integrate_sky_uniform_set)) { + Vector<RD::Uniform> uniforms; + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 0; + u.ids.push_back(p_sky->radiance); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 1; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + integrate_sky_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.integrate.version_get_shader(gi->sdfgi_shader.integrate_shader, 0), 1); + } + sky_uniform_set = integrate_sky_uniform_set; + push_constant.sky_mode = SDFGIShader::IntegratePushConstant::SKY_MODE_SKY; + } + } + } + + render_pass++; + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(true); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.integrate_pipeline[SDFGIShader::INTEGRATE_MODE_PROCESS]); + + int32_t probe_divisor = cascade_size / SDFGI::PROBE_DIVISOR; + for (uint32_t i = 0; i < cascades.size(); i++) { + push_constant.cascade = i; + push_constant.world_offset[0] = cascades[i].position.x / probe_divisor; + push_constant.world_offset[1] = cascades[i].position.y / probe_divisor; + push_constant.world_offset[2] = cascades[i].position.z / probe_divisor; + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[i].integrate_uniform_set, 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sky_uniform_set, 1); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::IntegratePushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, probe_axis_count * probe_axis_count, probe_axis_count, 1); + } + + //end later after raster to avoid barriering on layout changes + //RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_NO_BARRIER); + + RD::get_singleton()->draw_command_end_label(); +} + +void RendererSceneGIRD::SDFGI::store_probes() { + RD::get_singleton()->barrier(RD::BARRIER_MASK_COMPUTE, RD::BARRIER_MASK_COMPUTE); + RD::get_singleton()->draw_command_begin_label("SDFGI Store Probes"); + + SDFGIShader::IntegratePushConstant push_constant; + push_constant.grid_size[1] = cascade_size; + push_constant.grid_size[2] = cascade_size; + push_constant.grid_size[0] = cascade_size; + push_constant.max_cascades = cascades.size(); + push_constant.probe_axis_size = probe_axis_count; + push_constant.history_index = render_pass % history_size; + push_constant.history_size = history_size; + static const uint32_t ray_count[RS::ENV_SDFGI_RAY_COUNT_MAX] = { 4, 8, 16, 32, 64, 96, 128 }; + push_constant.ray_count = ray_count[gi->sdfgi_ray_count]; + push_constant.ray_bias = probe_bias; + push_constant.image_size[0] = probe_axis_count * probe_axis_count; + push_constant.image_size[1] = probe_axis_count; + push_constant.store_ambient_texture = false; + + push_constant.sky_mode = 0; + push_constant.y_mult = y_mult; + + // Then store values into the lightprobe texture. Separating these steps has a small performance hit, but it allows for multiple bounces + RENDER_TIMESTAMP("Average Probes"); + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.integrate_pipeline[SDFGIShader::INTEGRATE_MODE_STORE]); + + //convert to octahedral to store + push_constant.image_size[0] *= SDFGI::LIGHTPROBE_OCT_SIZE; + push_constant.image_size[1] *= SDFGI::LIGHTPROBE_OCT_SIZE; + + for (uint32_t i = 0; i < cascades.size(); i++) { + push_constant.cascade = i; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[i].integrate_uniform_set, 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi->sdfgi_shader.integrate_default_sky_uniform_set, 1); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::IntegratePushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, probe_axis_count * probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, 1); + } + + RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_COMPUTE); + + RD::get_singleton()->draw_command_end_label(); +} + +int RendererSceneGIRD::SDFGI::get_pending_region_data(int p_region, Vector3i &r_local_offset, Vector3i &r_local_size, AABB &r_bounds) const { + int dirty_count = 0; + for (uint32_t i = 0; i < cascades.size(); i++) { + const SDFGI::Cascade &c = cascades[i]; + + if (c.dirty_regions == SDFGI::Cascade::DIRTY_ALL) { + if (dirty_count == p_region) { + r_local_offset = Vector3i(); + r_local_size = Vector3i(1, 1, 1) * cascade_size; + + r_bounds.position = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + c.position)) * c.cell_size * Vector3(1, 1.0 / y_mult, 1); + r_bounds.size = Vector3(r_local_size) * c.cell_size * Vector3(1, 1.0 / y_mult, 1); + return i; + } + dirty_count++; + } else { + for (int j = 0; j < 3; j++) { + if (c.dirty_regions[j] != 0) { + if (dirty_count == p_region) { + Vector3i from = Vector3i(0, 0, 0); + Vector3i to = Vector3i(1, 1, 1) * cascade_size; + + if (c.dirty_regions[j] > 0) { + //fill from the beginning + to[j] = c.dirty_regions[j]; + } else { + //fill from the end + from[j] = to[j] + c.dirty_regions[j]; + } + + for (int k = 0; k < j; k++) { + // "chip" away previous regions to avoid re-voxelizing the same thing + if (c.dirty_regions[k] > 0) { + from[k] += c.dirty_regions[k]; + } else if (c.dirty_regions[k] < 0) { + to[k] += c.dirty_regions[k]; + } + } + + r_local_offset = from; + r_local_size = to - from; + + r_bounds.position = Vector3(from + Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + c.position) * c.cell_size * Vector3(1, 1.0 / y_mult, 1); + r_bounds.size = Vector3(r_local_size) * c.cell_size * Vector3(1, 1.0 / y_mult, 1); + + return i; + } + + dirty_count++; + } + } + } + } + return -1; +} + +void RendererSceneGIRD::SDFGI::update_cascades() { + //update cascades + SDFGI::Cascade::UBO cascade_data[SDFGI::MAX_CASCADES]; + int32_t probe_divisor = cascade_size / SDFGI::PROBE_DIVISOR; + + for (uint32_t i = 0; i < cascades.size(); i++) { + Vector3 pos = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + cascades[i].position)) * cascades[i].cell_size; + + cascade_data[i].offset[0] = pos.x; + cascade_data[i].offset[1] = pos.y; + cascade_data[i].offset[2] = pos.z; + cascade_data[i].to_cell = 1.0 / cascades[i].cell_size; + cascade_data[i].probe_offset[0] = cascades[i].position.x / probe_divisor; + cascade_data[i].probe_offset[1] = cascades[i].position.y / probe_divisor; + cascade_data[i].probe_offset[2] = cascades[i].position.z / probe_divisor; + cascade_data[i].pad = 0; + } + + RD::get_singleton()->buffer_update(cascades_ubo, 0, sizeof(SDFGI::Cascade::UBO) * SDFGI::MAX_CASCADES, cascade_data, RD::BARRIER_MASK_COMPUTE); +} + +void RendererSceneGIRD::SDFGI::debug_draw(const CameraMatrix &p_projection, const Transform &p_transform, int p_width, int p_height, RID p_render_target, RID p_texture) { + if (!debug_uniform_set.is_valid() || !RD::get_singleton()->uniform_set_is_valid(debug_uniform_set)) { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.binding = 1; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { + if (i < cascades.size()) { + u.ids.push_back(cascades[i].sdf_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 2; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { + if (i < cascades.size()) { + u.ids.push_back(cascades[i].light_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { + if (i < cascades.size()) { + u.ids.push_back(cascades[i].light_aniso_0_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { + if (i < cascades.size()) { + u.ids.push_back(cascades[i].light_aniso_1_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 5; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.ids.push_back(occlusion_texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 8; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 9; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.ids.push_back(cascades_ubo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 10; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.ids.push_back(p_texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 11; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.ids.push_back(lightprobe_texture); + uniforms.push_back(u); + } + debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.debug_shader_version, 0); + } + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.debug_pipeline); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, debug_uniform_set, 0); + + SDFGIShader::DebugPushConstant push_constant; + push_constant.grid_size[0] = cascade_size; + push_constant.grid_size[1] = cascade_size; + push_constant.grid_size[2] = cascade_size; + push_constant.max_cascades = cascades.size(); + push_constant.screen_size[0] = p_width; + push_constant.screen_size[1] = p_height; + push_constant.probe_axis_size = probe_axis_count; + push_constant.use_occlusion = uses_occlusion; + push_constant.y_mult = y_mult; + + Vector2 vp_half = p_projection.get_viewport_half_extents(); + push_constant.cam_extent[0] = vp_half.x; + push_constant.cam_extent[1] = vp_half.y; + push_constant.cam_extent[2] = -p_projection.get_z_near(); + + push_constant.cam_transform[0] = p_transform.basis.elements[0][0]; + push_constant.cam_transform[1] = p_transform.basis.elements[1][0]; + push_constant.cam_transform[2] = p_transform.basis.elements[2][0]; + push_constant.cam_transform[3] = 0; + push_constant.cam_transform[4] = p_transform.basis.elements[0][1]; + push_constant.cam_transform[5] = p_transform.basis.elements[1][1]; + push_constant.cam_transform[6] = p_transform.basis.elements[2][1]; + push_constant.cam_transform[7] = 0; + push_constant.cam_transform[8] = p_transform.basis.elements[0][2]; + push_constant.cam_transform[9] = p_transform.basis.elements[1][2]; + push_constant.cam_transform[10] = p_transform.basis.elements[2][2]; + push_constant.cam_transform[11] = 0; + push_constant.cam_transform[12] = p_transform.origin.x; + push_constant.cam_transform[13] = p_transform.origin.y; + push_constant.cam_transform[14] = p_transform.origin.z; + push_constant.cam_transform[15] = 1; + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::DebugPushConstant)); + + RD::get_singleton()->compute_list_dispatch_threads(compute_list, p_width, p_height, 1); + RD::get_singleton()->compute_list_end(); + + Size2 rtsize = storage->render_target_get_size(p_render_target); + storage->get_effects()->copy_to_fb_rect(p_texture, storage->render_target_get_rd_framebuffer(p_render_target), Rect2(Vector2(), rtsize), true); +} + +void RendererSceneGIRD::SDFGI::debug_probes(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform) { + SDFGIShader::DebugProbesPushConstant push_constant; + + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + push_constant.projection[i * 4 + j] = p_camera_with_transform.matrix[i][j]; + } + } + + //gen spheres from strips + uint32_t band_points = 16; + push_constant.band_power = 4; + push_constant.sections_in_band = ((band_points / 2) - 1); + push_constant.band_mask = band_points - 2; + push_constant.section_arc = Math_TAU / float(push_constant.sections_in_band); + push_constant.y_mult = y_mult; + + uint32_t total_points = push_constant.sections_in_band * band_points; + uint32_t total_probes = probe_axis_count * probe_axis_count * probe_axis_count; + + push_constant.grid_size[0] = cascade_size; + push_constant.grid_size[1] = cascade_size; + push_constant.grid_size[2] = cascade_size; + push_constant.cascade = 0; + + push_constant.probe_axis_size = probe_axis_count; + + if (!debug_probes_uniform_set.is_valid() || !RD::get_singleton()->uniform_set_is_valid(debug_probes_uniform_set)) { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.binding = 1; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.ids.push_back(cascades_ubo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 2; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.ids.push_back(lightprobe_texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.ids.push_back(occlusion_texture); + uniforms.push_back(u); + } + + debug_probes_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.debug_probes.version_get_shader(gi->sdfgi_shader.debug_probes_shader, 0), 0); + } + + RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, gi->sdfgi_shader.debug_probes_pipeline[SDFGIShader::PROBE_DEBUG_PROBES].get_render_pipeline(RD::INVALID_FORMAT_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, debug_probes_uniform_set, 0); + RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(SDFGIShader::DebugProbesPushConstant)); + RD::get_singleton()->draw_list_draw(p_draw_list, false, total_probes, total_points); + + if (gi->sdfgi_debug_probe_dir != Vector3()) { + print_line("CLICK DEBUG ME?"); + uint32_t cascade = 0; + Vector3 offset = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + cascades[cascade].position)) * cascades[cascade].cell_size * Vector3(1.0, 1.0 / y_mult, 1.0); + Vector3 probe_size = cascades[cascade].cell_size * (cascade_size / SDFGI::PROBE_DIVISOR) * Vector3(1.0, 1.0 / y_mult, 1.0); + Vector3 ray_from = gi->sdfgi_debug_probe_pos; + Vector3 ray_to = gi->sdfgi_debug_probe_pos + gi->sdfgi_debug_probe_dir * cascades[cascade].cell_size * Math::sqrt(3.0) * cascade_size; + float sphere_radius = 0.2; + float closest_dist = 1e20; + gi->sdfgi_debug_probe_enabled = false; + + Vector3i probe_from = cascades[cascade].position / (cascade_size / SDFGI::PROBE_DIVISOR); + for (int i = 0; i < (SDFGI::PROBE_DIVISOR + 1); i++) { + for (int j = 0; j < (SDFGI::PROBE_DIVISOR + 1); j++) { + for (int k = 0; k < (SDFGI::PROBE_DIVISOR + 1); k++) { + Vector3 pos = offset + probe_size * Vector3(i, j, k); + Vector3 res; + if (Geometry3D::segment_intersects_sphere(ray_from, ray_to, pos, sphere_radius, &res)) { + float d = ray_from.distance_to(res); + if (d < closest_dist) { + closest_dist = d; + gi->sdfgi_debug_probe_enabled = true; + gi->sdfgi_debug_probe_index = probe_from + Vector3i(i, j, k); + } + } + } + } + } + + if (gi->sdfgi_debug_probe_enabled) { + print_line("found: " + gi->sdfgi_debug_probe_index); + } else { + print_line("no found"); + } + gi->sdfgi_debug_probe_dir = Vector3(); + } + + if (gi->sdfgi_debug_probe_enabled) { + uint32_t cascade = 0; + uint32_t probe_cells = (cascade_size / SDFGI::PROBE_DIVISOR); + Vector3i probe_from = cascades[cascade].position / probe_cells; + Vector3i ofs = gi->sdfgi_debug_probe_index - probe_from; + if (ofs.x < 0 || ofs.y < 0 || ofs.z < 0) { + return; + } + if (ofs.x > SDFGI::PROBE_DIVISOR || ofs.y > SDFGI::PROBE_DIVISOR || ofs.z > SDFGI::PROBE_DIVISOR) { + return; + } + + uint32_t mult = (SDFGI::PROBE_DIVISOR + 1); + uint32_t index = ofs.z * mult * mult + ofs.y * mult + ofs.x; + + push_constant.probe_debug_index = index; + + uint32_t cell_count = probe_cells * 2 * probe_cells * 2 * probe_cells * 2; + + RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, gi->sdfgi_shader.debug_probes_pipeline[SDFGIShader::PROBE_DEBUG_VISIBILITY].get_render_pipeline(RD::INVALID_FORMAT_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, debug_probes_uniform_set, 0); + RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(SDFGIShader::DebugProbesPushConstant)); + RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, total_points); + } +} + +void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform &p_transform, RendererSceneRenderRD *p_scene_render) { + /* Update general SDFGI Buffer */ + + SDFGIData sdfgi_data; + + sdfgi_data.grid_size[0] = cascade_size; + sdfgi_data.grid_size[1] = cascade_size; + sdfgi_data.grid_size[2] = cascade_size; + + sdfgi_data.max_cascades = cascades.size(); + sdfgi_data.probe_axis_size = probe_axis_count; + sdfgi_data.cascade_probe_size[0] = sdfgi_data.probe_axis_size - 1; //float version for performance + sdfgi_data.cascade_probe_size[1] = sdfgi_data.probe_axis_size - 1; + sdfgi_data.cascade_probe_size[2] = sdfgi_data.probe_axis_size - 1; + + float csize = cascade_size; + sdfgi_data.probe_to_uvw = 1.0 / float(sdfgi_data.cascade_probe_size[0]); + sdfgi_data.use_occlusion = uses_occlusion; + //sdfgi_data.energy = energy; + + sdfgi_data.y_mult = y_mult; + + float cascade_voxel_size = (csize / sdfgi_data.cascade_probe_size[0]); + float occlusion_clamp = (cascade_voxel_size - 0.5) / cascade_voxel_size; + sdfgi_data.occlusion_clamp[0] = occlusion_clamp; + sdfgi_data.occlusion_clamp[1] = occlusion_clamp; + sdfgi_data.occlusion_clamp[2] = occlusion_clamp; + sdfgi_data.normal_bias = (normal_bias / csize) * sdfgi_data.cascade_probe_size[0]; + + //vec2 tex_pixel_size = 1.0 / vec2(ivec2( (OCT_SIZE+2) * params.probe_axis_size * params.probe_axis_size, (OCT_SIZE+2) * params.probe_axis_size ) ); + //vec3 probe_uv_offset = (ivec3(OCT_SIZE+2,OCT_SIZE+2,(OCT_SIZE+2) * params.probe_axis_size)) * tex_pixel_size.xyx; + + uint32_t oct_size = SDFGI::LIGHTPROBE_OCT_SIZE; + + sdfgi_data.lightprobe_tex_pixel_size[0] = 1.0 / ((oct_size + 2) * sdfgi_data.probe_axis_size * sdfgi_data.probe_axis_size); + sdfgi_data.lightprobe_tex_pixel_size[1] = 1.0 / ((oct_size + 2) * sdfgi_data.probe_axis_size); + sdfgi_data.lightprobe_tex_pixel_size[2] = 1.0; + + sdfgi_data.energy = energy; + + sdfgi_data.lightprobe_uv_offset[0] = float(oct_size + 2) * sdfgi_data.lightprobe_tex_pixel_size[0]; + sdfgi_data.lightprobe_uv_offset[1] = float(oct_size + 2) * sdfgi_data.lightprobe_tex_pixel_size[1]; + sdfgi_data.lightprobe_uv_offset[2] = float((oct_size + 2) * sdfgi_data.probe_axis_size) * sdfgi_data.lightprobe_tex_pixel_size[0]; + + sdfgi_data.occlusion_renormalize[0] = 0.5; + sdfgi_data.occlusion_renormalize[1] = 1.0; + sdfgi_data.occlusion_renormalize[2] = 1.0 / float(sdfgi_data.max_cascades); + + int32_t probe_divisor = cascade_size / SDFGI::PROBE_DIVISOR; + + for (uint32_t i = 0; i < sdfgi_data.max_cascades; i++) { + SDFGIData::ProbeCascadeData &c = sdfgi_data.cascades[i]; + Vector3 pos = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + cascades[i].position)) * cascades[i].cell_size; + Vector3 cam_origin = p_transform.origin; + cam_origin.y *= y_mult; + pos -= cam_origin; //make pos local to camera, to reduce numerical error + c.position[0] = pos.x; + c.position[1] = pos.y; + c.position[2] = pos.z; + c.to_probe = 1.0 / (float(cascade_size) * cascades[i].cell_size / float(probe_axis_count - 1)); + + Vector3i probe_ofs = cascades[i].position / probe_divisor; + c.probe_world_offset[0] = probe_ofs.x; + c.probe_world_offset[1] = probe_ofs.y; + c.probe_world_offset[2] = probe_ofs.z; + + c.to_cell = 1.0 / cascades[i].cell_size; + } + + RD::get_singleton()->buffer_update(gi->sdfgi_ubo, 0, sizeof(SDFGIData), &sdfgi_data, RD::BARRIER_MASK_COMPUTE); + + /* Update dynamic lights in SDFGI cascades */ + + for (uint32_t i = 0; i < cascades.size(); i++) { + SDFGI::Cascade &cascade = cascades[i]; + + SDFGIShader::Light lights[SDFGI::MAX_DYNAMIC_LIGHTS]; + uint32_t idx = 0; + for (uint32_t j = 0; j < (uint32_t)p_scene_render->render_state.sdfgi_update_data->directional_lights->size(); j++) { + if (idx == SDFGI::MAX_DYNAMIC_LIGHTS) { + break; + } + + RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_scene_render->render_state.sdfgi_update_data->directional_lights->get(j)); + ERR_CONTINUE(!li); + + if (storage->light_directional_is_sky_only(li->light)) { + continue; + } + + Vector3 dir = -li->transform.basis.get_axis(Vector3::AXIS_Z); + dir.y *= y_mult; + dir.normalize(); + lights[idx].direction[0] = dir.x; + lights[idx].direction[1] = dir.y; + lights[idx].direction[2] = dir.z; + Color color = storage->light_get_color(li->light); + color = color.to_linear(); + lights[idx].color[0] = color.r; + lights[idx].color[1] = color.g; + lights[idx].color[2] = color.b; + lights[idx].type = RS::LIGHT_DIRECTIONAL; + lights[idx].energy = storage->light_get_param(li->light, RS::LIGHT_PARAM_ENERGY); + lights[idx].has_shadow = storage->light_has_shadow(li->light); + + idx++; + } + + AABB cascade_aabb; + cascade_aabb.position = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + cascade.position)) * cascade.cell_size; + cascade_aabb.size = Vector3(1, 1, 1) * cascade_size * cascade.cell_size; + + for (uint32_t j = 0; j < p_scene_render->render_state.sdfgi_update_data->positional_light_count; j++) { + if (idx == SDFGI::MAX_DYNAMIC_LIGHTS) { + break; + } + + RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_scene_render->render_state.sdfgi_update_data->positional_light_instances[j]); + ERR_CONTINUE(!li); + + uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light); + if (i > max_sdfgi_cascade) { + continue; + } + + if (!cascade_aabb.intersects(li->aabb)) { + continue; + } + + Vector3 dir = -li->transform.basis.get_axis(Vector3::AXIS_Z); + //faster to not do this here + //dir.y *= y_mult; + //dir.normalize(); + lights[idx].direction[0] = dir.x; + lights[idx].direction[1] = dir.y; + lights[idx].direction[2] = dir.z; + Vector3 pos = li->transform.origin; + pos.y *= y_mult; + lights[idx].position[0] = pos.x; + lights[idx].position[1] = pos.y; + lights[idx].position[2] = pos.z; + Color color = storage->light_get_color(li->light); + color = color.to_linear(); + lights[idx].color[0] = color.r; + lights[idx].color[1] = color.g; + lights[idx].color[2] = color.b; + lights[idx].type = storage->light_get_type(li->light); + lights[idx].energy = storage->light_get_param(li->light, RS::LIGHT_PARAM_ENERGY); + lights[idx].has_shadow = storage->light_has_shadow(li->light); + lights[idx].attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_ATTENUATION); + lights[idx].radius = storage->light_get_param(li->light, RS::LIGHT_PARAM_RANGE); + lights[idx].cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE))); + lights[idx].inv_spot_attenuation = 1.0f / storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); + + idx++; + } + + if (idx > 0) { + RD::get_singleton()->buffer_update(cascade.lights_buffer, 0, idx * sizeof(SDFGIShader::Light), lights, RD::BARRIER_MASK_COMPUTE); + } + + cascade_dynamic_light_count[i] = idx; + } +} + +void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region, const PagedArray<RendererSceneRender::GeometryInstance *> &p_instances, RendererSceneRenderRD *p_scene_render) { + //print_line("rendering region " + itos(p_region)); + RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND(!rb); // we wouldn't be here if this failed but... + AABB bounds; + Vector3i from; + Vector3i size; + + int cascade_prev = get_pending_region_data(p_region - 1, from, size, bounds); + int cascade_next = get_pending_region_data(p_region + 1, from, size, bounds); + int cascade = get_pending_region_data(p_region, from, size, bounds); + ERR_FAIL_COND(cascade < 0); + + if (cascade_prev != cascade) { + //initialize render + RD::get_singleton()->texture_clear(render_albedo, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(render_emission, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(render_emission_aniso, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(render_geom_facing, Color(0, 0, 0, 0), 0, 1, 0, 1); + } + + //print_line("rendering cascade " + itos(p_region) + " objects: " + itos(p_cull_count) + " bounds: " + bounds + " from: " + from + " size: " + size + " cell size: " + rtos(cascades[cascade].cell_size)); + p_scene_render->_render_sdfgi(p_render_buffers, from, size, bounds, p_instances, render_albedo, render_emission, render_emission_aniso, render_geom_facing); + + if (cascade_next != cascade) { + RD::get_singleton()->draw_command_begin_label("SDFGI Pre-Process Cascade"); + + RENDER_TIMESTAMP(">SDFGI Update SDF"); + //done rendering! must update SDF + //clear dispatch indirect data + + SDFGIShader::PreprocessPushConstant push_constant; + zeromem(&push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + + RENDER_TIMESTAMP("Scroll SDF"); + + //scroll + if (cascades[cascade].dirty_regions != SDFGI::Cascade::DIRTY_ALL) { + //for scroll + Vector3i dirty = cascades[cascade].dirty_regions; + push_constant.scroll[0] = dirty.x; + push_constant.scroll[1] = dirty.y; + push_constant.scroll[2] = dirty.z; + } else { + //for no scroll + push_constant.scroll[0] = 0; + push_constant.scroll[1] = 0; + push_constant.scroll[2] = 0; + } + + cascades[cascade].all_dynamic_lights_dirty = true; + + push_constant.grid_size = cascade_size; + push_constant.cascade = cascade; + + if (cascades[cascade].dirty_regions != SDFGI::Cascade::DIRTY_ALL) { + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + + //must pre scroll existing data because not all is dirty + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_SCROLL]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[cascade].scroll_uniform_set, 0); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cascades[cascade].solid_cell_dispatch_buffer, 0); + // no barrier do all together + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_SCROLL_OCCLUSION]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[cascade].scroll_occlusion_uniform_set, 0); + + Vector3i dirty = cascades[cascade].dirty_regions; + Vector3i groups; + groups.x = cascade_size - ABS(dirty.x); + groups.y = cascade_size - ABS(dirty.y); + groups.z = cascade_size - ABS(dirty.z); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, groups.x, groups.y, groups.z); + + //no barrier, continue together + + { + //scroll probes and their history also + + SDFGIShader::IntegratePushConstant ipush_constant; + ipush_constant.grid_size[1] = cascade_size; + ipush_constant.grid_size[2] = cascade_size; + ipush_constant.grid_size[0] = cascade_size; + ipush_constant.max_cascades = cascades.size(); + ipush_constant.probe_axis_size = probe_axis_count; + ipush_constant.history_index = 0; + ipush_constant.history_size = history_size; + ipush_constant.ray_count = 0; + ipush_constant.ray_bias = 0; + ipush_constant.sky_mode = 0; + ipush_constant.sky_energy = 0; + ipush_constant.sky_color[0] = 0; + ipush_constant.sky_color[1] = 0; + ipush_constant.sky_color[2] = 0; + ipush_constant.y_mult = y_mult; + ipush_constant.store_ambient_texture = false; + + ipush_constant.image_size[0] = probe_axis_count * probe_axis_count; + ipush_constant.image_size[1] = probe_axis_count; + + int32_t probe_divisor = cascade_size / SDFGI::PROBE_DIVISOR; + ipush_constant.cascade = cascade; + ipush_constant.world_offset[0] = cascades[cascade].position.x / probe_divisor; + ipush_constant.world_offset[1] = cascades[cascade].position.y / probe_divisor; + ipush_constant.world_offset[2] = cascades[cascade].position.z / probe_divisor; + + ipush_constant.scroll[0] = dirty.x / probe_divisor; + ipush_constant.scroll[1] = dirty.y / probe_divisor; + ipush_constant.scroll[2] = dirty.z / probe_divisor; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.integrate_pipeline[SDFGIShader::INTEGRATE_MODE_SCROLL]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[cascade].integrate_uniform_set, 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi->sdfgi_shader.integrate_default_sky_uniform_set, 1); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ipush_constant, sizeof(SDFGIShader::IntegratePushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, probe_axis_count * probe_axis_count, probe_axis_count, 1); + + RD::get_singleton()->compute_list_add_barrier(compute_list); + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.integrate_pipeline[SDFGIShader::INTEGRATE_MODE_SCROLL_STORE]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[cascade].integrate_uniform_set, 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi->sdfgi_shader.integrate_default_sky_uniform_set, 1); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ipush_constant, sizeof(SDFGIShader::IntegratePushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, probe_axis_count * probe_axis_count, probe_axis_count, 1); + + RD::get_singleton()->compute_list_add_barrier(compute_list); + + if (bounce_feedback > 0.0) { + //multibounce requires this to be stored so direct light can read from it + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.integrate_pipeline[SDFGIShader::INTEGRATE_MODE_STORE]); + + //convert to octahedral to store + ipush_constant.image_size[0] *= SDFGI::LIGHTPROBE_OCT_SIZE; + ipush_constant.image_size[1] *= SDFGI::LIGHTPROBE_OCT_SIZE; + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[cascade].integrate_uniform_set, 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi->sdfgi_shader.integrate_default_sky_uniform_set, 1); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ipush_constant, sizeof(SDFGIShader::IntegratePushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, probe_axis_count * probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, 1); + } + } + + //ok finally barrier + RD::get_singleton()->compute_list_end(); + } + + //clear dispatch indirect data + uint32_t dispatch_indirct_data[4] = { 0, 0, 0, 0 }; + RD::get_singleton()->buffer_update(cascades[cascade].solid_cell_dispatch_buffer, 0, sizeof(uint32_t) * 4, dispatch_indirct_data); + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + + bool half_size = true; //much faster, very little difference + static const int optimized_jf_group_size = 8; + + if (half_size) { + push_constant.grid_size >>= 1; + + uint32_t cascade_half_size = cascade_size >> 1; + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE_HALF]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdf_initialize_half_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_half_size, cascade_half_size, cascade_half_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + + //must start with regular jumpflood + + push_constant.half_size = true; + { + RENDER_TIMESTAMP("SDFGI Jump Flood (Half Size)"); + + uint32_t s = cascade_half_size; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD]); + + int jf_us = 0; + //start with regular jump flood for very coarse reads, as this is impossible to optimize + while (s > 1) { + s /= 2; + push_constant.step_size = s; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, jump_flood_half_uniform_set[jf_us], 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_half_size, cascade_half_size, cascade_half_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + jf_us = jf_us == 0 ? 1 : 0; + + if (cascade_half_size / (s / 2) >= optimized_jf_group_size) { + break; + } + } + + RENDER_TIMESTAMP("SDFGI Jump Flood Optimized (Half Size)"); + + //continue with optimized jump flood for smaller reads + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD_OPTIMIZED]); + while (s > 1) { + s /= 2; + push_constant.step_size = s; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, jump_flood_half_uniform_set[jf_us], 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_half_size, cascade_half_size, cascade_half_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + jf_us = jf_us == 0 ? 1 : 0; + } + } + + // restore grid size for last passes + push_constant.grid_size = cascade_size; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD_UPSCALE]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdf_upscale_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_size, cascade_size, cascade_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + + //run one pass of fullsize jumpflood to fix up half size arctifacts + + push_constant.half_size = false; + push_constant.step_size = 1; + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD_OPTIMIZED]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, jump_flood_uniform_set[upscale_jfa_uniform_set_index], 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_size, cascade_size, cascade_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + + } else { + //full size jumpflood + RENDER_TIMESTAMP("SDFGI Jump Flood"); + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdf_initialize_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_size, cascade_size, cascade_size); + + RD::get_singleton()->compute_list_add_barrier(compute_list); + + push_constant.half_size = false; + { + uint32_t s = cascade_size; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD]); + + int jf_us = 0; + //start with regular jump flood for very coarse reads, as this is impossible to optimize + while (s > 1) { + s /= 2; + push_constant.step_size = s; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, jump_flood_uniform_set[jf_us], 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_size, cascade_size, cascade_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + jf_us = jf_us == 0 ? 1 : 0; + + if (cascade_size / (s / 2) >= optimized_jf_group_size) { + break; + } + } + + RENDER_TIMESTAMP("SDFGI Jump Flood Optimized"); + + //continue with optimized jump flood for smaller reads + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_JUMP_FLOOD_OPTIMIZED]); + while (s > 1) { + s /= 2; + push_constant.step_size = s; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, jump_flood_uniform_set[jf_us], 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_size, cascade_size, cascade_size); + RD::get_singleton()->compute_list_add_barrier(compute_list); + jf_us = jf_us == 0 ? 1 : 0; + } + } + } + + RENDER_TIMESTAMP("SDFGI Occlusion"); + + // occlusion + { + uint32_t probe_size = cascade_size / SDFGI::PROBE_DIVISOR; + Vector3i probe_global_pos = cascades[cascade].position / probe_size; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_OCCLUSION]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, occlusion_uniform_set, 0); + for (int i = 0; i < 8; i++) { + //dispatch all at once for performance + Vector3i offset(i & 1, (i >> 1) & 1, (i >> 2) & 1); + + if ((probe_global_pos.x & 1) != 0) { + offset.x = (offset.x + 1) & 1; + } + if ((probe_global_pos.y & 1) != 0) { + offset.y = (offset.y + 1) & 1; + } + if ((probe_global_pos.z & 1) != 0) { + offset.z = (offset.z + 1) & 1; + } + push_constant.probe_offset[0] = offset.x; + push_constant.probe_offset[1] = offset.y; + push_constant.probe_offset[2] = offset.z; + push_constant.occlusion_index = i; + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + + Vector3i groups = Vector3i(probe_size + 1, probe_size + 1, probe_size + 1) - offset; //if offset, it's one less probe per axis to compute + RD::get_singleton()->compute_list_dispatch(compute_list, groups.x, groups.y, groups.z); + } + RD::get_singleton()->compute_list_add_barrier(compute_list); + } + + RENDER_TIMESTAMP("SDFGI Store"); + + // store + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.preprocess_pipeline[SDFGIShader::PRE_PROCESS_STORE]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascades[cascade].sdf_store_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_size, cascade_size, cascade_size); + + RD::get_singleton()->compute_list_end(); + + //clear these textures, as they will have previous garbage on next draw + RD::get_singleton()->texture_clear(cascades[cascade].light_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(cascades[cascade].light_aniso_0_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); + RD::get_singleton()->texture_clear(cascades[cascade].light_aniso_1_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); + +#if 0 + Vector<uint8_t> data = RD::get_singleton()->texture_get_data(cascades[cascade].sdf, 0); + Ref<Image> img; + img.instance(); + for (uint32_t i = 0; i < cascade_size; i++) { + Vector<uint8_t> subarr = data.subarray(128 * 128 * i, 128 * 128 * (i + 1) - 1); + img->create(cascade_size, cascade_size, false, Image::FORMAT_L8, subarr); + img->save_png("res://cascade_sdf_" + itos(cascade) + "_" + itos(i) + ".png"); + } + + //finalize render and update sdf +#endif + +#if 0 + Vector<uint8_t> data = RD::get_singleton()->texture_get_data(render_albedo, 0); + Ref<Image> img; + img.instance(); + for (uint32_t i = 0; i < cascade_size; i++) { + Vector<uint8_t> subarr = data.subarray(128 * 128 * i * 2, 128 * 128 * (i + 1) * 2 - 1); + img->createcascade_size, cascade_size, false, Image::FORMAT_RGB565, subarr); + img->convert(Image::FORMAT_RGBA8); + img->save_png("res://cascade_" + itos(cascade) + "_" + itos(i) + ".png"); + } + + //finalize render and update sdf +#endif + + RENDER_TIMESTAMP("<SDFGI Update SDF"); + RD::get_singleton()->draw_command_end_label(); + } +} + +void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32_t p_cascade_count, const uint32_t *p_cascade_indices, const PagedArray<RID> *p_positional_light_cull_result, RendererSceneRenderRD *p_scene_render) { + RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND(!rb); // we wouldn't be here if this failed but... + + RD::get_singleton()->draw_command_begin_label("SDFGI Render Static Lighs"); + + update_cascades(); + ; //need cascades updated for this + + SDFGIShader::Light lights[SDFGI::MAX_STATIC_LIGHTS]; + uint32_t light_count[SDFGI::MAX_STATIC_LIGHTS]; + + for (uint32_t i = 0; i < p_cascade_count; i++) { + ERR_CONTINUE(p_cascade_indices[i] >= cascades.size()); + + SDFGI::Cascade &cc = cascades[p_cascade_indices[i]]; + + { //fill light buffer + + AABB cascade_aabb; + cascade_aabb.position = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + cc.position)) * cc.cell_size; + cascade_aabb.size = Vector3(1, 1, 1) * cascade_size * cc.cell_size; + + int idx = 0; + + for (uint32_t j = 0; j < (uint32_t)p_positional_light_cull_result[i].size(); j++) { + if (idx == SDFGI::MAX_STATIC_LIGHTS) { + break; + } + + RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_positional_light_cull_result[i][j]); + ERR_CONTINUE(!li); + + uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light); + if (p_cascade_indices[i] > max_sdfgi_cascade) { + continue; + } + + if (!cascade_aabb.intersects(li->aabb)) { + continue; + } + + lights[idx].type = storage->light_get_type(li->light); + + Vector3 dir = -li->transform.basis.get_axis(Vector3::AXIS_Z); + if (lights[idx].type == RS::LIGHT_DIRECTIONAL) { + dir.y *= y_mult; //only makes sense for directional + dir.normalize(); + } + lights[idx].direction[0] = dir.x; + lights[idx].direction[1] = dir.y; + lights[idx].direction[2] = dir.z; + Vector3 pos = li->transform.origin; + pos.y *= y_mult; + lights[idx].position[0] = pos.x; + lights[idx].position[1] = pos.y; + lights[idx].position[2] = pos.z; + Color color = storage->light_get_color(li->light); + color = color.to_linear(); + lights[idx].color[0] = color.r; + lights[idx].color[1] = color.g; + lights[idx].color[2] = color.b; + lights[idx].energy = storage->light_get_param(li->light, RS::LIGHT_PARAM_ENERGY); + lights[idx].has_shadow = storage->light_has_shadow(li->light); + lights[idx].attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_ATTENUATION); + lights[idx].radius = storage->light_get_param(li->light, RS::LIGHT_PARAM_RANGE); + lights[idx].cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE))); + lights[idx].inv_spot_attenuation = 1.0f / storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); + + idx++; + } + + if (idx > 0) { + RD::get_singleton()->buffer_update(cc.lights_buffer, 0, idx * sizeof(SDFGIShader::Light), lights); + } + + light_count[i] = idx; + } + } + + /* Static Lights */ + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->sdfgi_shader.direct_light_pipeline[SDFGIShader::DIRECT_LIGHT_MODE_STATIC]); + + SDFGIShader::DirectLightPushConstant dl_push_constant; + + dl_push_constant.grid_size[0] = cascade_size; + dl_push_constant.grid_size[1] = cascade_size; + dl_push_constant.grid_size[2] = cascade_size; + dl_push_constant.max_cascades = cascades.size(); + dl_push_constant.probe_axis_size = probe_axis_count; + dl_push_constant.bounce_feedback = 0.0; // this is static light, do not multibounce yet + dl_push_constant.y_mult = y_mult; + dl_push_constant.use_occlusion = uses_occlusion; + + //all must be processed + dl_push_constant.process_offset = 0; + dl_push_constant.process_increment = 1; + + for (uint32_t i = 0; i < p_cascade_count; i++) { + ERR_CONTINUE(p_cascade_indices[i] >= cascades.size()); + + SDFGI::Cascade &cc = cascades[p_cascade_indices[i]]; + + dl_push_constant.light_count = light_count[i]; + dl_push_constant.cascade = p_cascade_indices[i]; + + if (dl_push_constant.light_count > 0) { + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cc.sdf_direct_light_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &dl_push_constant, sizeof(SDFGIShader::DirectLightPushConstant)); + RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cc.solid_cell_dispatch_buffer, 0); + } + } + + RD::get_singleton()->compute_list_end(); + + RD::get_singleton()->draw_command_end_label(); +} + +//////////////////////////////////////////////////////////////////////////////// +// GIProbeInstance + +void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render) { + uint32_t data_version = storage->gi_probe_get_data_version(probe); + + // (RE)CREATE IF NEEDED + + if (last_probe_data_version != data_version) { + //need to re-create everything + if (texture.is_valid()) { + RD::get_singleton()->free(texture); + RD::get_singleton()->free(write_buffer); + mipmaps.clear(); + } + + for (int i = 0; i < dynamic_maps.size(); i++) { + RD::get_singleton()->free(dynamic_maps[i].texture); + RD::get_singleton()->free(dynamic_maps[i].depth); + } + + dynamic_maps.clear(); + + Vector3i octree_size = storage->gi_probe_get_octree_size(probe); + + if (octree_size != Vector3i()) { + //can create a 3D texture + Vector<int> levels = storage->gi_probe_get_level_counts(probe); + + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; + tf.width = octree_size.x; + tf.height = octree_size.y; + tf.depth = octree_size.z; + tf.texture_type = RD::TEXTURE_TYPE_3D; + tf.mipmaps = levels.size(); + + tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; + + texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + RD::get_singleton()->texture_clear(texture, Color(0, 0, 0, 0), 0, levels.size(), 0, 1); + + { + int total_elements = 0; + for (int i = 0; i < levels.size(); i++) { + total_elements += levels[i]; + } + + write_buffer = RD::get_singleton()->storage_buffer_create(total_elements * 16); + } + + for (int i = 0; i < levels.size(); i++) { + GIProbeInstance::Mipmap mipmap; + mipmap.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), texture, 0, i, RD::TEXTURE_SLICE_3D); + mipmap.level = levels.size() - i - 1; + mipmap.cell_offset = 0; + for (uint32_t j = 0; j < mipmap.level; j++) { + mipmap.cell_offset += levels[j]; + } + mipmap.cell_count = levels[mipmap.level]; + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 1; + u.ids.push_back(storage->gi_probe_get_octree_buffer(probe)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 2; + u.ids.push_back(storage->gi_probe_get_data_buffer(probe)); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 4; + u.ids.push_back(write_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 9; + u.ids.push_back(storage->gi_probe_get_sdf_texture(probe)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 10; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + { + Vector<RD::Uniform> copy_uniforms = uniforms; + if (i == 0) { + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.binding = 3; + u.ids.push_back(gi->gi_probe_lights_uniform); + copy_uniforms.push_back(u); + } + + mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT], 0); + + copy_uniforms = uniforms; //restore + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 5; + u.ids.push_back(texture); + copy_uniforms.push_back(u); + } + mipmap.second_bounce_uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE], 0); + } else { + mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP], 0); + } + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 5; + u.ids.push_back(mipmap.texture); + uniforms.push_back(u); + } + + mipmap.write_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE], 0); + + mipmaps.push_back(mipmap); + } + + { + uint32_t dynamic_map_size = MAX(MAX(octree_size.x, octree_size.y), octree_size.z); + uint32_t oversample = nearest_power_of_2_templated(4); + int mipmap_index = 0; + + while (mipmap_index < mipmaps.size()) { + GIProbeInstance::DynamicMap dmap; + + if (oversample > 0) { + dmap.size = dynamic_map_size * (1 << oversample); + dmap.mipmap = -1; + oversample--; + } else { + dmap.size = dynamic_map_size >> mipmap_index; + dmap.mipmap = mipmap_index; + mipmap_index++; + } + + RD::TextureFormat dtf; + dtf.width = dmap.size; + dtf.height = dmap.size; + dtf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT; + + if (dynamic_maps.size() == 0) { + dtf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + } + dmap.texture = RD::get_singleton()->texture_create(dtf, RD::TextureView()); + + if (dynamic_maps.size() == 0) { + //render depth for first one + dtf.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_D32_SFLOAT, RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ? RD::DATA_FORMAT_D32_SFLOAT : RD::DATA_FORMAT_X8_D24_UNORM_PACK32; + dtf.usage_bits = RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; + dmap.fb_depth = RD::get_singleton()->texture_create(dtf, RD::TextureView()); + } + + //just use depth as-is + dtf.format = RD::DATA_FORMAT_R32_SFLOAT; + dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + + dmap.depth = RD::get_singleton()->texture_create(dtf, RD::TextureView()); + + if (dynamic_maps.size() == 0) { + dtf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; + dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + dmap.albedo = RD::get_singleton()->texture_create(dtf, RD::TextureView()); + dmap.normal = RD::get_singleton()->texture_create(dtf, RD::TextureView()); + dmap.orm = RD::get_singleton()->texture_create(dtf, RD::TextureView()); + + Vector<RID> fb; + fb.push_back(dmap.albedo); + fb.push_back(dmap.normal); + fb.push_back(dmap.orm); + fb.push_back(dmap.texture); //emission + fb.push_back(dmap.depth); + fb.push_back(dmap.fb_depth); + + dmap.fb = RD::get_singleton()->framebuffer_create(fb); + + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.binding = 3; + u.ids.push_back(gi->gi_probe_lights_uniform); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 5; + u.ids.push_back(dmap.albedo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 6; + u.ids.push_back(dmap.normal); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 7; + u.ids.push_back(dmap.orm); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 8; + u.ids.push_back(dmap.fb_depth); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 9; + u.ids.push_back(storage->gi_probe_get_sdf_texture(probe)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 10; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 11; + u.ids.push_back(dmap.texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 12; + u.ids.push_back(dmap.depth); + uniforms.push_back(u); + } + + dmap.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING], 0); + } + } else { + bool plot = dmap.mipmap >= 0; + bool write = dmap.mipmap < (mipmaps.size() - 1); + + Vector<RD::Uniform> uniforms; + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 5; + u.ids.push_back(dynamic_maps[dynamic_maps.size() - 1].texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 6; + u.ids.push_back(dynamic_maps[dynamic_maps.size() - 1].depth); + uniforms.push_back(u); + } + + if (write) { + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 7; + u.ids.push_back(dmap.texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 8; + u.ids.push_back(dmap.depth); + uniforms.push_back(u); + } + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 9; + u.ids.push_back(storage->gi_probe_get_sdf_texture(probe)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 10; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + if (plot) { + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 11; + u.ids.push_back(mipmaps[dmap.mipmap].texture); + uniforms.push_back(u); + } + } + + dmap.uniform_set = RD::get_singleton()->uniform_set_create( + uniforms, + gi->giprobe_lighting_shader_version_shaders[(write && plot) ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT : (write ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE : GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT)], + 0); + } + + dynamic_maps.push_back(dmap); + } + } + } + + last_probe_data_version = data_version; + p_update_light_instances = true; //just in case + + p_scene_render->_base_uniforms_changed(); + } + + // UDPDATE TIME + + if (has_dynamic_object_data) { + //if it has dynamic object data, it needs to be cleared + RD::get_singleton()->texture_clear(texture, Color(0, 0, 0, 0), 0, mipmaps.size(), 0, 1); + } + + uint32_t light_count = 0; + + if (p_update_light_instances || p_dynamic_objects.size() > 0) { + light_count = MIN(gi->gi_probe_max_lights, (uint32_t)p_light_instances.size()); + + { + Transform to_cell = storage->gi_probe_get_to_cell_xform(probe); + Transform to_probe_xform = (transform * to_cell.affine_inverse()).affine_inverse(); + //update lights + + for (uint32_t i = 0; i < light_count; i++) { + GIProbeLight &l = gi->gi_probe_lights[i]; + RID light_instance = p_light_instances[i]; + RID light = p_scene_render->light_instance_get_base_light(light_instance); + + l.type = storage->light_get_type(light); + if (l.type == RS::LIGHT_DIRECTIONAL && storage->light_directional_is_sky_only(light)) { + light_count--; + continue; + } + + l.attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_ATTENUATION); + l.energy = storage->light_get_param(light, RS::LIGHT_PARAM_ENERGY) * storage->light_get_param(light, RS::LIGHT_PARAM_INDIRECT_ENERGY); + l.radius = to_cell.basis.xform(Vector3(storage->light_get_param(light, RS::LIGHT_PARAM_RANGE), 0, 0)).length(); + Color color = storage->light_get_color(light).to_linear(); + l.color[0] = color.r; + l.color[1] = color.g; + l.color[2] = color.b; + + l.cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ANGLE))); + l.inv_spot_attenuation = 1.0f / storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ATTENUATION); + + Transform xform = p_scene_render->light_instance_get_base_transform(light_instance); + + Vector3 pos = to_probe_xform.xform(xform.origin); + Vector3 dir = to_probe_xform.basis.xform(-xform.basis.get_axis(2)).normalized(); + + l.position[0] = pos.x; + l.position[1] = pos.y; + l.position[2] = pos.z; + + l.direction[0] = dir.x; + l.direction[1] = dir.y; + l.direction[2] = dir.z; + + l.has_shadow = storage->light_has_shadow(light); + } + + RD::get_singleton()->buffer_update(gi->gi_probe_lights_uniform, 0, sizeof(GIProbeLight) * light_count, gi->gi_probe_lights); + } + } + + if (has_dynamic_object_data || p_update_light_instances || p_dynamic_objects.size()) { + // PROCESS MIPMAPS + if (mipmaps.size()) { + //can update mipmaps + + Vector3i probe_size = storage->gi_probe_get_octree_size(probe); + + GIProbePushConstant push_constant; + + push_constant.limits[0] = probe_size.x; + push_constant.limits[1] = probe_size.y; + push_constant.limits[2] = probe_size.z; + push_constant.stack_size = mipmaps.size(); + push_constant.emission_scale = 1.0; + push_constant.propagation = storage->gi_probe_get_propagation(probe); + push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(probe); + push_constant.light_count = light_count; + push_constant.aniso_strength = 0; + + /* print_line("probe update to version " + itos(last_probe_version)); + print_line("propagation " + rtos(push_constant.propagation)); + print_line("dynrange " + rtos(push_constant.dynamic_range)); + */ + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + + int passes; + if (p_update_light_instances) { + passes = storage->gi_probe_is_using_two_bounces(probe) ? 2 : 1; + } else { + passes = 1; //only re-blitting is necessary + } + int wg_size = 64; + int wg_limit_x = RD::get_singleton()->limit_get(RD::LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_X); + + for (int pass = 0; pass < passes; pass++) { + if (p_update_light_instances) { + for (int i = 0; i < mipmaps.size(); i++) { + if (i == 0) { + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[pass == 0 ? GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT : GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE]); + } else if (i == 1) { + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP]); + } + + if (pass == 1 || i > 0) { + RD::get_singleton()->compute_list_add_barrier(compute_list); //wait til previous step is done + } + if (pass == 0 || i > 0) { + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, mipmaps[i].uniform_set, 0); + } else { + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, mipmaps[i].second_bounce_uniform_set, 0); + } + + push_constant.cell_offset = mipmaps[i].cell_offset; + push_constant.cell_count = mipmaps[i].cell_count; + + int wg_todo = (mipmaps[i].cell_count - 1) / wg_size + 1; + while (wg_todo) { + int wg_count = MIN(wg_todo, wg_limit_x); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbePushConstant)); + RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1); + wg_todo -= wg_count; + push_constant.cell_offset += wg_count * wg_size; + } + } + + RD::get_singleton()->compute_list_add_barrier(compute_list); //wait til previous step is done + } + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE]); + + for (int i = 0; i < mipmaps.size(); i++) { + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, mipmaps[i].write_uniform_set, 0); + + push_constant.cell_offset = mipmaps[i].cell_offset; + push_constant.cell_count = mipmaps[i].cell_count; + + int wg_todo = (mipmaps[i].cell_count - 1) / wg_size + 1; + while (wg_todo) { + int wg_count = MIN(wg_todo, wg_limit_x); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbePushConstant)); + RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1); + wg_todo -= wg_count; + push_constant.cell_offset += wg_count * wg_size; + } + } + } + + RD::get_singleton()->compute_list_end(); + } + } + + has_dynamic_object_data = false; //clear until dynamic object data is used again + + if (p_dynamic_objects.size() && dynamic_maps.size()) { + Vector3i octree_size = storage->gi_probe_get_octree_size(probe); + int multiplier = dynamic_maps[0].size / MAX(MAX(octree_size.x, octree_size.y), octree_size.z); + + Transform oversample_scale; + oversample_scale.basis.scale(Vector3(multiplier, multiplier, multiplier)); + + Transform to_cell = oversample_scale * storage->gi_probe_get_to_cell_xform(probe); + Transform to_world_xform = transform * to_cell.affine_inverse(); + Transform to_probe_xform = to_world_xform.affine_inverse(); + + AABB probe_aabb(Vector3(), octree_size); + + //this could probably be better parallelized in compute.. + for (int i = 0; i < (int)p_dynamic_objects.size(); i++) { + RendererSceneRender::GeometryInstance *instance = p_dynamic_objects[i]; + + //transform aabb to giprobe + AABB aabb = (to_probe_xform * p_scene_render->geometry_instance_get_transform(instance)).xform(p_scene_render->geometry_instance_get_aabb(instance)); + + //this needs to wrap to grid resolution to avoid jitter + //also extend margin a bit just in case + Vector3i begin = aabb.position - Vector3i(1, 1, 1); + Vector3i end = aabb.position + aabb.size + Vector3i(1, 1, 1); + + for (int j = 0; j < 3; j++) { + if ((end[j] - begin[j]) & 1) { + end[j]++; //for half extents split, it needs to be even + } + begin[j] = MAX(begin[j], 0); + end[j] = MIN(end[j], octree_size[j] * multiplier); + } + + //aabb = aabb.intersection(probe_aabb); //intersect + aabb.position = begin; + aabb.size = end - begin; + + //print_line("aabb: " + aabb); + + for (int j = 0; j < 6; j++) { + //if (j != 0 && j != 3) { + // continue; + //} + static const Vector3 render_z[6] = { + Vector3(1, 0, 0), + Vector3(0, 1, 0), + Vector3(0, 0, 1), + Vector3(-1, 0, 0), + Vector3(0, -1, 0), + Vector3(0, 0, -1), + }; + static const Vector3 render_up[6] = { + Vector3(0, 1, 0), + Vector3(0, 0, 1), + Vector3(0, 1, 0), + Vector3(0, 1, 0), + Vector3(0, 0, 1), + Vector3(0, 1, 0), + }; + + Vector3 render_dir = render_z[j]; + Vector3 up_dir = render_up[j]; + + Vector3 center = aabb.position + aabb.size * 0.5; + Transform xform; + xform.set_look_at(center - aabb.size * 0.5 * render_dir, center, up_dir); + + Vector3 x_dir = xform.basis.get_axis(0).abs(); + int x_axis = int(Vector3(0, 1, 2).dot(x_dir)); + Vector3 y_dir = xform.basis.get_axis(1).abs(); + int y_axis = int(Vector3(0, 1, 2).dot(y_dir)); + Vector3 z_dir = -xform.basis.get_axis(2); + int z_axis = int(Vector3(0, 1, 2).dot(z_dir.abs())); + + Rect2i rect(aabb.position[x_axis], aabb.position[y_axis], aabb.size[x_axis], aabb.size[y_axis]); + bool x_flip = bool(Vector3(1, 1, 1).dot(xform.basis.get_axis(0)) < 0); + bool y_flip = bool(Vector3(1, 1, 1).dot(xform.basis.get_axis(1)) < 0); + bool z_flip = bool(Vector3(1, 1, 1).dot(xform.basis.get_axis(2)) > 0); + + CameraMatrix cm; + cm.set_orthogonal(-rect.size.width / 2, rect.size.width / 2, -rect.size.height / 2, rect.size.height / 2, 0.0001, aabb.size[z_axis]); + + if (p_scene_render->cull_argument.size() == 0) { + p_scene_render->cull_argument.push_back(nullptr); + } + p_scene_render->cull_argument[0] = instance; + + p_scene_render->_render_material(to_world_xform * xform, cm, true, p_scene_render->cull_argument, dynamic_maps[0].fb, Rect2i(Vector2i(), rect.size)); + + GIProbeDynamicPushConstant push_constant; + zeromem(&push_constant, sizeof(GIProbeDynamicPushConstant)); + push_constant.limits[0] = octree_size.x; + push_constant.limits[1] = octree_size.y; + push_constant.limits[2] = octree_size.z; + push_constant.light_count = p_light_instances.size(); + push_constant.x_dir[0] = x_dir[0]; + push_constant.x_dir[1] = x_dir[1]; + push_constant.x_dir[2] = x_dir[2]; + push_constant.y_dir[0] = y_dir[0]; + push_constant.y_dir[1] = y_dir[1]; + push_constant.y_dir[2] = y_dir[2]; + push_constant.z_dir[0] = z_dir[0]; + push_constant.z_dir[1] = z_dir[1]; + push_constant.z_dir[2] = z_dir[2]; + push_constant.z_base = xform.origin[z_axis]; + push_constant.z_sign = (z_flip ? -1.0 : 1.0); + push_constant.pos_multiplier = float(1.0) / multiplier; + push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(probe); + push_constant.flip_x = x_flip; + push_constant.flip_y = y_flip; + push_constant.rect_pos[0] = rect.position[0]; + push_constant.rect_pos[1] = rect.position[1]; + push_constant.rect_size[0] = rect.size[0]; + push_constant.rect_size[1] = rect.size[1]; + push_constant.prev_rect_ofs[0] = 0; + push_constant.prev_rect_ofs[1] = 0; + push_constant.prev_rect_size[0] = 0; + push_constant.prev_rect_size[1] = 0; + push_constant.on_mipmap = false; + push_constant.propagation = storage->gi_probe_get_propagation(probe); + push_constant.pad[0] = 0; + push_constant.pad[1] = 0; + push_constant.pad[2] = 0; + + //process lighting + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, dynamic_maps[0].uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbeDynamicPushConstant)); + RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1); + //print_line("rect: " + itos(i) + ": " + rect); + + for (int k = 1; k < dynamic_maps.size(); k++) { + // enlarge the rect if needed so all pixels fit when downscaled, + // this ensures downsampling is smooth and optimal because no pixels are left behind + + //x + if (rect.position.x & 1) { + rect.size.x++; + push_constant.prev_rect_ofs[0] = 1; //this is used to ensure reading is also optimal + } else { + push_constant.prev_rect_ofs[0] = 0; + } + if (rect.size.x & 1) { + rect.size.x++; + } + + rect.position.x >>= 1; + rect.size.x = MAX(1, rect.size.x >> 1); + + //y + if (rect.position.y & 1) { + rect.size.y++; + push_constant.prev_rect_ofs[1] = 1; + } else { + push_constant.prev_rect_ofs[1] = 0; + } + if (rect.size.y & 1) { + rect.size.y++; + } + + rect.position.y >>= 1; + rect.size.y = MAX(1, rect.size.y >> 1); + + //shrink limits to ensure plot does not go outside map + if (dynamic_maps[k].mipmap > 0) { + for (int l = 0; l < 3; l++) { + push_constant.limits[l] = MAX(1, push_constant.limits[l] >> 1); + } + } + + //print_line("rect: " + itos(i) + ": " + rect); + push_constant.rect_pos[0] = rect.position[0]; + push_constant.rect_pos[1] = rect.position[1]; + push_constant.prev_rect_size[0] = push_constant.rect_size[0]; + push_constant.prev_rect_size[1] = push_constant.rect_size[1]; + push_constant.rect_size[0] = rect.size[0]; + push_constant.rect_size[1] = rect.size[1]; + push_constant.on_mipmap = dynamic_maps[k].mipmap > 0; + + RD::get_singleton()->compute_list_add_barrier(compute_list); + + if (dynamic_maps[k].mipmap < 0) { + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE]); + } else if (k < dynamic_maps.size() - 1) { + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT]); + } else { + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi->giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT]); + } + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, dynamic_maps[k].uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbeDynamicPushConstant)); + RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1); + } + + RD::get_singleton()->compute_list_end(); + } + } + + has_dynamic_object_data = true; //clear until dynamic object data is used again + } + + last_probe_version = storage->gi_probe_get_version(probe); +} + +void RendererSceneGIRD::GIProbeInstance::debug(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) { + if (mipmaps.size() == 0) { + return; + } + + CameraMatrix cam_transform = (p_camera_with_transform * CameraMatrix(transform)) * CameraMatrix(storage->gi_probe_get_to_cell_xform(probe).affine_inverse()); + + int level = 0; + Vector3i octree_size = storage->gi_probe_get_octree_size(probe); + + GIProbeDebugPushConstant push_constant; + push_constant.alpha = p_alpha; + push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(probe); + push_constant.cell_offset = mipmaps[level].cell_offset; + push_constant.level = level; + + push_constant.bounds[0] = octree_size.x >> level; + push_constant.bounds[1] = octree_size.y >> level; + push_constant.bounds[2] = octree_size.z >> level; + push_constant.pad = 0; + + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + push_constant.projection[i * 4 + j] = cam_transform.matrix[i][j]; + } + } + + if (gi->giprobe_debug_uniform_set.is_valid()) { + RD::get_singleton()->free(gi->giprobe_debug_uniform_set); + } + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 1; + u.ids.push_back(storage->gi_probe_get_data_buffer(probe)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 2; + u.ids.push_back(texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 3; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + int cell_count; + if (!p_emission && p_lighting && has_dynamic_object_data) { + cell_count = push_constant.bounds[0] * push_constant.bounds[1] * push_constant.bounds[2]; + } else { + cell_count = mipmaps[level].cell_count; + } + + gi->giprobe_debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->giprobe_debug_shader_version_shaders[0], 0); + + int giprobe_debug_pipeline = GI_PROBE_DEBUG_COLOR; + if (p_emission) { + giprobe_debug_pipeline = GI_PROBE_DEBUG_EMISSION; + } else if (p_lighting) { + giprobe_debug_pipeline = has_dynamic_object_data ? GI_PROBE_DEBUG_LIGHT_FULL : GI_PROBE_DEBUG_LIGHT; + } + RD::get_singleton()->draw_list_bind_render_pipeline( + p_draw_list, + gi->giprobe_debug_shader_version_pipelines[giprobe_debug_pipeline].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, gi->giprobe_debug_uniform_set, 0); + RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(GIProbeDebugPushConstant)); + RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, 36); +} + +//////////////////////////////////////////////////////////////////////////////// +// GIRD + +RendererSceneGIRD::RendererSceneGIRD() { + sdfgi_ray_count = RS::EnvironmentSDFGIRayCount(CLAMP(int32_t(GLOBAL_GET("rendering/global_illumination/sdfgi/probe_ray_count")), 0, int32_t(RS::ENV_SDFGI_RAY_COUNT_MAX - 1))); + sdfgi_frames_to_converge = RS::EnvironmentSDFGIFramesToConverge(CLAMP(int32_t(GLOBAL_GET("rendering/global_illumination/sdfgi/frames_to_converge")), 0, int32_t(RS::ENV_SDFGI_CONVERGE_MAX - 1))); + sdfgi_frames_to_update_light = RS::EnvironmentSDFGIFramesToUpdateLight(CLAMP(int32_t(GLOBAL_GET("rendering/global_illumination/sdfgi/frames_to_update_lights")), 0, int32_t(RS::ENV_SDFGI_UPDATE_LIGHT_MAX - 1))); +} + +RendererSceneGIRD::~RendererSceneGIRD() { +} + +void RendererSceneGIRD::init(RendererStorageRD *p_storage, RendererSceneSkyRD *p_sky) { + storage = p_storage; + + /* GI */ + + { + //kinda complicated to compute the amount of slots, we try to use as many as we can + + gi_probe_max_lights = 32; + + gi_probe_lights = memnew_arr(GIProbeLight, gi_probe_max_lights); + gi_probe_lights_uniform = RD::get_singleton()->uniform_buffer_create(gi_probe_max_lights * sizeof(GIProbeLight)); + gi_probe_quality = RS::GIProbeQuality(CLAMP(int(GLOBAL_GET("rendering/global_illumination/gi_probes/quality")), 0, 1)); + + String defines = "\n#define MAX_LIGHTS " + itos(gi_probe_max_lights) + "\n"; + + Vector<String> versions; + versions.push_back("\n#define MODE_COMPUTE_LIGHT\n"); + versions.push_back("\n#define MODE_SECOND_BOUNCE\n"); + versions.push_back("\n#define MODE_UPDATE_MIPMAPS\n"); + versions.push_back("\n#define MODE_WRITE_TEXTURE\n"); + versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_LIGHTING\n"); + versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_WRITE\n"); + versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n"); + versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n#define MODE_DYNAMIC_SHRINK_WRITE\n"); + + giprobe_shader.initialize(versions, defines); + giprobe_lighting_shader_version = giprobe_shader.version_create(); + for (int i = 0; i < GI_PROBE_SHADER_VERSION_MAX; i++) { + giprobe_lighting_shader_version_shaders[i] = giprobe_shader.version_get_shader(giprobe_lighting_shader_version, i); + giprobe_lighting_shader_version_pipelines[i] = RD::get_singleton()->compute_pipeline_create(giprobe_lighting_shader_version_shaders[i]); + } + } + + { + String defines; + Vector<String> versions; + versions.push_back("\n#define MODE_DEBUG_COLOR\n"); + versions.push_back("\n#define MODE_DEBUG_LIGHT\n"); + versions.push_back("\n#define MODE_DEBUG_EMISSION\n"); + versions.push_back("\n#define MODE_DEBUG_LIGHT\n#define MODE_DEBUG_LIGHT_FULL\n"); + + giprobe_debug_shader.initialize(versions, defines); + giprobe_debug_shader_version = giprobe_debug_shader.version_create(); + for (int i = 0; i < GI_PROBE_DEBUG_MAX; i++) { + giprobe_debug_shader_version_shaders[i] = giprobe_debug_shader.version_get_shader(giprobe_debug_shader_version, i); + + RD::PipelineRasterizationState rs; + rs.cull_mode = RD::POLYGON_CULL_FRONT; + RD::PipelineDepthStencilState ds; + ds.enable_depth_test = true; + ds.enable_depth_write = true; + ds.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; + + giprobe_debug_shader_version_pipelines[i].setup(giprobe_debug_shader_version_shaders[i], RD::RENDER_PRIMITIVE_TRIANGLES, rs, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(), 0); + } + } + + /* SDGFI */ + + { + Vector<String> preprocess_modes; + preprocess_modes.push_back("\n#define MODE_SCROLL\n"); + preprocess_modes.push_back("\n#define MODE_SCROLL_OCCLUSION\n"); + preprocess_modes.push_back("\n#define MODE_INITIALIZE_JUMP_FLOOD\n"); + preprocess_modes.push_back("\n#define MODE_INITIALIZE_JUMP_FLOOD_HALF\n"); + preprocess_modes.push_back("\n#define MODE_JUMPFLOOD\n"); + preprocess_modes.push_back("\n#define MODE_JUMPFLOOD_OPTIMIZED\n"); + preprocess_modes.push_back("\n#define MODE_UPSCALE_JUMP_FLOOD\n"); + preprocess_modes.push_back("\n#define MODE_OCCLUSION\n"); + preprocess_modes.push_back("\n#define MODE_STORE\n"); + String defines = "\n#define OCCLUSION_SIZE " + itos(SDFGI::CASCADE_SIZE / SDFGI::PROBE_DIVISOR) + "\n"; + sdfgi_shader.preprocess.initialize(preprocess_modes, defines); + sdfgi_shader.preprocess_shader = sdfgi_shader.preprocess.version_create(); + for (int i = 0; i < SDFGIShader::PRE_PROCESS_MAX; i++) { + sdfgi_shader.preprocess_pipeline[i] = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, i)); + } + } + + { + //calculate tables + String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; + + Vector<String> direct_light_modes; + direct_light_modes.push_back("\n#define MODE_PROCESS_STATIC\n"); + direct_light_modes.push_back("\n#define MODE_PROCESS_DYNAMIC\n"); + sdfgi_shader.direct_light.initialize(direct_light_modes, defines); + sdfgi_shader.direct_light_shader = sdfgi_shader.direct_light.version_create(); + for (int i = 0; i < SDFGIShader::DIRECT_LIGHT_MODE_MAX; i++) { + sdfgi_shader.direct_light_pipeline[i] = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.direct_light.version_get_shader(sdfgi_shader.direct_light_shader, i)); + } + } + + { + //calculate tables + String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; + defines += "\n#define SH_SIZE " + itos(SDFGI::SH_SIZE) + "\n"; + if (p_sky->sky_use_cubemap_array) { + defines += "\n#define USE_CUBEMAP_ARRAY\n"; + } + + Vector<String> integrate_modes; + integrate_modes.push_back("\n#define MODE_PROCESS\n"); + integrate_modes.push_back("\n#define MODE_STORE\n"); + integrate_modes.push_back("\n#define MODE_SCROLL\n"); + integrate_modes.push_back("\n#define MODE_SCROLL_STORE\n"); + sdfgi_shader.integrate.initialize(integrate_modes, defines); + sdfgi_shader.integrate_shader = sdfgi_shader.integrate.version_create(); + + for (int i = 0; i < SDFGIShader::INTEGRATE_MODE_MAX; i++) { + sdfgi_shader.integrate_pipeline[i] = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.integrate.version_get_shader(sdfgi_shader.integrate_shader, i)); + } + + { + Vector<RD::Uniform> uniforms; + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 0; + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_WHITE)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 1; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + sdfgi_shader.integrate_default_sky_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.integrate.version_get_shader(sdfgi_shader.integrate_shader, 0), 1); + } + } + + //GK + { + //calculate tables + String defines = "\n#define SDFGI_OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; + Vector<String> gi_modes; + gi_modes.push_back("\n#define USE_GIPROBES\n"); + gi_modes.push_back("\n#define USE_SDFGI\n"); + gi_modes.push_back("\n#define USE_SDFGI\n\n#define USE_GIPROBES\n"); + gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_GIPROBES\n"); + gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n"); + gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n\n#define USE_GIPROBES\n"); + + shader.initialize(gi_modes, defines); + shader_version = shader.version_create(); + for (int i = 0; i < MODE_MAX; i++) { + pipelines[i] = RD::get_singleton()->compute_pipeline_create(shader.version_get_shader(shader_version, i)); + } + + sdfgi_ubo = RD::get_singleton()->uniform_buffer_create(sizeof(SDFGIData)); + } + { + String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; + Vector<String> debug_modes; + debug_modes.push_back(""); + sdfgi_shader.debug.initialize(debug_modes, defines); + sdfgi_shader.debug_shader = sdfgi_shader.debug.version_create(); + sdfgi_shader.debug_shader_version = sdfgi_shader.debug.version_get_shader(sdfgi_shader.debug_shader, 0); + sdfgi_shader.debug_pipeline = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.debug_shader_version); + } + { + String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; + + Vector<String> versions; + versions.push_back("\n#define MODE_PROBES\n"); + versions.push_back("\n#define MODE_VISIBILITY\n"); + + sdfgi_shader.debug_probes.initialize(versions, defines); + sdfgi_shader.debug_probes_shader = sdfgi_shader.debug_probes.version_create(); + + { + RD::PipelineRasterizationState rs; + rs.cull_mode = RD::POLYGON_CULL_DISABLED; + RD::PipelineDepthStencilState ds; + ds.enable_depth_test = true; + ds.enable_depth_write = true; + ds.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; + for (int i = 0; i < SDFGIShader::PROBE_DEBUG_MAX; i++) { + RID debug_probes_shader_version = sdfgi_shader.debug_probes.version_get_shader(sdfgi_shader.debug_probes_shader, i); + sdfgi_shader.debug_probes_pipeline[i].setup(debug_probes_shader_version, RD::RENDER_PRIMITIVE_TRIANGLE_STRIPS, rs, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(), 0); + } + } + } + default_giprobe_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(GIProbeData) * MAX_GIPROBES); +} + +void RendererSceneGIRD::free() { + RD::get_singleton()->free(default_giprobe_buffer); + RD::get_singleton()->free(gi_probe_lights_uniform); + RD::get_singleton()->free(sdfgi_ubo); + + giprobe_debug_shader.version_free(giprobe_debug_shader_version); + giprobe_shader.version_free(giprobe_lighting_shader_version); + shader.version_free(shader_version); + sdfgi_shader.debug_probes.version_free(sdfgi_shader.debug_probes_shader); + sdfgi_shader.debug.version_free(sdfgi_shader.debug_shader); + sdfgi_shader.direct_light.version_free(sdfgi_shader.direct_light_shader); + sdfgi_shader.integrate.version_free(sdfgi_shader.integrate_shader); + sdfgi_shader.preprocess.version_free(sdfgi_shader.preprocess_shader); + + memdelete_arr(gi_probe_lights); +} + +RendererSceneGIRD::SDFGI *RendererSceneGIRD::create_sdfgi(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size) { + SDFGI *sdfgi = memnew(SDFGI); + + sdfgi->create(p_env, p_world_position, p_requested_history_size, this); + + return sdfgi; +} + +void RendererSceneGIRD::setup_giprobes(RID p_render_buffers, const Transform &p_transform, const PagedArray<RID> &p_gi_probes, uint32_t &r_gi_probes_used, RendererSceneRenderRD *p_scene_render) { + r_gi_probes_used = 0; + + // feels a little dirty to use our container this way but.... + RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND(rb == nullptr); + + RID gi_probe_buffer = p_scene_render->render_buffers_get_gi_probe_buffer(p_render_buffers); + + RD::get_singleton()->draw_command_begin_label("GIProbes Setup"); + + GIProbeData gi_probe_data[MAX_GIPROBES]; + + bool giprobes_changed = false; + + Transform to_camera; + to_camera.origin = p_transform.origin; //only translation, make local + + for (int i = 0; i < MAX_GIPROBES; i++) { + RID texture; + if (i < (int)p_gi_probes.size()) { + GIProbeInstance *gipi = get_probe_instance(p_gi_probes[i]); + + if (gipi) { + texture = gipi->texture; + GIProbeData &gipd = gi_probe_data[i]; + + RID base_probe = gipi->probe; + + Transform to_cell = storage->gi_probe_get_to_cell_xform(gipi->probe) * gipi->transform.affine_inverse() * to_camera; + + gipd.xform[0] = to_cell.basis.elements[0][0]; + gipd.xform[1] = to_cell.basis.elements[1][0]; + gipd.xform[2] = to_cell.basis.elements[2][0]; + gipd.xform[3] = 0; + gipd.xform[4] = to_cell.basis.elements[0][1]; + gipd.xform[5] = to_cell.basis.elements[1][1]; + gipd.xform[6] = to_cell.basis.elements[2][1]; + gipd.xform[7] = 0; + gipd.xform[8] = to_cell.basis.elements[0][2]; + gipd.xform[9] = to_cell.basis.elements[1][2]; + gipd.xform[10] = to_cell.basis.elements[2][2]; + gipd.xform[11] = 0; + gipd.xform[12] = to_cell.origin.x; + gipd.xform[13] = to_cell.origin.y; + gipd.xform[14] = to_cell.origin.z; + gipd.xform[15] = 1; + + Vector3 bounds = storage->gi_probe_get_octree_size(base_probe); + + gipd.bounds[0] = bounds.x; + gipd.bounds[1] = bounds.y; + gipd.bounds[2] = bounds.z; + + gipd.dynamic_range = storage->gi_probe_get_dynamic_range(base_probe) * storage->gi_probe_get_energy(base_probe); + gipd.bias = storage->gi_probe_get_bias(base_probe); + gipd.normal_bias = storage->gi_probe_get_normal_bias(base_probe); + gipd.blend_ambient = !storage->gi_probe_is_interior(base_probe); + gipd.anisotropy_strength = 0; + gipd.ao = storage->gi_probe_get_ao(base_probe); + gipd.ao_size = Math::pow(storage->gi_probe_get_ao_size(base_probe), 4.0f); + gipd.mipmaps = gipi->mipmaps.size(); + } + + r_gi_probes_used++; + } + + if (texture == RID()) { + texture = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); + } + + if (texture != rb->gi.giprobe_textures[i]) { + giprobes_changed = true; + rb->gi.giprobe_textures[i] = texture; + } + } + + if (giprobes_changed) { + if (RD::get_singleton()->uniform_set_is_valid(rb->gi_uniform_set)) { + RD::get_singleton()->free(rb->gi_uniform_set); + } + rb->gi_uniform_set = RID(); + if (rb->volumetric_fog) { + if (RD::get_singleton()->uniform_set_is_valid(rb->volumetric_fog->uniform_set)) { + RD::get_singleton()->free(rb->volumetric_fog->uniform_set); + RD::get_singleton()->free(rb->volumetric_fog->uniform_set2); + } + rb->volumetric_fog->uniform_set = RID(); + rb->volumetric_fog->uniform_set2 = RID(); + } + } + + if (p_gi_probes.size() > 0) { + RD::get_singleton()->buffer_update(gi_probe_buffer, 0, sizeof(GIProbeData) * MIN((uint64_t)MAX_GIPROBES, p_gi_probes.size()), gi_probe_data, RD::BARRIER_MASK_COMPUTE); + } + + RD::get_singleton()->draw_command_end_label(); +} + +void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_gi_probe_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform, const PagedArray<RID> &p_gi_probes, RendererSceneRenderRD *p_scene_render) { + RD::get_singleton()->draw_command_begin_label("GI Render"); + + RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND(rb == nullptr); + RendererSceneEnvironmentRD *env = p_scene_render->environment_owner.getornull(p_environment); + + if (rb->ambient_buffer.is_null() || rb->using_half_size_gi != half_resolution) { + if (rb->ambient_buffer.is_valid()) { + RD::get_singleton()->free(rb->ambient_buffer); + RD::get_singleton()->free(rb->reflection_buffer); + } + + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.width = rb->width; + tf.height = rb->height; + if (half_resolution) { + tf.width >>= 1; + tf.height >>= 1; + } + tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; + rb->reflection_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView()); + rb->ambient_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView()); + rb->using_half_size_gi = half_resolution; + + p_scene_render->_render_buffers_uniform_set_changed(p_render_buffers); + } + + PushConstant push_constant; + + push_constant.screen_size[0] = rb->width; + push_constant.screen_size[1] = rb->height; + push_constant.z_near = p_projection.get_z_near(); + push_constant.z_far = p_projection.get_z_far(); + push_constant.orthogonal = p_projection.is_orthogonal(); + push_constant.proj_info[0] = -2.0f / (rb->width * p_projection.matrix[0][0]); + push_constant.proj_info[1] = -2.0f / (rb->height * p_projection.matrix[1][1]); + push_constant.proj_info[2] = (1.0f - p_projection.matrix[0][2]) / p_projection.matrix[0][0]; + push_constant.proj_info[3] = (1.0f + p_projection.matrix[1][2]) / p_projection.matrix[1][1]; + push_constant.max_giprobes = MIN((uint64_t)MAX_GIPROBES, p_gi_probes.size()); + push_constant.high_quality_vct = gi_probe_quality == RS::GI_PROBE_QUALITY_HIGH; + + bool use_sdfgi = rb->sdfgi != nullptr; + bool use_giprobes = push_constant.max_giprobes > 0; + + if (env) { + push_constant.ao_color[0] = env->ao_color.r; + push_constant.ao_color[1] = env->ao_color.g; + push_constant.ao_color[2] = env->ao_color.b; + } else { + push_constant.ao_color[0] = 0; + push_constant.ao_color[1] = 0; + push_constant.ao_color[2] = 0; + } + + push_constant.cam_rotation[0] = p_transform.basis[0][0]; + push_constant.cam_rotation[1] = p_transform.basis[1][0]; + push_constant.cam_rotation[2] = p_transform.basis[2][0]; + push_constant.cam_rotation[3] = 0; + push_constant.cam_rotation[4] = p_transform.basis[0][1]; + push_constant.cam_rotation[5] = p_transform.basis[1][1]; + push_constant.cam_rotation[6] = p_transform.basis[2][1]; + push_constant.cam_rotation[7] = 0; + push_constant.cam_rotation[8] = p_transform.basis[0][2]; + push_constant.cam_rotation[9] = p_transform.basis[1][2]; + push_constant.cam_rotation[10] = p_transform.basis[2][2]; + push_constant.cam_rotation[11] = 0; + + if (rb->gi_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(rb->gi_uniform_set)) { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.binding = 1; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { + u.ids.push_back(rb->sdfgi->cascades[j].sdf_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 2; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { + u.ids.push_back(rb->sdfgi->cascades[j].light_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { + u.ids.push_back(rb->sdfgi->cascades[j].light_aniso_0_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { + if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { + u.ids.push_back(rb->sdfgi->cascades[j].light_aniso_1_tex); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 5; + if (rb->sdfgi) { + u.ids.push_back(rb->sdfgi->occlusion_texture); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 6; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 7; + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 9; + u.ids.push_back(rb->ambient_buffer); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 10; + u.ids.push_back(rb->reflection_buffer); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 11; + if (rb->sdfgi) { + u.ids.push_back(rb->sdfgi->lightprobe_texture); + } else { + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE)); + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 12; + u.ids.push_back(rb->depth_texture); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 13; + u.ids.push_back(p_normal_roughness_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 14; + RID buffer = p_gi_probe_buffer.is_valid() ? p_gi_probe_buffer : storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_BLACK); + u.ids.push_back(buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.binding = 15; + u.ids.push_back(sdfgi_ubo); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.binding = 16; + u.ids.push_back(rb->gi.giprobe_buffer); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 17; + for (int i = 0; i < MAX_GIPROBES; i++) { + u.ids.push_back(rb->gi.giprobe_textures[i]); + } + uniforms.push_back(u); + } + + rb->gi_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, shader.version_get_shader(shader_version, 0), 0); + } + + Mode mode; + + if (rb->using_half_size_gi) { + mode = (use_sdfgi && use_giprobes) ? MODE_HALF_RES_COMBINED : (use_sdfgi ? MODE_HALF_RES_SDFGI : MODE_HALF_RES_GIPROBE); + } else { + mode = (use_sdfgi && use_giprobes) ? MODE_COMBINED : (use_sdfgi ? MODE_SDFGI : MODE_GIPROBE); + } + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(true); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, pipelines[mode]); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->gi_uniform_set, 0); + RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(PushConstant)); + + if (rb->using_half_size_gi) { + RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width >> 1, rb->height >> 1, 1); + } else { + RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width, rb->height, 1); + } + //do barrier later to allow oeverlap + //RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_NO_BARRIER); //no barriers, let other compute, raster and transfer happen at the same time + RD::get_singleton()->draw_command_end_label(); +} + +RID RendererSceneGIRD::gi_probe_instance_create(RID p_base) { + GIProbeInstance gi_probe; + gi_probe.gi = this; + gi_probe.storage = storage; + gi_probe.probe = p_base; + RID rid = gi_probe_instance_owner.make_rid(gi_probe); + return rid; +} + +void RendererSceneGIRD::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) { + GIProbeInstance *gi_probe = get_probe_instance(p_probe); + ERR_FAIL_COND(!gi_probe); + + gi_probe->transform = p_xform; +} + +bool RendererSceneGIRD::gi_probe_needs_update(RID p_probe) const { + GIProbeInstance *gi_probe = get_probe_instance(p_probe); + ERR_FAIL_COND_V(!gi_probe, false); + + return gi_probe->last_probe_version != storage->gi_probe_get_version(gi_probe->probe); +} + +void RendererSceneGIRD::gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render) { + GIProbeInstance *gi_probe = get_probe_instance(p_probe); + ERR_FAIL_COND(!gi_probe); + + gi_probe->update(p_update_light_instances, p_light_instances, p_dynamic_objects, p_scene_render); +} + +void RendererSceneGIRD::debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) { + GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_gi_probe); + ERR_FAIL_COND(!gi_probe); + + gi_probe->debug(p_draw_list, p_framebuffer, p_camera_with_transform, p_lighting, p_emission, p_alpha); +} diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.h b/servers/rendering/renderer_rd/renderer_scene_gi_rd.h new file mode 100644 index 0000000000..c0f3318538 --- /dev/null +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.h @@ -0,0 +1,668 @@ +/*************************************************************************/ +/* renderer_scene_gi_rd.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef RENDERING_SERVER_SCENE_GI_RD_H +#define RENDERING_SERVER_SCENE_GI_RD_H + +#include "core/templates/local_vector.h" +#include "core/templates/rid_owner.h" +#include "servers/rendering/renderer_compositor.h" +#include "servers/rendering/renderer_rd/renderer_scene_environment_rd.h" +#include "servers/rendering/renderer_rd/renderer_scene_sky_rd.h" +#include "servers/rendering/renderer_rd/renderer_storage_rd.h" +#include "servers/rendering/renderer_rd/shaders/gi.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/giprobe.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/giprobe_debug.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/sdfgi_debug.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/sdfgi_debug_probes.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl.gen.h" +#include "servers/rendering/renderer_scene_render.h" +#include "servers/rendering/rendering_device.h" + +// Forward declare RendererSceneRenderRD so we can pass it into some of our methods, these classes are pretty tightly bound +class RendererSceneRenderRD; + +class RendererSceneGIRD { +private: + RendererStorageRD *storage; + + /* GIPROBE INSTANCE */ + + struct GIProbeLight { + uint32_t type; + float energy; + float radius; + float attenuation; + + float color[3]; + float cos_spot_angle; + + float position[3]; + float inv_spot_attenuation; + + float direction[3]; + uint32_t has_shadow; + }; + + struct GIProbePushConstant { + int32_t limits[3]; + uint32_t stack_size; + + float emission_scale; + float propagation; + float dynamic_range; + uint32_t light_count; + + uint32_t cell_offset; + uint32_t cell_count; + float aniso_strength; + uint32_t pad; + }; + + struct GIProbeDynamicPushConstant { + int32_t limits[3]; + uint32_t light_count; + int32_t x_dir[3]; + float z_base; + int32_t y_dir[3]; + float z_sign; + int32_t z_dir[3]; + float pos_multiplier; + uint32_t rect_pos[2]; + uint32_t rect_size[2]; + uint32_t prev_rect_ofs[2]; + uint32_t prev_rect_size[2]; + uint32_t flip_x; + uint32_t flip_y; + float dynamic_range; + uint32_t on_mipmap; + float propagation; + float pad[3]; + }; + + GIProbeLight *gi_probe_lights; + uint32_t gi_probe_max_lights; + RID gi_probe_lights_uniform; + + enum { + GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT, + GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE, + GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP, + GI_PROBE_SHADER_VERSION_WRITE_TEXTURE, + GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING, + GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE, + GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT, + GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT, + GI_PROBE_SHADER_VERSION_MAX + }; + + GiprobeShaderRD giprobe_shader; + RID giprobe_lighting_shader_version; + RID giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_MAX]; + RID giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_MAX]; + + enum { + GI_PROBE_DEBUG_COLOR, + GI_PROBE_DEBUG_LIGHT, + GI_PROBE_DEBUG_EMISSION, + GI_PROBE_DEBUG_LIGHT_FULL, + GI_PROBE_DEBUG_MAX + }; + + struct GIProbeDebugPushConstant { + float projection[16]; + uint32_t cell_offset; + float dynamic_range; + float alpha; + uint32_t level; + int32_t bounds[3]; + uint32_t pad; + }; + + GiprobeDebugShaderRD giprobe_debug_shader; + RID giprobe_debug_shader_version; + RID giprobe_debug_shader_version_shaders[GI_PROBE_DEBUG_MAX]; + PipelineCacheRD giprobe_debug_shader_version_pipelines[GI_PROBE_DEBUG_MAX]; + RID giprobe_debug_uniform_set; + + /* SDFGI */ + + struct SDFGIShader { + enum SDFGIPreprocessShaderVersion { + PRE_PROCESS_SCROLL, + PRE_PROCESS_SCROLL_OCCLUSION, + PRE_PROCESS_JUMP_FLOOD_INITIALIZE, + PRE_PROCESS_JUMP_FLOOD_INITIALIZE_HALF, + PRE_PROCESS_JUMP_FLOOD, + PRE_PROCESS_JUMP_FLOOD_OPTIMIZED, + PRE_PROCESS_JUMP_FLOOD_UPSCALE, + PRE_PROCESS_OCCLUSION, + PRE_PROCESS_STORE, + PRE_PROCESS_MAX + }; + + struct PreprocessPushConstant { + int32_t scroll[3]; + int32_t grid_size; + + int32_t probe_offset[3]; + int32_t step_size; + + int32_t half_size; + uint32_t occlusion_index; + int32_t cascade; + uint32_t pad; + }; + + SdfgiPreprocessShaderRD preprocess; + RID preprocess_shader; + RID preprocess_pipeline[PRE_PROCESS_MAX]; + + struct DebugPushConstant { + float grid_size[3]; + uint32_t max_cascades; + + int32_t screen_size[2]; + uint32_t use_occlusion; + float y_mult; + + float cam_extent[3]; + uint32_t probe_axis_size; + + float cam_transform[16]; + }; + + SdfgiDebugShaderRD debug; + RID debug_shader; + RID debug_shader_version; + RID debug_pipeline; + + enum ProbeDebugMode { + PROBE_DEBUG_PROBES, + PROBE_DEBUG_VISIBILITY, + PROBE_DEBUG_MAX + }; + + struct DebugProbesPushConstant { + float projection[16]; + + uint32_t band_power; + uint32_t sections_in_band; + uint32_t band_mask; + float section_arc; + + float grid_size[3]; + uint32_t cascade; + + uint32_t pad; + float y_mult; + int32_t probe_debug_index; + int32_t probe_axis_size; + }; + + SdfgiDebugProbesShaderRD debug_probes; + RID debug_probes_shader; + RID debug_probes_shader_version; + + PipelineCacheRD debug_probes_pipeline[PROBE_DEBUG_MAX]; + + struct Light { + float color[3]; + float energy; + + float direction[3]; + uint32_t has_shadow; + + float position[3]; + float attenuation; + + uint32_t type; + float cos_spot_angle; + float inv_spot_attenuation; + float radius; + + float shadow_color[4]; + }; + + struct DirectLightPushConstant { + float grid_size[3]; + uint32_t max_cascades; + + uint32_t cascade; + uint32_t light_count; + uint32_t process_offset; + uint32_t process_increment; + + int32_t probe_axis_size; + float bounce_feedback; + float y_mult; + uint32_t use_occlusion; + }; + + enum { + DIRECT_LIGHT_MODE_STATIC, + DIRECT_LIGHT_MODE_DYNAMIC, + DIRECT_LIGHT_MODE_MAX + }; + SdfgiDirectLightShaderRD direct_light; + RID direct_light_shader; + RID direct_light_pipeline[DIRECT_LIGHT_MODE_MAX]; + + enum { + INTEGRATE_MODE_PROCESS, + INTEGRATE_MODE_STORE, + INTEGRATE_MODE_SCROLL, + INTEGRATE_MODE_SCROLL_STORE, + INTEGRATE_MODE_MAX + }; + struct IntegratePushConstant { + enum { + SKY_MODE_DISABLED, + SKY_MODE_COLOR, + SKY_MODE_SKY, + }; + + float grid_size[3]; + uint32_t max_cascades; + + uint32_t probe_axis_size; + uint32_t cascade; + uint32_t history_index; + uint32_t history_size; + + uint32_t ray_count; + float ray_bias; + int32_t image_size[2]; + + int32_t world_offset[3]; + uint32_t sky_mode; + + int32_t scroll[3]; + float sky_energy; + + float sky_color[3]; + float y_mult; + + uint32_t store_ambient_texture; + uint32_t pad[3]; + }; + + SdfgiIntegrateShaderRD integrate; + RID integrate_shader; + RID integrate_pipeline[INTEGRATE_MODE_MAX]; + + RID integrate_default_sky_uniform_set; + + } sdfgi_shader; + +public: + /* GIPROBE INSTANCE */ + + //@TODO GIProbeInstance is still directly used in the render code, we'll address this when we refactor the render code itself. + + struct GIProbeInstance { + // access to our containers + RendererStorageRD *storage; + RendererSceneGIRD *gi; + + RID probe; + RID texture; + RID write_buffer; + + struct Mipmap { + RID texture; + RID uniform_set; + RID second_bounce_uniform_set; + RID write_uniform_set; + uint32_t level; + uint32_t cell_offset; + uint32_t cell_count; + }; + Vector<Mipmap> mipmaps; + + struct DynamicMap { + RID texture; //color normally, or emission on first pass + RID fb_depth; //actual depth buffer for the first pass, float depth for later passes + RID depth; //actual depth buffer for the first pass, float depth for later passes + RID normal; //normal buffer for the first pass + RID albedo; //emission buffer for the first pass + RID orm; //orm buffer for the first pass + RID fb; //used for rendering, only valid on first map + RID uniform_set; + uint32_t size; + int mipmap; // mipmap to write to, -1 if no mipmap assigned + }; + + Vector<DynamicMap> dynamic_maps; + + int slot = -1; + uint32_t last_probe_version = 0; + uint32_t last_probe_data_version = 0; + + //uint64_t last_pass = 0; + uint32_t render_index = 0; + + bool has_dynamic_object_data = false; + + Transform transform; + + void update(bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render); + void debug(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha); + }; + + mutable RID_Owner<GIProbeInstance> gi_probe_instance_owner; + + _FORCE_INLINE_ GIProbeInstance *get_probe_instance(RID p_probe) const { + return gi_probe_instance_owner.getornull(p_probe); + }; + + _FORCE_INLINE_ RID gi_probe_instance_get_texture(RID p_probe) { + GIProbeInstance *gi_probe = get_probe_instance(p_probe); + ERR_FAIL_COND_V(!gi_probe, RID()); + return gi_probe->texture; + }; + + RS::GIProbeQuality gi_probe_quality = RS::GI_PROBE_QUALITY_HIGH; + + /* SDFGI */ + + struct SDFGI { + enum { + MAX_CASCADES = 8, + CASCADE_SIZE = 128, + PROBE_DIVISOR = 16, + ANISOTROPY_SIZE = 6, + MAX_DYNAMIC_LIGHTS = 128, + MAX_STATIC_LIGHTS = 1024, + LIGHTPROBE_OCT_SIZE = 6, + SH_SIZE = 16 + }; + + struct Cascade { + struct UBO { + float offset[3]; + float to_cell; + int32_t probe_offset[3]; + uint32_t pad; + }; + + //cascade blocks are full-size for volume (128^3), half size for albedo/emission + RID sdf_tex; + RID light_tex; + RID light_aniso_0_tex; + RID light_aniso_1_tex; + + RID light_data; + RID light_aniso_0_data; + RID light_aniso_1_data; + + struct SolidCell { // this struct is unused, but remains as reference for size + uint32_t position; + uint32_t albedo; + uint32_t static_light; + uint32_t static_light_aniso; + }; + + RID solid_cell_dispatch_buffer; //buffer for indirect compute dispatch + RID solid_cell_buffer; + + RID lightprobe_history_tex; + RID lightprobe_average_tex; + + float cell_size; + Vector3i position; + + static const Vector3i DIRTY_ALL; + Vector3i dirty_regions; //(0,0,0 is not dirty, negative is refresh from the end, DIRTY_ALL is refresh all. + + RID sdf_store_uniform_set; + RID sdf_direct_light_uniform_set; + RID scroll_uniform_set; + RID scroll_occlusion_uniform_set; + RID integrate_uniform_set; + RID lights_buffer; + + bool all_dynamic_lights_dirty = true; + }; + + // access to our containers + RendererStorageRD *storage; + RendererSceneGIRD *gi; + + // used for rendering (voxelization) + RID render_albedo; + RID render_emission; + RID render_emission_aniso; + RID render_occlusion[8]; + RID render_geom_facing; + + RID render_sdf[2]; + RID render_sdf_half[2]; + + // used for ping pong processing in cascades + RID sdf_initialize_uniform_set; + RID sdf_initialize_half_uniform_set; + RID jump_flood_uniform_set[2]; + RID jump_flood_half_uniform_set[2]; + RID sdf_upscale_uniform_set; + int upscale_jfa_uniform_set_index; + RID occlusion_uniform_set; + + uint32_t cascade_size = 128; + + LocalVector<Cascade> cascades; + + RID lightprobe_texture; + RID lightprobe_data; + RID occlusion_texture; + RID occlusion_data; + RID ambient_texture; //integrates with volumetric fog + + RID lightprobe_history_scroll; //used for scrolling lightprobes + RID lightprobe_average_scroll; //used for scrolling lightprobes + + uint32_t history_size = 0; + float solid_cell_ratio = 0; + uint32_t solid_cell_count = 0; + + RS::EnvironmentSDFGICascades cascade_mode; + float min_cell_size = 0; + uint32_t probe_axis_count = 0; //amount of probes per axis, this is an odd number because it encloses endpoints + + RID debug_uniform_set; + RID debug_probes_uniform_set; + RID cascades_ubo; + + bool uses_occlusion = false; + float bounce_feedback = 0.0; + bool reads_sky = false; + float energy = 1.0; + float normal_bias = 1.1; + float probe_bias = 1.1; + RS::EnvironmentSDFGIYScale y_scale_mode = RS::ENV_SDFGI_Y_SCALE_DISABLED; + + float y_mult = 1.0; + + uint32_t render_pass = 0; + + int32_t cascade_dynamic_light_count[SDFGI::MAX_CASCADES]; //used dynamically + RID integrate_sky_uniform_set; + + void create(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size, RendererSceneGIRD *p_gi); + void erase(); + void update(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position); + void update_light(); + void update_probes(RendererSceneEnvironmentRD *p_env, RendererSceneSkyRD::Sky *p_sky); + void store_probes(); + int get_pending_region_data(int p_region, Vector3i &r_local_offset, Vector3i &r_local_size, AABB &r_bounds) const; + void update_cascades(); + + void debug_draw(const CameraMatrix &p_projection, const Transform &p_transform, int p_width, int p_height, RID p_render_target, RID p_texture); + void debug_probes(RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform); + + void pre_process_gi(const Transform &p_transform, RendererSceneRenderRD *p_scene_render); + void render_region(RID p_render_buffers, int p_region, const PagedArray<RendererSceneRender::GeometryInstance *> &p_instances, RendererSceneRenderRD *p_scene_render); + void render_static_lights(RID p_render_buffers, uint32_t p_cascade_count, const uint32_t *p_cascade_indices, const PagedArray<RID> *p_positional_light_cull_result, RendererSceneRenderRD *p_scene_render); + }; + + RS::EnvironmentSDFGIRayCount sdfgi_ray_count = RS::ENV_SDFGI_RAY_COUNT_16; + RS::EnvironmentSDFGIFramesToConverge sdfgi_frames_to_converge = RS::ENV_SDFGI_CONVERGE_IN_10_FRAMES; + RS::EnvironmentSDFGIFramesToUpdateLight sdfgi_frames_to_update_light = RS::ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES; + + float sdfgi_solid_cell_ratio = 0.25; + Vector3 sdfgi_debug_probe_pos; + Vector3 sdfgi_debug_probe_dir; + bool sdfgi_debug_probe_enabled = false; + Vector3i sdfgi_debug_probe_index; + + /* SDFGI UPDATE */ + + int sdfgi_get_lightprobe_octahedron_size() const { return SDFGI::LIGHTPROBE_OCT_SIZE; } + + /* GI */ + enum { + MAX_GIPROBES = 8 + }; + + // Struct for use in render buffer + struct RenderBuffersGI { + RID giprobe_textures[MAX_GIPROBES]; + RID giprobe_buffer; + + RID full_buffer; + RID full_dispatch; + RID full_mask; + }; + + struct SDFGIData { + float grid_size[3]; + uint32_t max_cascades; + + uint32_t use_occlusion; + int32_t probe_axis_size; + float probe_to_uvw; + float normal_bias; + + float lightprobe_tex_pixel_size[3]; + float energy; + + float lightprobe_uv_offset[3]; + float y_mult; + + float occlusion_clamp[3]; + uint32_t pad3; + + float occlusion_renormalize[3]; + uint32_t pad4; + + float cascade_probe_size[3]; + uint32_t pad5; + + struct ProbeCascadeData { + float position[3]; //offset of (0,0,0) in world coordinates + float to_probe; // 1/bounds * grid_size + int32_t probe_world_offset[3]; + float to_cell; // 1/bounds * grid_size + }; + + ProbeCascadeData cascades[SDFGI::MAX_CASCADES]; + }; + + struct GIProbeData { + float xform[16]; + float bounds[3]; + float dynamic_range; + + float bias; + float normal_bias; + uint32_t blend_ambient; + uint32_t texture_slot; + + float anisotropy_strength; + float ao; + float ao_size; + uint32_t mipmaps; + }; + + struct PushConstant { + int32_t screen_size[2]; + float z_near; + float z_far; + + float proj_info[4]; + float ao_color[3]; + uint32_t max_giprobes; + + uint32_t high_quality_vct; + uint32_t orthogonal; + uint32_t pad[2]; + + float cam_rotation[12]; + }; + + RID sdfgi_ubo; + enum Mode { + MODE_GIPROBE, + MODE_SDFGI, + MODE_COMBINED, + MODE_HALF_RES_GIPROBE, + MODE_HALF_RES_SDFGI, + MODE_HALF_RES_COMBINED, + MODE_MAX + }; + + RID default_giprobe_buffer; + + bool half_resolution = false; + GiShaderRD shader; + RID shader_version; + RID pipelines[MODE_MAX]; + + RendererSceneGIRD(); + ~RendererSceneGIRD(); + + void init(RendererStorageRD *p_storage, RendererSceneSkyRD *p_sky); + void free(); + + SDFGI *create_sdfgi(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world_position, uint32_t p_requested_history_size); + + void setup_giprobes(RID p_render_buffers, const Transform &p_transform, const PagedArray<RID> &p_gi_probes, uint32_t &r_gi_probes_used, RendererSceneRenderRD *p_scene_render); + void process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_gi_probe_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform, const PagedArray<RID> &p_gi_probes, RendererSceneRenderRD *p_scene_render); + + RID gi_probe_instance_create(RID p_base); + void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform); + bool gi_probe_needs_update(RID p_probe) const; + void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects, RendererSceneRenderRD *p_scene_render); + void debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha); +}; + +#endif /* !RENDERING_SERVER_SCENE_GI_RD_H */ diff --git a/servers/rendering/renderer_rd/renderer_scene_render_forward.cpp b/servers/rendering/renderer_rd/renderer_scene_render_forward_clustered.cpp index a57dee7314..7a19495f48 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_forward.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_forward_clustered.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* renderer_scene_render_forward.cpp */ +/* renderer_scene_render_forward_clustered.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "renderer_scene_render_forward.h" +#include "renderer_scene_render_forward_clustered.h" #include "core/config/project_settings.h" #include "servers/rendering/rendering_device.h" #include "servers/rendering/rendering_server_default.h" /* SCENE SHADER */ -void RendererSceneRenderForward::ShaderData::set_code(const String &p_code) { +void RendererSceneRenderForwardClustered::ShaderData::set_code(const String &p_code) { //compile code = p_code; @@ -123,7 +123,7 @@ void RendererSceneRenderForward::ShaderData::set_code(const String &p_code) { actions.uniforms = &uniforms; - RendererSceneRenderForward *scene_singleton = (RendererSceneRenderForward *)RendererSceneRenderForward::singleton; + RendererSceneRenderForwardClustered *scene_singleton = (RendererSceneRenderForwardClustered *)RendererSceneRenderForwardClustered::singleton; Error err = scene_singleton->shader.compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code); @@ -257,7 +257,7 @@ void RendererSceneRenderForward::ShaderData::set_code(const String &p_code) { RD::RenderPrimitive primitive_rd = uses_point_size ? RD::RENDER_PRIMITIVE_POINTS : primitive_rd_table[j]; for (int k = 0; k < SHADER_VERSION_MAX; k++) { - if (!static_cast<RendererSceneRenderForward *>(singleton)->shader.scene_shader.is_variant_enabled(k)) { + if (!static_cast<RendererSceneRenderForwardClustered *>(singleton)->shader.scene_shader.is_variant_enabled(k)) { continue; } RD::PipelineRasterizationState raster_state; @@ -324,7 +324,7 @@ void RendererSceneRenderForward::ShaderData::set_code(const String &p_code) { valid = true; } -void RendererSceneRenderForward::ShaderData::set_default_texture_param(const StringName &p_name, RID p_texture) { +void RendererSceneRenderForwardClustered::ShaderData::set_default_texture_param(const StringName &p_name, RID p_texture) { if (!p_texture.is_valid()) { default_texture_params.erase(p_name); } else { @@ -332,7 +332,7 @@ void RendererSceneRenderForward::ShaderData::set_default_texture_param(const Str } } -void RendererSceneRenderForward::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { +void RendererSceneRenderForwardClustered::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { Map<int, StringName> order; for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { @@ -354,7 +354,7 @@ void RendererSceneRenderForward::ShaderData::get_param_list(List<PropertyInfo> * } } -void RendererSceneRenderForward::ShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const { +void RendererSceneRenderForwardClustered::ShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const { for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { continue; @@ -369,7 +369,7 @@ void RendererSceneRenderForward::ShaderData::get_instance_param_list(List<Render } } -bool RendererSceneRenderForward::ShaderData::is_param_texture(const StringName &p_param) const { +bool RendererSceneRenderForwardClustered::ShaderData::is_param_texture(const StringName &p_param) const { if (!uniforms.has(p_param)) { return false; } @@ -377,15 +377,15 @@ bool RendererSceneRenderForward::ShaderData::is_param_texture(const StringName & return uniforms[p_param].texture_order >= 0; } -bool RendererSceneRenderForward::ShaderData::is_animated() const { +bool RendererSceneRenderForwardClustered::ShaderData::is_animated() const { return false; } -bool RendererSceneRenderForward::ShaderData::casts_shadows() const { +bool RendererSceneRenderForwardClustered::ShaderData::casts_shadows() const { return false; } -Variant RendererSceneRenderForward::ShaderData::get_default_parameter(const StringName &p_parameter) const { +Variant RendererSceneRenderForwardClustered::ShaderData::get_default_parameter(const StringName &p_parameter) const { if (uniforms.has(p_parameter)) { ShaderLanguage::ShaderNode::Uniform uniform = uniforms[p_parameter]; Vector<ShaderLanguage::ConstantNode::Value> default_value = uniform.default_value; @@ -394,19 +394,19 @@ Variant RendererSceneRenderForward::ShaderData::get_default_parameter(const Stri return Variant(); } -RS::ShaderNativeSourceCode RendererSceneRenderForward::ShaderData::get_native_source_code() const { - RendererSceneRenderForward *scene_singleton = (RendererSceneRenderForward *)RendererSceneRenderForward::singleton; +RS::ShaderNativeSourceCode RendererSceneRenderForwardClustered::ShaderData::get_native_source_code() const { + RendererSceneRenderForwardClustered *scene_singleton = (RendererSceneRenderForwardClustered *)RendererSceneRenderForwardClustered::singleton; return scene_singleton->shader.scene_shader.version_get_native_source_code(version); } -RendererSceneRenderForward::ShaderData::ShaderData() { +RendererSceneRenderForwardClustered::ShaderData::ShaderData() { valid = false; uses_screen_texture = false; } -RendererSceneRenderForward::ShaderData::~ShaderData() { - RendererSceneRenderForward *scene_singleton = (RendererSceneRenderForward *)RendererSceneRenderForward::singleton; +RendererSceneRenderForwardClustered::ShaderData::~ShaderData() { + RendererSceneRenderForwardClustered *scene_singleton = (RendererSceneRenderForwardClustered *)RendererSceneRenderForwardClustered::singleton; ERR_FAIL_COND(!scene_singleton); //pipeline variants will clear themselves if shader is gone if (version.is_valid()) { @@ -414,21 +414,21 @@ RendererSceneRenderForward::ShaderData::~ShaderData() { } } -RendererStorageRD::ShaderData *RendererSceneRenderForward::_create_shader_func() { +RendererStorageRD::ShaderData *RendererSceneRenderForwardClustered::_create_shader_func() { ShaderData *shader_data = memnew(ShaderData); return shader_data; } -void RendererSceneRenderForward::MaterialData::set_render_priority(int p_priority) { +void RendererSceneRenderForwardClustered::MaterialData::set_render_priority(int p_priority) { priority = p_priority - RS::MATERIAL_RENDER_PRIORITY_MIN; //8 bits } -void RendererSceneRenderForward::MaterialData::set_next_pass(RID p_pass) { +void RendererSceneRenderForwardClustered::MaterialData::set_next_pass(RID p_pass) { next_pass = p_pass; } -void RendererSceneRenderForward::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { - RendererSceneRenderForward *scene_singleton = (RendererSceneRenderForward *)RendererSceneRenderForward::singleton; +void RendererSceneRenderForwardClustered::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { + RendererSceneRenderForwardClustered *scene_singleton = (RendererSceneRenderForwardClustered *)RendererSceneRenderForwardClustered::singleton; if ((uint32_t)ubo_data.size() != shader_data->ubo_size) { p_uniform_dirty = true; @@ -507,7 +507,7 @@ void RendererSceneRenderForward::MaterialData::update_parameters(const Map<Strin uniform_set = RD::get_singleton()->uniform_set_create(uniforms, scene_singleton->shader.scene_shader.version_get_shader(shader_data->version, 0), MATERIAL_UNIFORM_SET); } -RendererSceneRenderForward::MaterialData::~MaterialData() { +RendererSceneRenderForwardClustered::MaterialData::~MaterialData() { if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { RD::get_singleton()->free(uniform_set); } @@ -517,7 +517,7 @@ RendererSceneRenderForward::MaterialData::~MaterialData() { } } -RendererStorageRD::MaterialData *RendererSceneRenderForward::_create_material_func(ShaderData *p_shader) { +RendererStorageRD::MaterialData *RendererSceneRenderForwardClustered::_create_material_func(ShaderData *p_shader) { MaterialData *material_data = memnew(MaterialData); material_data->shader_data = p_shader; material_data->last_frame = false; @@ -525,11 +525,11 @@ RendererStorageRD::MaterialData *RendererSceneRenderForward::_create_material_fu return material_data; } -RendererSceneRenderForward::RenderBufferDataForward::~RenderBufferDataForward() { +RendererSceneRenderForwardClustered::RenderBufferDataForward::~RenderBufferDataForward() { clear(); } -void RendererSceneRenderForward::RenderBufferDataForward::ensure_specular() { +void RendererSceneRenderForwardClustered::RenderBufferDataForward::ensure_specular() { if (!specular.is_valid()) { RD::TextureFormat tf; tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; @@ -583,7 +583,7 @@ void RendererSceneRenderForward::RenderBufferDataForward::ensure_specular() { } } -void RendererSceneRenderForward::RenderBufferDataForward::ensure_giprobe() { +void RendererSceneRenderForwardClustered::RenderBufferDataForward::ensure_giprobe() { if (!giprobe_buffer.is_valid()) { RD::TextureFormat tf; tf.format = RD::DATA_FORMAT_R8G8_UINT; @@ -619,7 +619,7 @@ void RendererSceneRenderForward::RenderBufferDataForward::ensure_giprobe() { } } -void RendererSceneRenderForward::RenderBufferDataForward::clear() { +void RendererSceneRenderForwardClustered::RenderBufferDataForward::clear() { if (giprobe_buffer != RID()) { RD::get_singleton()->free(giprobe_buffer); giprobe_buffer = RID(); @@ -673,7 +673,7 @@ void RendererSceneRenderForward::RenderBufferDataForward::clear() { } } -void RendererSceneRenderForward::RenderBufferDataForward::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) { +void RendererSceneRenderForwardClustered::RenderBufferDataForward::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) { clear(); msaa = p_msaa; @@ -740,7 +740,7 @@ void RendererSceneRenderForward::RenderBufferDataForward::configure(RID p_color_ } } -void RendererSceneRenderForward::_allocate_normal_roughness_texture(RenderBufferDataForward *rb) { +void RendererSceneRenderForwardClustered::_allocate_normal_roughness_texture(RenderBufferDataForward *rb) { if (rb->normal_roughness_buffer.is_valid()) { return; } @@ -778,11 +778,11 @@ void RendererSceneRenderForward::_allocate_normal_roughness_texture(RenderBuffer _render_buffers_clear_uniform_set(rb); } -RendererSceneRenderRD::RenderBufferData *RendererSceneRenderForward::_create_render_buffer_data() { +RendererSceneRenderRD::RenderBufferData *RendererSceneRenderForwardClustered::_create_render_buffer_data() { return memnew(RenderBufferDataForward); } -bool RendererSceneRenderForward::free(RID p_rid) { +bool RendererSceneRenderForwardClustered::free(RID p_rid) { if (RendererSceneRenderRD::free(p_rid)) { return true; } @@ -791,8 +791,8 @@ bool RendererSceneRenderForward::free(RID p_rid) { /// RENDERING /// -template <RendererSceneRenderForward::PassMode p_pass_mode> -void RendererSceneRenderForward::_render_list_template(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element) { +template <RendererSceneRenderForwardClustered::PassMode p_pass_mode> +void RendererSceneRenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element) { RD::DrawListID draw_list = p_draw_list; RD::FramebufferFormatID framebuffer_format = p_framebuffer_Format; @@ -961,7 +961,7 @@ void RendererSceneRenderForward::_render_list_template(RenderingDevice::DrawList } } -void RendererSceneRenderForward::_render_list(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element) { +void RendererSceneRenderForwardClustered::_render_list(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element) { //use template for faster performance (pass mode comparisons are inlined) switch (p_params->pass_mode) { @@ -998,7 +998,7 @@ void RendererSceneRenderForward::_render_list(RenderingDevice::DrawListID p_draw } } -void RendererSceneRenderForward::_render_list_thread_function(uint32_t p_thread, RenderListParameters *p_params) { +void RendererSceneRenderForwardClustered::_render_list_thread_function(uint32_t p_thread, RenderListParameters *p_params) { uint32_t render_total = p_params->element_count; uint32_t total_threads = RendererThreadPool::singleton->thread_work_pool.get_thread_count(); uint32_t render_from = p_thread * render_total / total_threads; @@ -1006,7 +1006,7 @@ void RendererSceneRenderForward::_render_list_thread_function(uint32_t p_thread, _render_list(thread_draw_lists[p_thread], p_params->framebuffer_format, p_params, render_from, render_to); } -void RendererSceneRenderForward::_render_list_with_threads(RenderListParameters *p_params, RID p_framebuffer, RD::InitialAction p_initial_color_action, RD::FinalAction p_final_color_action, RD::InitialAction p_initial_depth_action, RD::FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const Vector<RID> &p_storage_textures) { +void RendererSceneRenderForwardClustered::_render_list_with_threads(RenderListParameters *p_params, RID p_framebuffer, RD::InitialAction p_initial_color_action, RD::FinalAction p_final_color_action, RD::InitialAction p_initial_depth_action, RD::FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const Vector<RID> &p_storage_textures) { RD::FramebufferFormatID fb_format = RD::get_singleton()->framebuffer_get_format(p_framebuffer); p_params->framebuffer_format = fb_format; @@ -1014,7 +1014,7 @@ void RendererSceneRenderForward::_render_list_with_threads(RenderListParameters //multi threaded thread_draw_lists.resize(RendererThreadPool::singleton->thread_work_pool.get_thread_count()); RD::get_singleton()->draw_list_begin_split(p_framebuffer, thread_draw_lists.size(), thread_draw_lists.ptr(), p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, p_clear_color_values, p_clear_depth, p_clear_stencil, p_region, p_storage_textures); - RendererThreadPool::singleton->thread_work_pool.do_work(thread_draw_lists.size(), this, &RendererSceneRenderForward::_render_list_thread_function, p_params); + RendererThreadPool::singleton->thread_work_pool.do_work(thread_draw_lists.size(), this, &RendererSceneRenderForwardClustered::_render_list_thread_function, p_params); RD::get_singleton()->draw_list_end(p_params->barrier); } else { //single threaded @@ -1024,7 +1024,7 @@ void RendererSceneRenderForward::_render_list_with_threads(RenderListParameters } } -void RendererSceneRenderForward::_setup_environment(RID p_environment, RID p_render_buffers, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, RID p_reflection_probe, bool p_no_fog, const Size2i &p_screen_size, uint32_t p_cluster_size, uint32_t p_max_cluster_elements, RID p_shadow_atlas, bool p_flip_y, const Color &p_default_bg_color, float p_znear, float p_zfar, bool p_opaque_render_buffers, bool p_pancake_shadows, int p_index) { +void RendererSceneRenderForwardClustered::_setup_environment(RID p_environment, RID p_render_buffers, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, RID p_reflection_probe, bool p_no_fog, const Size2i &p_screen_size, uint32_t p_cluster_size, uint32_t p_max_cluster_elements, RID p_shadow_atlas, bool p_flip_y, const Color &p_default_bg_color, float p_znear, float p_zfar, bool p_opaque_render_buffers, bool p_pancake_shadows, int p_index) { //CameraMatrix projection = p_cam_projection; //projection.flip_y(); // Vulkan and modern APIs use Y-Down CameraMatrix correction; @@ -1130,7 +1130,7 @@ void RendererSceneRenderForward::_setup_environment(RID p_environment, RID p_ren //vec2 tex_pixel_size = 1.0 / vec2(ivec2( (OCT_SIZE+2) * params.probe_axis_size * params.probe_axis_size, (OCT_SIZE+2) * params.probe_axis_size ) ); //vec3 probe_uv_offset = (ivec3(OCT_SIZE+2,OCT_SIZE+2,(OCT_SIZE+2) * params.probe_axis_size)) * tex_pixel_size.xyx; - uint32_t oct_size = sdfgi_get_lightprobe_octahedron_size(); + uint32_t oct_size = gi.sdfgi_get_lightprobe_octahedron_size(); scene_state.ubo.sdfgi_lightprobe_tex_pixel_size[0] = 1.0 / ((oct_size + 2) * scene_state.ubo.sdfgi_probe_axis_size * scene_state.ubo.sdfgi_probe_axis_size); scene_state.ubo.sdfgi_lightprobe_tex_pixel_size[1] = 1.0 / ((oct_size + 2) * scene_state.ubo.sdfgi_probe_axis_size); @@ -1274,7 +1274,7 @@ void RendererSceneRenderForward::_setup_environment(RID p_environment, RID p_ren RD::get_singleton()->buffer_update(scene_state.uniform_buffers[p_index], 0, sizeof(SceneState::UBO), &scene_state.ubo, RD::BARRIER_MASK_RASTER); } -void RendererSceneRenderForward::_update_instance_data_buffer(RenderListType p_render_list) { +void RendererSceneRenderForwardClustered::_update_instance_data_buffer(RenderListType p_render_list) { if (scene_state.instance_data[p_render_list].size() > 0) { if (scene_state.instance_buffer[p_render_list] == RID() || scene_state.instance_buffer_size[p_render_list] < scene_state.instance_data[p_render_list].size()) { if (scene_state.instance_buffer[p_render_list] != RID()) { @@ -1287,7 +1287,7 @@ void RendererSceneRenderForward::_update_instance_data_buffer(RenderListType p_r RD::get_singleton()->buffer_update(scene_state.instance_buffer[p_render_list], 0, sizeof(SceneState::InstanceData) * scene_state.instance_data[p_render_list].size(), scene_state.instance_data[p_render_list].ptr(), RD::BARRIER_MASK_RASTER); } } -void RendererSceneRenderForward::_fill_instance_data(RenderListType p_render_list, uint32_t p_offset, int32_t p_max_elements, bool p_update_buffer) { +void RendererSceneRenderForwardClustered::_fill_instance_data(RenderListType p_render_list, uint32_t p_offset, int32_t p_max_elements, bool p_update_buffer) { RenderList *rl = &render_list[p_render_list]; uint32_t element_total = p_max_elements >= 0 ? uint32_t(p_max_elements) : rl->elements.size(); @@ -1298,7 +1298,7 @@ void RendererSceneRenderForward::_fill_instance_data(RenderListType p_render_lis GeometryInstanceSurfaceDataCache *prev_surface = nullptr; for (uint32_t i = 0; i < element_total; i++) { GeometryInstanceSurfaceDataCache *surface = rl->elements[i + p_offset]; - GeometryInstanceForward *inst = surface->owner; + GeometryInstanceForwardClustered *inst = surface->owner; SceneState::InstanceData &instance_data = scene_state.instance_data[p_render_list][i + p_offset]; @@ -1355,7 +1355,7 @@ void RendererSceneRenderForward::_fill_instance_data(RenderListType p_render_lis } } -void RendererSceneRenderForward::_fill_render_list(RenderListType p_render_list, const PagedArray<GeometryInstance *> &p_instances, PassMode p_pass_mode, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_using_sdfgi, bool p_using_opaque_gi, const Plane &p_lod_plane, float p_lod_distance_multiplier, float p_screen_lod_threshold, bool p_append) { +void RendererSceneRenderForwardClustered::_fill_render_list(RenderListType p_render_list, const PagedArray<GeometryInstance *> &p_instances, PassMode p_pass_mode, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_using_sdfgi, bool p_using_opaque_gi, const Plane &p_lod_plane, float p_lod_distance_multiplier, float p_screen_lod_threshold, bool p_append) { if (p_render_list == RENDER_LIST_OPAQUE) { scene_state.used_sss = false; scene_state.used_screen_texture = false; @@ -1381,7 +1381,7 @@ void RendererSceneRenderForward::_fill_render_list(RenderListType p_render_list, //fill list for (int i = 0; i < (int)p_instances.size(); i++) { - GeometryInstanceForward *inst = static_cast<GeometryInstanceForward *>(p_instances[i]); + GeometryInstanceForwardClustered *inst = static_cast<GeometryInstanceForwardClustered *>(p_instances[i]); Vector3 support_min = inst->transformed_aabb.get_support(-near_plane.normal); inst->depth = near_plane.distance_to(support_min); @@ -1549,14 +1549,14 @@ void RendererSceneRenderForward::_fill_render_list(RenderListType p_render_list, } } -void RendererSceneRenderForward::_setup_giprobes(const PagedArray<RID> &p_giprobes) { +void RendererSceneRenderForwardClustered::_setup_giprobes(const PagedArray<RID> &p_giprobes) { scene_state.giprobes_used = MIN(p_giprobes.size(), uint32_t(MAX_GI_PROBES)); for (uint32_t i = 0; i < scene_state.giprobes_used; i++) { scene_state.giprobe_ids[i] = p_giprobes[i]; } } -void RendererSceneRenderForward::_setup_lightmaps(const PagedArray<RID> &p_lightmaps, const Transform &p_cam_transform) { +void RendererSceneRenderForwardClustered::_setup_lightmaps(const PagedArray<RID> &p_lightmaps, const Transform &p_cam_transform) { scene_state.lightmaps_used = 0; for (int i = 0; i < (int)p_lightmaps.size(); i++) { if (i >= (int)scene_state.max_lightmaps) { @@ -1578,11 +1578,12 @@ void RendererSceneRenderForward::_setup_lightmaps(const PagedArray<RID> &p_light } } -void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_cluster_buffer, uint32_t p_cluster_size, uint32_t p_max_cluster_elements, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, const Color &p_default_bg_color, float p_screen_lod_threshold) { +void RendererSceneRenderForwardClustered::_render_scene(RID p_render_buffer, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_cluster_buffer, uint32_t p_cluster_size, uint32_t p_max_cluster_elements, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, const Color &p_default_bg_color, float p_screen_lod_threshold) { RenderBufferDataForward *render_buffer = nullptr; if (p_render_buffer.is_valid()) { render_buffer = (RenderBufferDataForward *)render_buffers_get_data(p_render_buffer); } + RendererSceneEnvironmentRD *env = get_environment(p_environment); //first of all, make a new render pass //fill up ubo @@ -1729,7 +1730,7 @@ void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transf clear_color.b *= bg_energy; if (render_buffers_has_volumetric_fog(p_render_buffer) || environment_is_fog_enabled(p_environment)) { draw_sky_fog_only = true; - storage->material_set_param(sky_scene_state.fog_material, "clear_color", Variant(clear_color.to_linear())); + storage->material_set_param(sky.sky_scene_state.fog_material, "clear_color", Variant(clear_color.to_linear())); } } break; case RS::ENV_BG_COLOR: { @@ -1739,7 +1740,7 @@ void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transf clear_color.b *= bg_energy; if (render_buffers_has_volumetric_fog(p_render_buffer) || environment_is_fog_enabled(p_environment)) { draw_sky_fog_only = true; - storage->material_set_param(sky_scene_state.fog_material, "clear_color", Variant(clear_color.to_linear())); + storage->material_set_param(sky.sky_scene_state.fog_material, "clear_color", Variant(clear_color.to_linear())); } } break; case RS::ENV_BG_SKY: { @@ -1767,12 +1768,12 @@ void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transf projection = correction * p_cam_projection; } - _setup_sky(p_environment, p_render_buffer, projection, p_cam_transform, screen_size); + sky.setup(env, p_render_buffer, projection, p_cam_transform, screen_size, this); - RID sky = environment_get_sky(p_environment); - if (sky.is_valid()) { - _update_sky(p_environment, projection, p_cam_transform); - radiance_texture = sky_get_radiance_texture_rd(sky); + RID sky_rid = env->sky; + if (sky_rid.is_valid()) { + sky.update(env, projection, p_cam_transform, time); + radiance_texture = sky.sky_get_radiance_texture_rd(sky_rid); } else { // do not try to draw sky if invalid draw_sky = false; @@ -1890,7 +1891,7 @@ void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transf RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, will_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, will_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); RD::get_singleton()->draw_command_begin_label("Debug GIProbes"); for (int i = 0; i < (int)p_gi_probes.size(); i++) { - _debug_giprobe(p_gi_probes[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0); + gi.debug_giprobe(p_gi_probes[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0); } RD::get_singleton()->draw_command_end_label(); RD::get_singleton()->draw_list_end(); @@ -1921,7 +1922,7 @@ void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transf projection = correction * p_cam_projection; } RD::get_singleton()->draw_command_begin_label("Draw Sky"); - _draw_sky(can_continue_color, can_continue_depth, opaque_framebuffer, p_environment, projection, p_cam_transform); + sky.draw(env, can_continue_color, can_continue_depth, opaque_framebuffer, projection, p_cam_transform, time); RD::get_singleton()->draw_command_end_label(); } @@ -1980,7 +1981,7 @@ void RendererSceneRenderForward::_render_scene(RID p_render_buffer, const Transf RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_render_shadow_begin() { +void RendererSceneRenderForwardClustered::_render_shadow_begin() { scene_state.shadow_passes.clear(); RD::get_singleton()->draw_command_begin_label("Shadow Setup"); _update_render_base_uniform_set(); @@ -1988,7 +1989,7 @@ void RendererSceneRenderForward::_render_shadow_begin() { render_list[RENDER_LIST_SECONDARY].clear(); scene_state.instance_data[RENDER_LIST_SECONDARY].clear(); } -void RendererSceneRenderForward::_render_shadow_append(RID p_framebuffer, const PagedArray<GeometryInstance *> &p_instances, const CameraMatrix &p_projection, const Transform &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end) { +void RendererSceneRenderForwardClustered::_render_shadow_append(RID p_framebuffer, const PagedArray<GeometryInstance *> &p_instances, const CameraMatrix &p_projection, const Transform &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end) { uint32_t shadow_pass_index = scene_state.shadow_passes.size(); SceneState::ShadowPass shadow_pass; @@ -2035,7 +2036,7 @@ void RendererSceneRenderForward::_render_shadow_append(RID p_framebuffer, const } } -void RendererSceneRenderForward::_render_shadow_process() { +void RendererSceneRenderForwardClustered::_render_shadow_process() { _update_instance_data_buffer(RENDER_LIST_SECONDARY); //render shadows one after the other, so this can be done un-barriered and the driver can optimize (as well as allow us to run compute at the same time) @@ -2047,7 +2048,7 @@ void RendererSceneRenderForward::_render_shadow_process() { RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_render_shadow_end(uint32_t p_barrier) { +void RendererSceneRenderForwardClustered::_render_shadow_end(uint32_t p_barrier) { RD::get_singleton()->draw_command_begin_label("Shadow Render"); for (uint32_t i = 0; i < scene_state.shadow_passes.size(); i++) { @@ -2062,7 +2063,7 @@ void RendererSceneRenderForward::_render_shadow_end(uint32_t p_barrier) { RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_render_particle_collider_heightfield(RID p_fb, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, const PagedArray<GeometryInstance *> &p_instances) { +void RendererSceneRenderForwardClustered::_render_particle_collider_heightfield(RID p_fb, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, const PagedArray<GeometryInstance *> &p_instances) { RENDER_TIMESTAMP("Setup Render Collider Heightfield"); RD::get_singleton()->draw_command_begin_label("Render Collider Heightfield"); @@ -2090,7 +2091,7 @@ void RendererSceneRenderForward::_render_particle_collider_heightfield(RID p_fb, RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_render_material(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) { +void RendererSceneRenderForwardClustered::_render_material(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) { RENDER_TIMESTAMP("Setup Rendering Material"); RD::get_singleton()->draw_command_begin_label("Render Material"); @@ -2128,7 +2129,7 @@ void RendererSceneRenderForward::_render_material(const Transform &p_cam_transfo RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_render_uv2(const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) { +void RendererSceneRenderForwardClustered::_render_uv2(const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) { RENDER_TIMESTAMP("Setup Rendering UV2"); RD::get_singleton()->draw_command_begin_label("Render UV2"); @@ -2190,7 +2191,7 @@ void RendererSceneRenderForward::_render_uv2(const PagedArray<GeometryInstance * RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_render_sdfgi(RID p_render_buffers, const Vector3i &p_from, const Vector3i &p_size, const AABB &p_bounds, const PagedArray<GeometryInstance *> &p_instances, const RID &p_albedo_texture, const RID &p_emission_texture, const RID &p_emission_aniso_texture, const RID &p_geom_facing_texture) { +void RendererSceneRenderForwardClustered::_render_sdfgi(RID p_render_buffers, const Vector3i &p_from, const Vector3i &p_size, const AABB &p_bounds, const PagedArray<GeometryInstance *> &p_instances, const RID &p_albedo_texture, const RID &p_emission_texture, const RID &p_emission_aniso_texture, const RID &p_geom_facing_texture) { RENDER_TIMESTAMP("Render SDFGI"); RD::get_singleton()->draw_command_begin_label("Render SDFGI Voxel"); @@ -2271,14 +2272,14 @@ void RendererSceneRenderForward::_render_sdfgi(RID p_render_buffers, const Vecto RD::get_singleton()->draw_command_end_label(); } -void RendererSceneRenderForward::_base_uniforms_changed() { +void RendererSceneRenderForwardClustered::_base_uniforms_changed() { if (!render_base_uniform_set.is_null() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) { RD::get_singleton()->free(render_base_uniform_set); } render_base_uniform_set = RID(); } -void RendererSceneRenderForward::_update_render_base_uniform_set() { +void RendererSceneRenderForwardClustered::_update_render_base_uniform_set() { if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != storage->lightmap_array_get_version())) { if (render_base_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) { RD::get_singleton()->free(render_base_uniform_set); @@ -2404,7 +2405,7 @@ void RendererSceneRenderForward::_update_render_base_uniform_set() { } } -RID RendererSceneRenderForward::_setup_render_pass_uniform_set(RenderListType p_render_list, RID p_render_buffers, RID p_radiance_texture, RID p_shadow_atlas, RID p_reflection_atlas, RID p_cluster_buffer, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_lightmaps, bool p_use_directional_shadow_atlas, int p_index) { +RID RendererSceneRenderForwardClustered::_setup_render_pass_uniform_set(RenderListType p_render_list, RID p_render_buffers, RID p_radiance_texture, RID p_shadow_atlas, RID p_reflection_atlas, RID p_cluster_buffer, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_lightmaps, bool p_use_directional_shadow_atlas, int p_index) { //there should always be enough uniform buffers for render passes, otherwise bugs ERR_FAIL_INDEX_V(p_index, (int)scene_state.uniform_buffers.size(), RID()); @@ -2514,7 +2515,7 @@ RID RendererSceneRenderForward::_setup_render_pass_uniform_set(RenderListType p_ RID default_tex = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); for (int i = 0; i < MAX_GI_PROBES; i++) { if (i < (int)p_gi_probes.size()) { - RID tex = gi_probe_instance_get_texture(p_gi_probes[i]); + RID tex = gi.gi_probe_instance_get_texture(p_gi_probes[i]); if (!tex.is_valid()) { tex = default_tex; } @@ -2654,7 +2655,7 @@ RID RendererSceneRenderForward::_setup_render_pass_uniform_set(RenderListType p_ return render_pass_uniform_sets[p_index]; } -RID RendererSceneRenderForward::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_texture, RID p_emission_texture, RID p_emission_aniso_texture, RID p_geom_facing_texture) { +RID RendererSceneRenderForwardClustered::_setup_sdfgi_render_pass_uniform_set(RID p_albedo_texture, RID p_emission_texture, RID p_emission_aniso_texture, RID p_geom_facing_texture) { if (sdfgi_pass_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sdfgi_pass_uniform_set)) { RD::get_singleton()->free(sdfgi_pass_uniform_set); } @@ -2787,30 +2788,25 @@ RID RendererSceneRenderForward::_setup_sdfgi_render_pass_uniform_set(RID p_albed return sdfgi_pass_uniform_set; } -void RendererSceneRenderForward::_render_buffers_clear_uniform_set(RenderBufferDataForward *rb) { +void RendererSceneRenderForwardClustered::_render_buffers_clear_uniform_set(RenderBufferDataForward *rb) { } -void RendererSceneRenderForward::_render_buffers_uniform_set_changed(RID p_render_buffers) { +void RendererSceneRenderForwardClustered::_render_buffers_uniform_set_changed(RID p_render_buffers) { RenderBufferDataForward *rb = (RenderBufferDataForward *)render_buffers_get_data(p_render_buffers); _render_buffers_clear_uniform_set(rb); } -RID RendererSceneRenderForward::_render_buffers_get_normal_texture(RID p_render_buffers) { +RID RendererSceneRenderForwardClustered::_render_buffers_get_normal_texture(RID p_render_buffers) { RenderBufferDataForward *rb = (RenderBufferDataForward *)render_buffers_get_data(p_render_buffers); return rb->normal_roughness_buffer; } -RendererSceneRenderForward *RendererSceneRenderForward::singleton = nullptr; +RendererSceneRenderForwardClustered *RendererSceneRenderForwardClustered::singleton = nullptr; -void RendererSceneRenderForward::set_time(double p_time, double p_step) { - time = p_time; - RendererSceneRenderRD::set_time(p_time, p_step); -} - -void RendererSceneRenderForward::_geometry_instance_mark_dirty(GeometryInstance *p_geometry_instance) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::_geometry_instance_mark_dirty(GeometryInstance *p_geometry_instance) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); if (ginstance->dirty_list_element.in_list()) { return; } @@ -2829,7 +2825,7 @@ void RendererSceneRenderForward::_geometry_instance_mark_dirty(GeometryInstance geometry_instance_dirty_list.add(&ginstance->dirty_list_element); } -void RendererSceneRenderForward::_geometry_instance_add_surface_with_material(GeometryInstanceForward *ginstance, uint32_t p_surface, MaterialData *p_material, uint32_t p_material_id, uint32_t p_shader_id, RID p_mesh) { +void RendererSceneRenderForwardClustered::_geometry_instance_add_surface_with_material(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, MaterialData *p_material, uint32_t p_material_id, uint32_t p_shader_id, RID p_mesh) { bool has_read_screen_alpha = p_material->shader_data->uses_screen_texture || p_material->shader_data->uses_depth_texture || p_material->shader_data->uses_normal_texture; bool has_base_alpha = (p_material->shader_data->uses_alpha || has_read_screen_alpha); bool has_blend_alpha = p_material->shader_data->uses_blend_alpha; @@ -2853,7 +2849,7 @@ void RendererSceneRenderForward::_geometry_instance_add_surface_with_material(Ge flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_NORMAL_TEXTURE; } - if (ginstance->data->cast_double_sided_shaodows) { + if (ginstance->data->cast_double_sided_shadows) { flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_DOUBLE_SIDED_SHADOWS; } @@ -2925,7 +2921,7 @@ void RendererSceneRenderForward::_geometry_instance_add_surface_with_material(Ge sdcache->sort.priority = p_material->priority; } -void RendererSceneRenderForward::_geometry_instance_add_surface(GeometryInstanceForward *ginstance, uint32_t p_surface, RID p_material, RID p_mesh) { +void RendererSceneRenderForwardClustered::_geometry_instance_add_surface(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, RID p_material, RID p_mesh) { RID m_src; m_src = ginstance->data->material_override.is_valid() ? ginstance->data->material_override : p_material; @@ -2965,8 +2961,8 @@ void RendererSceneRenderForward::_geometry_instance_add_surface(GeometryInstance } } -void RendererSceneRenderForward::_geometry_instance_update(GeometryInstance *p_geometry_instance) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geometry_instance) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); if (ginstance->data->dirty_dependencies) { ginstance->data->dependency_tracker.update_begin(); @@ -3123,24 +3119,24 @@ void RendererSceneRenderForward::_geometry_instance_update(GeometryInstance *p_g ginstance->dirty_list_element.remove_from_list(); } -void RendererSceneRenderForward::_update_dirty_geometry_instances() { +void RendererSceneRenderForwardClustered::_update_dirty_geometry_instances() { while (geometry_instance_dirty_list.first()) { _geometry_instance_update(geometry_instance_dirty_list.first()->self()); } } -void RendererSceneRenderForward::_geometry_instance_dependency_changed(RendererStorage::DependencyChangedNotification p_notification, RendererStorage::DependencyTracker *p_tracker) { +void RendererSceneRenderForwardClustered::_geometry_instance_dependency_changed(RendererStorage::DependencyChangedNotification p_notification, RendererStorage::DependencyTracker *p_tracker) { switch (p_notification) { case RendererStorage::DEPENDENCY_CHANGED_MATERIAL: case RendererStorage::DEPENDENCY_CHANGED_MESH: case RendererStorage::DEPENDENCY_CHANGED_MULTIMESH: case RendererStorage::DEPENDENCY_CHANGED_SKELETON_DATA: { - static_cast<RendererSceneRenderForward *>(singleton)->_geometry_instance_mark_dirty(static_cast<GeometryInstance *>(p_tracker->userdata)); + static_cast<RendererSceneRenderForwardClustered *>(singleton)->_geometry_instance_mark_dirty(static_cast<GeometryInstance *>(p_tracker->userdata)); } break; case RendererStorage::DEPENDENCY_CHANGED_MULTIMESH_VISIBLE_INSTANCES: { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_tracker->userdata); + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_tracker->userdata); if (ginstance->data->base_type == RS::INSTANCE_MULTIMESH) { - ginstance->instance_count = static_cast<RendererSceneRenderForward *>(singleton)->storage->multimesh_get_instances_to_draw(ginstance->data->base); + ginstance->instance_count = static_cast<RendererSceneRenderForwardClustered *>(singleton)->storage->multimesh_get_instances_to_draw(ginstance->data->base); } } break; default: { @@ -3148,16 +3144,16 @@ void RendererSceneRenderForward::_geometry_instance_dependency_changed(RendererS } break; } } -void RendererSceneRenderForward::_geometry_instance_dependency_deleted(const RID &p_dependency, RendererStorage::DependencyTracker *p_tracker) { - static_cast<RendererSceneRenderForward *>(singleton)->_geometry_instance_mark_dirty(static_cast<GeometryInstance *>(p_tracker->userdata)); +void RendererSceneRenderForwardClustered::_geometry_instance_dependency_deleted(const RID &p_dependency, RendererStorage::DependencyTracker *p_tracker) { + static_cast<RendererSceneRenderForwardClustered *>(singleton)->_geometry_instance_mark_dirty(static_cast<GeometryInstance *>(p_tracker->userdata)); } -RendererSceneRender::GeometryInstance *RendererSceneRenderForward::geometry_instance_create(RID p_base) { +RendererSceneRender::GeometryInstance *RendererSceneRenderForwardClustered::geometry_instance_create(RID p_base) { RS::InstanceType type = storage->get_base_type(p_base); ERR_FAIL_COND_V(!((1 << type) & RS::INSTANCE_GEOMETRY_MASK), nullptr); - GeometryInstanceForward *ginstance = geometry_instance_alloc.alloc(); - ginstance->data = memnew(GeometryInstanceForward::Data); + GeometryInstanceForwardClustered *ginstance = geometry_instance_alloc.alloc(); + ginstance->data = memnew(GeometryInstanceForwardClustered::Data); ginstance->data->base = p_base; ginstance->data->base_type = type; @@ -3169,35 +3165,35 @@ RendererSceneRender::GeometryInstance *RendererSceneRenderForward::geometry_inst return ginstance; } -void RendererSceneRenderForward::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->data->skeleton = p_skeleton; _geometry_instance_mark_dirty(ginstance); ginstance->data->dirty_dependencies = true; } -void RendererSceneRenderForward::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->data->material_override = p_override; _geometry_instance_mark_dirty(ginstance); ginstance->data->dirty_dependencies = true; } -void RendererSceneRenderForward::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector<RID> &p_materials) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector<RID> &p_materials) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->data->surface_materials = p_materials; _geometry_instance_mark_dirty(ginstance); ginstance->data->dirty_dependencies = true; } -void RendererSceneRenderForward::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->mesh_instance = p_mesh_instance; _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabb) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabb) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->transform = p_transform; ginstance->mirror = p_transform.basis.determinant() < 0; @@ -3213,33 +3209,33 @@ void RendererSceneRenderForward::geometry_instance_set_transform(GeometryInstanc ginstance->lod_model_scale = max_scale; } -void RendererSceneRenderForward::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->lod_bias = p_lod_bias; } -void RendererSceneRenderForward::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->data->use_baked_light = p_enable; _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->data->use_dynamic_gi = p_enable; _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->lightmap_instance = p_lightmap_instance; ginstance->lightmap_uv_scale = p_lightmap_uv_scale; ginstance->lightmap_slice_index = p_lightmap_slice_index; _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); if (p_sh9) { if (ginstance->lightmap_sh == nullptr) { @@ -3255,28 +3251,28 @@ void RendererSceneRenderForward::geometry_instance_set_lightmap_capture(Geometry } _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->shader_parameters_offset = p_offset; _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); - ginstance->data->cast_double_sided_shaodows = p_enable; + ginstance->data->cast_double_sided_shadows = p_enable; _geometry_instance_mark_dirty(ginstance); } -void RendererSceneRenderForward::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); ginstance->layer_mask = p_layer_mask; } -void RendererSceneRenderForward::geometry_instance_free(GeometryInstance *p_geometry_instance) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_free(GeometryInstance *p_geometry_instance) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); if (ginstance->lightmap_sh != nullptr) { geometry_instance_lightmap_sh.free(ginstance->lightmap_sh); @@ -3291,29 +3287,29 @@ void RendererSceneRenderForward::geometry_instance_free(GeometryInstance *p_geom geometry_instance_alloc.free(ginstance); } -uint32_t RendererSceneRenderForward::geometry_instance_get_pair_mask() { +uint32_t RendererSceneRenderForwardClustered::geometry_instance_get_pair_mask() { return (1 << RS::INSTANCE_GI_PROBE); } -void RendererSceneRenderForward::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) { +void RendererSceneRenderForwardClustered::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) { } -void RendererSceneRenderForward::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) { +void RendererSceneRenderForwardClustered::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) { } -void RendererSceneRenderForward::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) { +void RendererSceneRenderForwardClustered::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) { } -Transform RendererSceneRenderForward::geometry_instance_get_transform(GeometryInstance *p_instance) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_instance); +Transform RendererSceneRenderForwardClustered::geometry_instance_get_transform(GeometryInstance *p_instance) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_instance); ERR_FAIL_COND_V(!ginstance, Transform()); return ginstance->transform; } -AABB RendererSceneRenderForward::geometry_instance_get_aabb(GeometryInstance *p_instance) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_instance); +AABB RendererSceneRenderForwardClustered::geometry_instance_get_aabb(GeometryInstance *p_instance) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_instance); ERR_FAIL_COND_V(!ginstance, AABB()); return ginstance->data->aabb; } -void RendererSceneRenderForward::geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count) { - GeometryInstanceForward *ginstance = static_cast<GeometryInstanceForward *>(p_geometry_instance); +void RendererSceneRenderForwardClustered::geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); ERR_FAIL_COND(!ginstance); if (p_gi_probe_instance_count > 0) { ginstance->gi_probes[0] = p_gi_probe_instances[0]; @@ -3328,11 +3324,10 @@ void RendererSceneRenderForward::geometry_instance_pair_gi_probe_instances(Geome } } -RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_storage) : +RendererSceneRenderForwardClustered::RendererSceneRenderForwardClustered(RendererStorageRD *p_storage) : RendererSceneRenderRD(p_storage) { singleton = this; low_end = is_low_end(); - storage = p_storage; /* SCENE SHADER */ @@ -3346,7 +3341,7 @@ RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_stor if (is_using_radiance_cubemap_array()) { defines += "\n#define USE_RADIANCE_CUBEMAP_ARRAY \n"; } - defines += "\n#define SDFGI_OCT_SIZE " + itos(sdfgi_get_lightprobe_octahedron_size()) + "\n"; + defines += "\n#define SDFGI_OCT_SIZE " + itos(gi.sdfgi_get_lightprobe_octahedron_size()) + "\n"; defines += "\n#define MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS " + itos(get_max_directional_lights()) + "\n"; { @@ -3627,7 +3622,7 @@ RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_stor render_list_thread_threshold = GLOBAL_GET("rendering/limits/forward_renderer/threaded_render_minimum_instances"); } -RendererSceneRenderForward::~RendererSceneRenderForward() { +RendererSceneRenderForwardClustered::~RendererSceneRenderForwardClustered() { directional_shadow_atlas_set_size(0); //clear base uniform set if still valid diff --git a/servers/rendering/renderer_rd/renderer_scene_render_forward.h b/servers/rendering/renderer_rd/renderer_scene_render_forward_clustered.h index af78c50fda..98e2a7efcc 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_forward.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_forward_clustered.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* renderer_scene_render_forward.h */ +/* renderer_scene_render_forward_clustered.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,16 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RENDERING_SERVER_SCENE_RENDER_FORWARD_H -#define RENDERING_SERVER_SCENE_RENDER_FORWARD_H +#ifndef RENDERING_SERVER_SCENE_RENDER_FORWARD_CLUSTERED_H +#define RENDERING_SERVER_SCENE_RENDER_FORWARD_CLUSTERED_H #include "core/templates/paged_allocator.h" #include "servers/rendering/renderer_rd/pipeline_cache_rd.h" #include "servers/rendering/renderer_rd/renderer_scene_render_rd.h" #include "servers/rendering/renderer_rd/renderer_storage_rd.h" -#include "servers/rendering/renderer_rd/shaders/scene_forward.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl.gen.h" -class RendererSceneRenderForward : public RendererSceneRenderRD { +class RendererSceneRenderForwardClustered : public RendererSceneRenderRD { enum { SCENE_UNIFORM_SET = 0, RENDER_PASS_UNIFORM_SET = 1, @@ -79,12 +79,10 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { }; struct { - SceneForwardShaderRD scene_shader; + SceneForwardClusteredShaderRD scene_shader; ShaderCompilerRD compiler; } shader; - RendererStorageRD *storage; - /* Material */ struct ShaderData : public RendererStorageRD::ShaderData { @@ -186,7 +184,7 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { RendererStorageRD::ShaderData *_create_shader_func(); static RendererStorageRD::ShaderData *_create_shader_funcs() { - return static_cast<RendererSceneRenderForward *>(singleton)->_create_shader_func(); + return static_cast<RendererSceneRenderForwardClustered *>(singleton)->_create_shader_func(); } struct MaterialData : public RendererStorageRD::MaterialData { @@ -208,7 +206,7 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { RendererStorageRD::MaterialData *_create_material_func(ShaderData *p_shader); static RendererStorageRD::MaterialData *_create_material_funcs(RendererStorageRD::ShaderData *p_shader) { - return static_cast<RendererSceneRenderForward *>(singleton)->_create_material_func(static_cast<ShaderData *>(p_shader)); + return static_cast<RendererSceneRenderForwardClustered *>(singleton)->_create_material_func(static_cast<ShaderData *>(p_shader)); } /* Framebuffer */ @@ -490,9 +488,8 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { } scene_state; - static RendererSceneRenderForward *singleton; + static RendererSceneRenderForwardClustered *singleton; - double time; RID default_shader; RID default_material; RID overdraw_material_shader; @@ -534,7 +531,7 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { Map<Size2i, RID> sdfgi_framebuffer_size_cache; struct GeometryInstanceData; - struct GeometryInstanceForward; + struct GeometryInstanceForwardClustered; struct GeometryInstanceLightmapSH { Color sh[9]; @@ -588,10 +585,10 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { ShaderData *shader_shadow = nullptr; GeometryInstanceSurfaceDataCache *next = nullptr; - GeometryInstanceForward *owner = nullptr; + GeometryInstanceForwardClustered *owner = nullptr; }; - struct GeometryInstanceForward : public GeometryInstance { + struct GeometryInstanceForwardClustered : public GeometryInstance { //used during rendering bool mirror = false; bool non_uniform_scale = false; @@ -617,7 +614,7 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { RID lightmap_instance; GeometryInstanceLightmapSH *lightmap_sh = nullptr; GeometryInstanceSurfaceDataCache *surface_caches = nullptr; - SelfList<GeometryInstanceForward> dirty_list_element; + SelfList<GeometryInstanceForwardClustered> dirty_list_element; struct Data { //data used less often goes into regular heap @@ -631,7 +628,7 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { bool use_dynamic_gi = false; bool use_baked_light = false; - bool cast_double_sided_shaodows = false; + bool cast_double_sided_shadows = false; bool mirror = false; bool dirty_dependencies = false; @@ -640,21 +637,21 @@ class RendererSceneRenderForward : public RendererSceneRenderRD { Data *data = nullptr; - GeometryInstanceForward() : + GeometryInstanceForwardClustered() : dirty_list_element(this) {} }; static void _geometry_instance_dependency_changed(RendererStorage::DependencyChangedNotification p_notification, RendererStorage::DependencyTracker *p_tracker); static void _geometry_instance_dependency_deleted(const RID &p_dependency, RendererStorage::DependencyTracker *p_tracker); - SelfList<GeometryInstanceForward>::List geometry_instance_dirty_list; + SelfList<GeometryInstanceForwardClustered>::List geometry_instance_dirty_list; - PagedAllocator<GeometryInstanceForward> geometry_instance_alloc; + PagedAllocator<GeometryInstanceForwardClustered> geometry_instance_alloc; PagedAllocator<GeometryInstanceSurfaceDataCache> geometry_instance_surface_alloc; PagedAllocator<GeometryInstanceLightmapSH> geometry_instance_lightmap_sh; - void _geometry_instance_add_surface_with_material(GeometryInstanceForward *ginstance, uint32_t p_surface, MaterialData *p_material, uint32_t p_material_id, uint32_t p_shader_id, RID p_mesh); - void _geometry_instance_add_surface(GeometryInstanceForward *ginstance, uint32_t p_surface, RID p_material, RID p_mesh); + void _geometry_instance_add_surface_with_material(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, MaterialData *p_material, uint32_t p_material_id, uint32_t p_shader_id, RID p_mesh); + void _geometry_instance_add_surface(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, RID p_material, RID p_mesh); void _geometry_instance_mark_dirty(GeometryInstance *p_geometry_instance); void _geometry_instance_update(GeometryInstance *p_geometry_instance); void _update_dirty_geometry_instances(); @@ -761,11 +758,9 @@ public: virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count); virtual void geometry_instance_pair_gi_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_gi_probe_instances, uint32_t p_gi_probe_instance_count); - virtual void set_time(double p_time, double p_step); - virtual bool free(RID p_rid); - RendererSceneRenderForward(RendererStorageRD *p_storage); - ~RendererSceneRenderForward(); + RendererSceneRenderForwardClustered(RendererStorageRD *p_storage); + ~RendererSceneRenderForwardClustered(); }; -#endif // RASTERIZER_SCENE_HIGHEND_RD_H +#endif // !RENDERING_SERVER_SCENE_RENDER_FORWARD_CLUSTERED_H diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 15e963f6e4..4cf296f0db 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -35,8 +35,6 @@ #include "renderer_compositor_rd.h" #include "servers/rendering/rendering_server_default.h" -uint64_t RendererSceneRenderRD::auto_exposure_counter = 2; - void get_vogel_disk(float *r_kernel, int p_sample_count) { const float golden_angle = 2.4; @@ -49,980 +47,42 @@ void get_vogel_disk(float *r_kernel, int p_sample_count) { } } -void RendererSceneRenderRD::_clear_reflection_data(ReflectionData &rd) { - rd.layers.clear(); - rd.radiance_base_cubemap = RID(); - if (rd.downsampled_radiance_cubemap.is_valid()) { - RD::get_singleton()->free(rd.downsampled_radiance_cubemap); - } - rd.downsampled_radiance_cubemap = RID(); - rd.downsampled_layer.mipmaps.clear(); - rd.coefficient_buffer = RID(); -} - -void RendererSceneRenderRD::_update_reflection_data(ReflectionData &rd, int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality) { - //recreate radiance and all data - - int mipmaps = p_mipmaps; - uint32_t w = p_size, h = p_size; - - if (p_use_array) { - int layers = p_low_quality ? 8 : roughness_layers; - - for (int i = 0; i < layers; i++) { - ReflectionData::Layer layer; - uint32_t mmw = w; - uint32_t mmh = h; - layer.mipmaps.resize(mipmaps); - layer.views.resize(mipmaps); - for (int j = 0; j < mipmaps; j++) { - ReflectionData::Layer::Mipmap &mm = layer.mipmaps.write[j]; - mm.size.width = mmw; - mm.size.height = mmh; - for (int k = 0; k < 6; k++) { - mm.views[k] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + i * 6 + k, j); - Vector<RID> fbtex; - fbtex.push_back(mm.views[k]); - mm.framebuffers[k] = RD::get_singleton()->framebuffer_create(fbtex); - } - - layer.views.write[j] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + i * 6, j, RD::TEXTURE_SLICE_CUBEMAP); - - mmw = MAX(1, mmw >> 1); - mmh = MAX(1, mmh >> 1); - } - - rd.layers.push_back(layer); - } - - } else { - mipmaps = p_low_quality ? 8 : mipmaps; - //regular cubemap, lower quality (aliasing, less memory) - ReflectionData::Layer layer; - uint32_t mmw = w; - uint32_t mmh = h; - layer.mipmaps.resize(mipmaps); - layer.views.resize(mipmaps); - for (int j = 0; j < mipmaps; j++) { - ReflectionData::Layer::Mipmap &mm = layer.mipmaps.write[j]; - mm.size.width = mmw; - mm.size.height = mmh; - for (int k = 0; k < 6; k++) { - mm.views[k] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + k, j); - Vector<RID> fbtex; - fbtex.push_back(mm.views[k]); - mm.framebuffers[k] = RD::get_singleton()->framebuffer_create(fbtex); - } - - layer.views.write[j] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer, j, RD::TEXTURE_SLICE_CUBEMAP); - - mmw = MAX(1, mmw >> 1); - mmh = MAX(1, mmh >> 1); - } - - rd.layers.push_back(layer); - } - - rd.radiance_base_cubemap = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer, 0, RD::TEXTURE_SLICE_CUBEMAP); - - RD::TextureFormat tf; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf.width = 64; // Always 64x64 - tf.height = 64; - tf.texture_type = RD::TEXTURE_TYPE_CUBE; - tf.array_layers = 6; - tf.mipmaps = 7; - tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - - rd.downsampled_radiance_cubemap = RD::get_singleton()->texture_create(tf, RD::TextureView()); - { - uint32_t mmw = 64; - uint32_t mmh = 64; - rd.downsampled_layer.mipmaps.resize(7); - for (int j = 0; j < rd.downsampled_layer.mipmaps.size(); j++) { - ReflectionData::DownsampleLayer::Mipmap &mm = rd.downsampled_layer.mipmaps.write[j]; - mm.size.width = mmw; - mm.size.height = mmh; - mm.view = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), rd.downsampled_radiance_cubemap, 0, j, RD::TEXTURE_SLICE_CUBEMAP); - - mmw = MAX(1, mmw >> 1); - mmh = MAX(1, mmh >> 1); - } - } -} - -void RendererSceneRenderRD::_create_reflection_fast_filter(ReflectionData &rd, bool p_use_arrays) { - storage->get_effects()->cubemap_downsample(rd.radiance_base_cubemap, rd.downsampled_layer.mipmaps[0].view, rd.downsampled_layer.mipmaps[0].size); - - for (int i = 1; i < rd.downsampled_layer.mipmaps.size(); i++) { - storage->get_effects()->cubemap_downsample(rd.downsampled_layer.mipmaps[i - 1].view, rd.downsampled_layer.mipmaps[i].view, rd.downsampled_layer.mipmaps[i].size); - } - - Vector<RID> views; - if (p_use_arrays) { - for (int i = 1; i < rd.layers.size(); i++) { - views.push_back(rd.layers[i].views[0]); - } - } else { - for (int i = 1; i < rd.layers[0].views.size(); i++) { - views.push_back(rd.layers[0].views[i]); - } - } - - storage->get_effects()->cubemap_filter(rd.downsampled_radiance_cubemap, views, p_use_arrays); -} - -void RendererSceneRenderRD::_create_reflection_importance_sample(ReflectionData &rd, bool p_use_arrays, int p_cube_side, int p_base_layer) { - if (p_use_arrays) { - //render directly to the layers - storage->get_effects()->cubemap_roughness(rd.radiance_base_cubemap, rd.layers[p_base_layer].views[0], p_cube_side, sky_ggx_samples_quality, float(p_base_layer) / (rd.layers.size() - 1.0), rd.layers[p_base_layer].mipmaps[0].size.x); - } else { - storage->get_effects()->cubemap_roughness(rd.layers[0].views[p_base_layer - 1], rd.layers[0].views[p_base_layer], p_cube_side, sky_ggx_samples_quality, float(p_base_layer) / (rd.layers[0].mipmaps.size() - 1.0), rd.layers[0].mipmaps[p_base_layer].size.x); - } -} - -void RendererSceneRenderRD::_update_reflection_mipmaps(ReflectionData &rd, int p_start, int p_end) { - for (int i = p_start; i < p_end; i++) { - for (int j = 0; j < rd.layers[i].views.size() - 1; j++) { - RID view = rd.layers[i].views[j]; - RID texture = rd.layers[i].views[j + 1]; - Size2i size = rd.layers[i].mipmaps[j + 1].size; - storage->get_effects()->cubemap_downsample(view, texture, size); - } - } -} - -void RendererSceneRenderRD::_sdfgi_erase(RenderBuffers *rb) { - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - const SDFGI::Cascade &c = rb->sdfgi->cascades[i]; - RD::get_singleton()->free(c.light_data); - RD::get_singleton()->free(c.light_aniso_0_tex); - RD::get_singleton()->free(c.light_aniso_1_tex); - RD::get_singleton()->free(c.sdf_tex); - RD::get_singleton()->free(c.solid_cell_dispatch_buffer); - RD::get_singleton()->free(c.solid_cell_buffer); - RD::get_singleton()->free(c.lightprobe_history_tex); - RD::get_singleton()->free(c.lightprobe_average_tex); - RD::get_singleton()->free(c.lights_buffer); - } - - RD::get_singleton()->free(rb->sdfgi->render_albedo); - RD::get_singleton()->free(rb->sdfgi->render_emission); - RD::get_singleton()->free(rb->sdfgi->render_emission_aniso); - - RD::get_singleton()->free(rb->sdfgi->render_sdf[0]); - RD::get_singleton()->free(rb->sdfgi->render_sdf[1]); - - RD::get_singleton()->free(rb->sdfgi->render_sdf_half[0]); - RD::get_singleton()->free(rb->sdfgi->render_sdf_half[1]); - - for (int i = 0; i < 8; i++) { - RD::get_singleton()->free(rb->sdfgi->render_occlusion[i]); - } - - RD::get_singleton()->free(rb->sdfgi->render_geom_facing); - - RD::get_singleton()->free(rb->sdfgi->lightprobe_data); - RD::get_singleton()->free(rb->sdfgi->lightprobe_history_scroll); - RD::get_singleton()->free(rb->sdfgi->occlusion_data); - RD::get_singleton()->free(rb->sdfgi->ambient_texture); - - RD::get_singleton()->free(rb->sdfgi->cascades_ubo); - - memdelete(rb->sdfgi); - - rb->sdfgi = nullptr; -} - -const Vector3i RendererSceneRenderRD::SDFGI::Cascade::DIRTY_ALL = Vector3i(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF); - void RendererSceneRenderRD::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) { - Environment *env = environment_owner.getornull(p_environment); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment); RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); bool needs_sdfgi = env && env->sdfgi_enabled; if (!needs_sdfgi) { if (rb->sdfgi != nullptr) { //erase it - _sdfgi_erase(rb); + rb->sdfgi->erase(); + memdelete(rb->sdfgi); + rb->sdfgi = nullptr; + _render_buffers_uniform_set_changed(p_render_buffers); } return; } static const uint32_t history_frames_to_converge[RS::ENV_SDFGI_CONVERGE_MAX] = { 5, 10, 15, 20, 25, 30 }; - uint32_t requested_history_size = history_frames_to_converge[sdfgi_frames_to_converge]; + uint32_t requested_history_size = history_frames_to_converge[gi.sdfgi_frames_to_converge]; if (rb->sdfgi && (rb->sdfgi->cascade_mode != env->sdfgi_cascades || rb->sdfgi->min_cell_size != env->sdfgi_min_cell_size || requested_history_size != rb->sdfgi->history_size || rb->sdfgi->uses_occlusion != env->sdfgi_use_occlusion || rb->sdfgi->y_scale_mode != env->sdfgi_y_scale)) { //configuration changed, erase - _sdfgi_erase(rb); + rb->sdfgi->erase(); + memdelete(rb->sdfgi); + rb->sdfgi = nullptr; } - SDFGI *sdfgi = rb->sdfgi; + RendererSceneGIRD::SDFGI *sdfgi = rb->sdfgi; if (sdfgi == nullptr) { - //re-create - rb->sdfgi = memnew(SDFGI); - sdfgi = rb->sdfgi; - sdfgi->cascade_mode = env->sdfgi_cascades; - sdfgi->min_cell_size = env->sdfgi_min_cell_size; - sdfgi->uses_occlusion = env->sdfgi_use_occlusion; - sdfgi->y_scale_mode = env->sdfgi_y_scale; - static const float y_scale[3] = { 1.0, 1.5, 2.0 }; - sdfgi->y_mult = y_scale[sdfgi->y_scale_mode]; - static const int cascasde_size[3] = { 4, 6, 8 }; - sdfgi->cascades.resize(cascasde_size[sdfgi->cascade_mode]); - sdfgi->probe_axis_count = SDFGI::PROBE_DIVISOR + 1; - sdfgi->solid_cell_ratio = sdfgi_solid_cell_ratio; - sdfgi->solid_cell_count = uint32_t(float(sdfgi->cascade_size * sdfgi->cascade_size * sdfgi->cascade_size) * sdfgi->solid_cell_ratio); - - float base_cell_size = sdfgi->min_cell_size; - - RD::TextureFormat tf_sdf; - tf_sdf.format = RD::DATA_FORMAT_R8_UNORM; - tf_sdf.width = sdfgi->cascade_size; // Always 64x64 - tf_sdf.height = sdfgi->cascade_size; - tf_sdf.depth = sdfgi->cascade_size; - tf_sdf.texture_type = RD::TEXTURE_TYPE_3D; - tf_sdf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; - - { - RD::TextureFormat tf_render = tf_sdf; - tf_render.format = RD::DATA_FORMAT_R16_UINT; - sdfgi->render_albedo = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - tf_render.format = RD::DATA_FORMAT_R32_UINT; - sdfgi->render_emission = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - sdfgi->render_emission_aniso = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - - tf_render.format = RD::DATA_FORMAT_R8_UNORM; //at least its easy to visualize - - for (int i = 0; i < 8; i++) { - sdfgi->render_occlusion[i] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - } - - tf_render.format = RD::DATA_FORMAT_R32_UINT; - sdfgi->render_geom_facing = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - - tf_render.format = RD::DATA_FORMAT_R8G8B8A8_UINT; - sdfgi->render_sdf[0] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - sdfgi->render_sdf[1] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - - tf_render.width /= 2; - tf_render.height /= 2; - tf_render.depth /= 2; - - sdfgi->render_sdf_half[0] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - sdfgi->render_sdf_half[1] = RD::get_singleton()->texture_create(tf_render, RD::TextureView()); - } - - RD::TextureFormat tf_occlusion = tf_sdf; - tf_occlusion.format = RD::DATA_FORMAT_R16_UINT; - tf_occlusion.shareable_formats.push_back(RD::DATA_FORMAT_R16_UINT); - tf_occlusion.shareable_formats.push_back(RD::DATA_FORMAT_R4G4B4A4_UNORM_PACK16); - tf_occlusion.depth *= sdfgi->cascades.size(); //use depth for occlusion slices - tf_occlusion.width *= 2; //use width for the other half - - RD::TextureFormat tf_light = tf_sdf; - tf_light.format = RD::DATA_FORMAT_R32_UINT; - tf_light.shareable_formats.push_back(RD::DATA_FORMAT_R32_UINT); - tf_light.shareable_formats.push_back(RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32); - - RD::TextureFormat tf_aniso0 = tf_sdf; - tf_aniso0.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; - RD::TextureFormat tf_aniso1 = tf_sdf; - tf_aniso1.format = RD::DATA_FORMAT_R8G8_UNORM; - - int passes = nearest_shift(sdfgi->cascade_size) - 1; - - //store lightprobe SH - RD::TextureFormat tf_probes; - tf_probes.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf_probes.width = sdfgi->probe_axis_count * sdfgi->probe_axis_count; - tf_probes.height = sdfgi->probe_axis_count * SDFGI::SH_SIZE; - tf_probes.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; - tf_probes.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; - - sdfgi->history_size = requested_history_size; - - RD::TextureFormat tf_probe_history = tf_probes; - tf_probe_history.format = RD::DATA_FORMAT_R16G16B16A16_SINT; //signed integer because SH are signed - tf_probe_history.array_layers = sdfgi->history_size; - - RD::TextureFormat tf_probe_average = tf_probes; - tf_probe_average.format = RD::DATA_FORMAT_R32G32B32A32_SINT; //signed integer because SH are signed - tf_probe_average.texture_type = RD::TEXTURE_TYPE_2D; - - sdfgi->lightprobe_history_scroll = RD::get_singleton()->texture_create(tf_probe_history, RD::TextureView()); - sdfgi->lightprobe_average_scroll = RD::get_singleton()->texture_create(tf_probe_average, RD::TextureView()); - - { - //octahedral lightprobes - RD::TextureFormat tf_octprobes = tf_probes; - tf_octprobes.array_layers = sdfgi->cascades.size() * 2; - tf_octprobes.format = RD::DATA_FORMAT_R32_UINT; //pack well with RGBE - tf_octprobes.width = sdfgi->probe_axis_count * sdfgi->probe_axis_count * (SDFGI::LIGHTPROBE_OCT_SIZE + 2); - tf_octprobes.height = sdfgi->probe_axis_count * (SDFGI::LIGHTPROBE_OCT_SIZE + 2); - tf_octprobes.shareable_formats.push_back(RD::DATA_FORMAT_R32_UINT); - tf_octprobes.shareable_formats.push_back(RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32); - //lightprobe texture is an octahedral texture - - sdfgi->lightprobe_data = RD::get_singleton()->texture_create(tf_octprobes, RD::TextureView()); - RD::TextureView tv; - tv.format_override = RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32; - sdfgi->lightprobe_texture = RD::get_singleton()->texture_create_shared(tv, sdfgi->lightprobe_data); - - //texture handling ambient data, to integrate with volumetric foc - RD::TextureFormat tf_ambient = tf_probes; - tf_ambient.array_layers = sdfgi->cascades.size(); - tf_ambient.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; //pack well with RGBE - tf_ambient.width = sdfgi->probe_axis_count * sdfgi->probe_axis_count; - tf_ambient.height = sdfgi->probe_axis_count; - tf_ambient.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; - //lightprobe texture is an octahedral texture - sdfgi->ambient_texture = RD::get_singleton()->texture_create(tf_ambient, RD::TextureView()); - } - - sdfgi->cascades_ubo = RD::get_singleton()->uniform_buffer_create(sizeof(SDFGI::Cascade::UBO) * SDFGI::MAX_CASCADES); - - sdfgi->occlusion_data = RD::get_singleton()->texture_create(tf_occlusion, RD::TextureView()); - { - RD::TextureView tv; - tv.format_override = RD::DATA_FORMAT_R4G4B4A4_UNORM_PACK16; - sdfgi->occlusion_texture = RD::get_singleton()->texture_create_shared(tv, sdfgi->occlusion_data); - } - - for (uint32_t i = 0; i < sdfgi->cascades.size(); i++) { - SDFGI::Cascade &cascade = sdfgi->cascades[i]; - - /* 3D Textures */ - - cascade.sdf_tex = RD::get_singleton()->texture_create(tf_sdf, RD::TextureView()); - - cascade.light_data = RD::get_singleton()->texture_create(tf_light, RD::TextureView()); - - cascade.light_aniso_0_tex = RD::get_singleton()->texture_create(tf_aniso0, RD::TextureView()); - cascade.light_aniso_1_tex = RD::get_singleton()->texture_create(tf_aniso1, RD::TextureView()); - - { - RD::TextureView tv; - tv.format_override = RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32; - cascade.light_tex = RD::get_singleton()->texture_create_shared(tv, cascade.light_data); - - RD::get_singleton()->texture_clear(cascade.light_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(cascade.light_aniso_0_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(cascade.light_aniso_1_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); - } - - cascade.cell_size = base_cell_size; - Vector3 world_position = p_world_position; - world_position.y *= sdfgi->y_mult; - int32_t probe_cells = sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; - Vector3 probe_size = Vector3(1, 1, 1) * cascade.cell_size * probe_cells; - Vector3i probe_pos = Vector3i((world_position / probe_size + Vector3(0.5, 0.5, 0.5)).floor()); - cascade.position = probe_pos * probe_cells; - - cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL; - - base_cell_size *= 2.0; - - /* Probe History */ - - cascade.lightprobe_history_tex = RD::get_singleton()->texture_create(tf_probe_history, RD::TextureView()); - RD::get_singleton()->texture_clear(cascade.lightprobe_history_tex, Color(0, 0, 0, 0), 0, 1, 0, tf_probe_history.array_layers); //needs to be cleared for average to work - - cascade.lightprobe_average_tex = RD::get_singleton()->texture_create(tf_probe_average, RD::TextureView()); - RD::get_singleton()->texture_clear(cascade.lightprobe_average_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); //needs to be cleared for average to work - - /* Buffers */ - - cascade.solid_cell_buffer = RD::get_singleton()->storage_buffer_create(sizeof(SDFGI::Cascade::SolidCell) * sdfgi->solid_cell_count); - cascade.solid_cell_dispatch_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * 4, Vector<uint8_t>(), RD::STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT); - cascade.lights_buffer = RD::get_singleton()->storage_buffer_create(sizeof(SDGIShader::Light) * MAX(SDFGI::MAX_STATIC_LIGHTS, SDFGI::MAX_DYNAMIC_LIGHTS)); - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_sdf[(passes & 1) ? 1 : 0]); //if passes are even, we read from buffer 0, else we read from buffer 1 - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 3; - for (int j = 0; j < 8; j++) { - u.ids.push_back(sdfgi->render_occlusion[j]); - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 4; - u.ids.push_back(sdfgi->render_emission); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 5; - u.ids.push_back(sdfgi->render_emission_aniso); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 6; - u.ids.push_back(sdfgi->render_geom_facing); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 7; - u.ids.push_back(cascade.sdf_tex); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 8; - u.ids.push_back(sdfgi->occlusion_data); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 10; - u.ids.push_back(cascade.solid_cell_dispatch_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 11; - u.ids.push_back(cascade.solid_cell_buffer); - uniforms.push_back(u); - } - - cascade.sdf_store_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_STORE), 0); - } - - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_geom_facing); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 3; - u.ids.push_back(sdfgi->render_emission); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 4; - u.ids.push_back(sdfgi->render_emission_aniso); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 5; - u.ids.push_back(cascade.solid_cell_dispatch_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 6; - u.ids.push_back(cascade.solid_cell_buffer); - uniforms.push_back(u); - } - - cascade.scroll_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_SCROLL), 0); - } - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - for (int j = 0; j < 8; j++) { - u.ids.push_back(sdfgi->render_occlusion[j]); - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->occlusion_data); - uniforms.push_back(u); - } - - cascade.scroll_occlusion_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_SCROLL_OCCLUSION), 0); - } - } - - //direct light - for (uint32_t i = 0; i < sdfgi->cascades.size(); i++) { - SDFGI::Cascade &cascade = sdfgi->cascades[i]; - - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.binding = 1; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (j < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[j].sdf_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 2; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 3; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.ids.push_back(cascade.solid_cell_dispatch_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 4; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.ids.push_back(cascade.solid_cell_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 5; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.ids.push_back(cascade.light_data); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 6; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.ids.push_back(cascade.light_aniso_0_tex); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 7; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.ids.push_back(cascade.light_aniso_1_tex); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 8; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.ids.push_back(rb->sdfgi->cascades_ubo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 9; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.ids.push_back(cascade.lights_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 10; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.ids.push_back(rb->sdfgi->lightprobe_texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 11; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.ids.push_back(rb->sdfgi->occlusion_texture); - uniforms.push_back(u); - } - - cascade.sdf_direct_light_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.direct_light.version_get_shader(sdfgi_shader.direct_light_shader, 0), 0); - } - - //preprocess initialize uniform set - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_sdf[0]); - uniforms.push_back(u); - } - - sdfgi->sdf_initialize_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE), 0); - } - - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_sdf_half[0]); - uniforms.push_back(u); - } - - sdfgi->sdf_initialize_half_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE_HALF), 0); - } - - //jump flood uniform set - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_sdf[0]); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_sdf[1]); - uniforms.push_back(u); - } - - sdfgi->jump_flood_uniform_set[0] = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD), 0); - SWAP(uniforms.write[0].ids.write[0], uniforms.write[1].ids.write[0]); - sdfgi->jump_flood_uniform_set[1] = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD), 0); - } - //jump flood half uniform set - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_sdf_half[0]); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_sdf_half[1]); - uniforms.push_back(u); - } - - sdfgi->jump_flood_half_uniform_set[0] = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD), 0); - SWAP(uniforms.write[0].ids.write[0], uniforms.write[1].ids.write[0]); - sdfgi->jump_flood_half_uniform_set[1] = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD), 0); - } - - //upscale half size sdf - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - u.ids.push_back(sdfgi->render_sdf_half[(passes & 1) ? 0 : 1]); //reverse pass order because half size - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 3; - u.ids.push_back(sdfgi->render_sdf[(passes & 1) ? 0 : 1]); //reverse pass order because it needs an extra JFA pass - uniforms.push_back(u); - } - - sdfgi->upscale_jfa_uniform_set_index = (passes & 1) ? 0 : 1; - sdfgi->sdf_upscale_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_JUMP_FLOOD_UPSCALE), 0); - } - - //occlusion uniform set - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 1; - u.ids.push_back(sdfgi->render_albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 2; - for (int i = 0; i < 8; i++) { - u.ids.push_back(sdfgi->render_occlusion[i]); - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 3; - u.ids.push_back(sdfgi->render_geom_facing); - uniforms.push_back(u); - } - - sdfgi->occlusion_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, SDGIShader::PRE_PROCESS_OCCLUSION), 0); - } - - for (uint32_t i = 0; i < sdfgi->cascades.size(); i++) { - //integrate uniform - - Vector<RD::Uniform> uniforms; - - { - RD::Uniform u; - u.binding = 1; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (j < sdfgi->cascades.size()) { - u.ids.push_back(sdfgi->cascades[j].sdf_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 2; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (j < sdfgi->cascades.size()) { - u.ids.push_back(sdfgi->cascades[j].light_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 3; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (j < sdfgi->cascades.size()) { - u.ids.push_back(sdfgi->cascades[j].light_aniso_0_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 4; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (j < sdfgi->cascades.size()) { - u.ids.push_back(sdfgi->cascades[j].light_aniso_1_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 6; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 7; - u.ids.push_back(sdfgi->cascades_ubo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 8; - u.ids.push_back(sdfgi->lightprobe_data); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 9; - u.ids.push_back(sdfgi->cascades[i].lightprobe_history_tex); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 10; - u.ids.push_back(sdfgi->cascades[i].lightprobe_average_tex); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 11; - u.ids.push_back(sdfgi->lightprobe_history_scroll); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 12; - u.ids.push_back(sdfgi->lightprobe_average_scroll); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 13; - RID parent_average; - if (i < sdfgi->cascades.size() - 1) { - parent_average = sdfgi->cascades[i + 1].lightprobe_average_tex; - } else { - parent_average = sdfgi->cascades[i - 1].lightprobe_average_tex; //to use something, but it won't be used - } - u.ids.push_back(parent_average); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 14; - u.ids.push_back(sdfgi->ambient_texture); - uniforms.push_back(u); - } - - sdfgi->cascades[i].integrate_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.integrate.version_get_shader(sdfgi_shader.integrate_shader, 0), 0); - } - - sdfgi->bounce_feedback = env->sdfgi_bounce_feedback; - sdfgi->energy = env->sdfgi_energy; - sdfgi->normal_bias = env->sdfgi_normal_bias; - sdfgi->probe_bias = env->sdfgi_probe_bias; - sdfgi->reads_sky = env->sdfgi_read_sky_light; + // re-create + rb->sdfgi = gi.create_sdfgi(env, p_world_position, requested_history_size); _render_buffers_uniform_set_changed(p_render_buffers); - - return; //done. all levels will need to be rendered which its going to take a bit - } - - //check for updates - - sdfgi->bounce_feedback = env->sdfgi_bounce_feedback; - sdfgi->energy = env->sdfgi_energy; - sdfgi->normal_bias = env->sdfgi_normal_bias; - sdfgi->probe_bias = env->sdfgi_probe_bias; - sdfgi->reads_sky = env->sdfgi_read_sky_light; - - int32_t drag_margin = (sdfgi->cascade_size / SDFGI::PROBE_DIVISOR) / 2; - - for (uint32_t i = 0; i < sdfgi->cascades.size(); i++) { - SDFGI::Cascade &cascade = sdfgi->cascades[i]; - cascade.dirty_regions = Vector3i(); - - Vector3 probe_half_size = Vector3(1, 1, 1) * cascade.cell_size * float(sdfgi->cascade_size / SDFGI::PROBE_DIVISOR) * 0.5; - probe_half_size = Vector3(0, 0, 0); - - Vector3 world_position = p_world_position; - world_position.y *= sdfgi->y_mult; - Vector3i pos_in_cascade = Vector3i((world_position + probe_half_size) / cascade.cell_size); - - for (int j = 0; j < 3; j++) { - if (pos_in_cascade[j] < cascade.position[j]) { - while (pos_in_cascade[j] < (cascade.position[j] - drag_margin)) { - cascade.position[j] -= drag_margin * 2; - cascade.dirty_regions[j] += drag_margin * 2; - } - } else if (pos_in_cascade[j] > cascade.position[j]) { - while (pos_in_cascade[j] > (cascade.position[j] + drag_margin)) { - cascade.position[j] += drag_margin * 2; - cascade.dirty_regions[j] -= drag_margin * 2; - } - } - - if (cascade.dirty_regions[j] == 0) { - continue; // not dirty - } else if (uint32_t(ABS(cascade.dirty_regions[j])) >= sdfgi->cascade_size) { - //moved too much, just redraw everything (make all dirty) - cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL; - break; - } - } - - if (cascade.dirty_regions != Vector3i() && cascade.dirty_regions != SDFGI::Cascade::DIRTY_ALL) { - //see how much the total dirty volume represents from the total volume - uint32_t total_volume = sdfgi->cascade_size * sdfgi->cascade_size * sdfgi->cascade_size; - uint32_t safe_volume = 1; - for (int j = 0; j < 3; j++) { - safe_volume *= sdfgi->cascade_size - ABS(cascade.dirty_regions[j]); - } - uint32_t dirty_volume = total_volume - safe_volume; - if (dirty_volume > (safe_volume / 2)) { - //more than half the volume is dirty, make all dirty so its only rendered once - cascade.dirty_regions = SDFGI::Cascade::DIRTY_ALL; - } - } + } else { + //check for updates + rb->sdfgi->update(env, p_world_position); } } @@ -1037,9 +97,9 @@ int RendererSceneRenderRD::sdfgi_get_pending_region_count(RID p_render_buffers) int dirty_count = 0; for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - const SDFGI::Cascade &c = rb->sdfgi->cascades[i]; + const RendererSceneGIRD::SDFGI::Cascade &c = rb->sdfgi->cascades[i]; - if (c.dirty_regions == SDFGI::Cascade::DIRTY_ALL) { + if (c.dirty_regions == RendererSceneGIRD::SDFGI::Cascade::DIRTY_ALL) { dirty_count++; } else { for (int j = 0; j < 3; j++) { @@ -1053,72 +113,15 @@ int RendererSceneRenderRD::sdfgi_get_pending_region_count(RID p_render_buffers) return dirty_count; } -int RendererSceneRenderRD::_sdfgi_get_pending_region_data(RID p_render_buffers, int p_region, Vector3i &r_local_offset, Vector3i &r_local_size, AABB &r_bounds) const { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND_V(rb == nullptr, -1); - ERR_FAIL_COND_V(rb->sdfgi == nullptr, -1); - - int dirty_count = 0; - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - const SDFGI::Cascade &c = rb->sdfgi->cascades[i]; - - if (c.dirty_regions == SDFGI::Cascade::DIRTY_ALL) { - if (dirty_count == p_region) { - r_local_offset = Vector3i(); - r_local_size = Vector3i(1, 1, 1) * rb->sdfgi->cascade_size; - - r_bounds.position = Vector3((Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + c.position)) * c.cell_size * Vector3(1, 1.0 / rb->sdfgi->y_mult, 1); - r_bounds.size = Vector3(r_local_size) * c.cell_size * Vector3(1, 1.0 / rb->sdfgi->y_mult, 1); - return i; - } - dirty_count++; - } else { - for (int j = 0; j < 3; j++) { - if (c.dirty_regions[j] != 0) { - if (dirty_count == p_region) { - Vector3i from = Vector3i(0, 0, 0); - Vector3i to = Vector3i(1, 1, 1) * rb->sdfgi->cascade_size; - - if (c.dirty_regions[j] > 0) { - //fill from the beginning - to[j] = c.dirty_regions[j]; - } else { - //fill from the end - from[j] = to[j] + c.dirty_regions[j]; - } - - for (int k = 0; k < j; k++) { - // "chip" away previous regions to avoid re-voxelizing the same thing - if (c.dirty_regions[k] > 0) { - from[k] += c.dirty_regions[k]; - } else if (c.dirty_regions[k] < 0) { - to[k] += c.dirty_regions[k]; - } - } - - r_local_offset = from; - r_local_size = to - from; - - r_bounds.position = Vector3(from + Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + c.position) * c.cell_size * Vector3(1, 1.0 / rb->sdfgi->y_mult, 1); - r_bounds.size = Vector3(r_local_size) * c.cell_size * Vector3(1, 1.0 / rb->sdfgi->y_mult, 1); - - return i; - } - - dirty_count++; - } - } - } - } - return -1; -} - AABB RendererSceneRenderRD::sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const { AABB bounds; Vector3i from; Vector3i size; + RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND_V(rb == nullptr, AABB()); + ERR_FAIL_COND_V(rb->sdfgi == nullptr, AABB()); - int c = _sdfgi_get_pending_region_data(p_render_buffers, p_region, from, size, bounds); + int c = rb->sdfgi->get_pending_region_data(p_region, from, size, bounds); ERR_FAIL_COND_V(c == -1, AABB()); return bounds; } @@ -1127,1956 +130,179 @@ uint32_t RendererSceneRenderRD::sdfgi_get_pending_region_cascade(RID p_render_bu AABB bounds; Vector3i from; Vector3i size; - - return _sdfgi_get_pending_region_data(p_render_buffers, p_region, from, size, bounds); -} - -void RendererSceneRenderRD::_sdfgi_update_cascades(RID p_render_buffers) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - if (rb->sdfgi == nullptr) { - return; - } - - //update cascades - SDFGI::Cascade::UBO cascade_data[SDFGI::MAX_CASCADES]; - int32_t probe_divisor = rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; - - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - Vector3 pos = Vector3((Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + rb->sdfgi->cascades[i].position)) * rb->sdfgi->cascades[i].cell_size; - - cascade_data[i].offset[0] = pos.x; - cascade_data[i].offset[1] = pos.y; - cascade_data[i].offset[2] = pos.z; - cascade_data[i].to_cell = 1.0 / rb->sdfgi->cascades[i].cell_size; - cascade_data[i].probe_offset[0] = rb->sdfgi->cascades[i].position.x / probe_divisor; - cascade_data[i].probe_offset[1] = rb->sdfgi->cascades[i].position.y / probe_divisor; - cascade_data[i].probe_offset[2] = rb->sdfgi->cascades[i].position.z / probe_divisor; - cascade_data[i].pad = 0; - } - - RD::get_singleton()->buffer_update(rb->sdfgi->cascades_ubo, 0, sizeof(SDFGI::Cascade::UBO) * SDFGI::MAX_CASCADES, cascade_data, RD::BARRIER_MASK_COMPUTE); -} - -void RendererSceneRenderRD::_sdfgi_update_light(RID p_render_buffers, RID p_environment) { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - if (rb->sdfgi == nullptr) { - return; - } - - RD::get_singleton()->draw_command_begin_label("SDFGI Update dynamic Light"); - - /* Update dynamic light */ - - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.direct_light_pipeline[SDGIShader::DIRECT_LIGHT_MODE_DYNAMIC]); - - SDGIShader::DirectLightPushConstant push_constant; - - push_constant.grid_size[0] = rb->sdfgi->cascade_size; - push_constant.grid_size[1] = rb->sdfgi->cascade_size; - push_constant.grid_size[2] = rb->sdfgi->cascade_size; - push_constant.max_cascades = rb->sdfgi->cascades.size(); - push_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - push_constant.bounce_feedback = rb->sdfgi->bounce_feedback; - push_constant.y_mult = rb->sdfgi->y_mult; - push_constant.use_occlusion = rb->sdfgi->uses_occlusion; - - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - SDFGI::Cascade &cascade = rb->sdfgi->cascades[i]; - push_constant.light_count = rb->sdfgi->cascade_dynamic_light_count[i]; - push_constant.cascade = i; - - if (rb->sdfgi->cascades[i].all_dynamic_lights_dirty || sdfgi_frames_to_update_light == RS::ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME) { - push_constant.process_offset = 0; - push_constant.process_increment = 1; - } else { - static uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = { - 1, 2, 4, 8, 16 - }; - - uint32_t frames_to_update = frames_to_update_table[sdfgi_frames_to_update_light]; - - push_constant.process_offset = RSG::rasterizer->get_frame_number() % frames_to_update; - push_constant.process_increment = frames_to_update; - } - rb->sdfgi->cascades[i].all_dynamic_lights_dirty = false; - - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascade.sdf_direct_light_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::DirectLightPushConstant)); - RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cascade.solid_cell_dispatch_buffer, 0); - } - RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_COMPUTE); - RD::get_singleton()->draw_command_end_label(); -} - -void RendererSceneRenderRD::_sdfgi_update_probes(RID p_render_buffers, RID p_environment) { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - if (rb->sdfgi == nullptr) { - return; - } - - RD::get_singleton()->draw_command_begin_label("SDFGI Update Probes"); - - Environment *env = environment_owner.getornull(p_environment); - - SDGIShader::IntegratePushConstant push_constant; - push_constant.grid_size[1] = rb->sdfgi->cascade_size; - push_constant.grid_size[2] = rb->sdfgi->cascade_size; - push_constant.grid_size[0] = rb->sdfgi->cascade_size; - push_constant.max_cascades = rb->sdfgi->cascades.size(); - push_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - push_constant.history_index = rb->sdfgi->render_pass % rb->sdfgi->history_size; - push_constant.history_size = rb->sdfgi->history_size; - static const uint32_t ray_count[RS::ENV_SDFGI_RAY_COUNT_MAX] = { 4, 8, 16, 32, 64, 96, 128 }; - push_constant.ray_count = ray_count[sdfgi_ray_count]; - push_constant.ray_bias = rb->sdfgi->probe_bias; - push_constant.image_size[0] = rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count; - push_constant.image_size[1] = rb->sdfgi->probe_axis_count; - push_constant.store_ambient_texture = env->volumetric_fog_enabled; - - RID sky_uniform_set = sdfgi_shader.integrate_default_sky_uniform_set; - push_constant.sky_mode = SDGIShader::IntegratePushConstant::SKY_MODE_DISABLED; - push_constant.y_mult = rb->sdfgi->y_mult; - - if (rb->sdfgi->reads_sky && env) { - push_constant.sky_energy = env->bg_energy; - - if (env->background == RS::ENV_BG_CLEAR_COLOR) { - push_constant.sky_mode = SDGIShader::IntegratePushConstant::SKY_MODE_COLOR; - Color c = storage->get_default_clear_color().to_linear(); - push_constant.sky_color[0] = c.r; - push_constant.sky_color[1] = c.g; - push_constant.sky_color[2] = c.b; - } else if (env->background == RS::ENV_BG_COLOR) { - push_constant.sky_mode = SDGIShader::IntegratePushConstant::SKY_MODE_COLOR; - Color c = env->bg_color; - push_constant.sky_color[0] = c.r; - push_constant.sky_color[1] = c.g; - push_constant.sky_color[2] = c.b; - - } else if (env->background == RS::ENV_BG_SKY) { - Sky *sky = sky_owner.getornull(env->sky); - if (sky && sky->radiance.is_valid()) { - if (sky->sdfgi_integrate_sky_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(sky->sdfgi_integrate_sky_uniform_set)) { - Vector<RD::Uniform> uniforms; - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 0; - u.ids.push_back(sky->radiance); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 1; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - sky->sdfgi_integrate_sky_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.integrate.version_get_shader(sdfgi_shader.integrate_shader, 0), 1); - } - sky_uniform_set = sky->sdfgi_integrate_sky_uniform_set; - push_constant.sky_mode = SDGIShader::IntegratePushConstant::SKY_MODE_SKY; - } - } - } - - rb->sdfgi->render_pass++; - - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(true); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.integrate_pipeline[SDGIShader::INTEGRATE_MODE_PROCESS]); - - int32_t probe_divisor = rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - push_constant.cascade = i; - push_constant.world_offset[0] = rb->sdfgi->cascades[i].position.x / probe_divisor; - push_constant.world_offset[1] = rb->sdfgi->cascades[i].position.y / probe_divisor; - push_constant.world_offset[2] = rb->sdfgi->cascades[i].position.z / probe_divisor; - - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[i].integrate_uniform_set, 0); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sky_uniform_set, 1); - - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::IntegratePushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count, rb->sdfgi->probe_axis_count, 1); - } - - //end later after raster to avoid barriering on layout changes - //RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_NO_BARRIER); - - RD::get_singleton()->draw_command_end_label(); -} - -void RendererSceneRenderRD::_sdfgi_store_probes(RID p_render_buffers) { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - if (rb->sdfgi == nullptr) { - return; - } - - RD::get_singleton()->barrier(RD::BARRIER_MASK_COMPUTE, RD::BARRIER_MASK_COMPUTE); - RD::get_singleton()->draw_command_begin_label("SDFGI Store Probes"); - - SDGIShader::IntegratePushConstant push_constant; - push_constant.grid_size[1] = rb->sdfgi->cascade_size; - push_constant.grid_size[2] = rb->sdfgi->cascade_size; - push_constant.grid_size[0] = rb->sdfgi->cascade_size; - push_constant.max_cascades = rb->sdfgi->cascades.size(); - push_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - push_constant.history_index = rb->sdfgi->render_pass % rb->sdfgi->history_size; - push_constant.history_size = rb->sdfgi->history_size; - static const uint32_t ray_count[RS::ENV_SDFGI_RAY_COUNT_MAX] = { 4, 8, 16, 32, 64, 96, 128 }; - push_constant.ray_count = ray_count[sdfgi_ray_count]; - push_constant.ray_bias = rb->sdfgi->probe_bias; - push_constant.image_size[0] = rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count; - push_constant.image_size[1] = rb->sdfgi->probe_axis_count; - push_constant.store_ambient_texture = false; - - push_constant.sky_mode = 0; - push_constant.y_mult = rb->sdfgi->y_mult; - - // Then store values into the lightprobe texture. Separating these steps has a small performance hit, but it allows for multiple bounces - RENDER_TIMESTAMP("Average Probes"); - - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.integrate_pipeline[SDGIShader::INTEGRATE_MODE_STORE]); - - //convert to octahedral to store - push_constant.image_size[0] *= SDFGI::LIGHTPROBE_OCT_SIZE; - push_constant.image_size[1] *= SDFGI::LIGHTPROBE_OCT_SIZE; - - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - push_constant.cascade = i; - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[i].integrate_uniform_set, 0); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdfgi_shader.integrate_default_sky_uniform_set, 1); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::IntegratePushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, rb->sdfgi->probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, 1); - } - - RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_COMPUTE); - - RD::get_singleton()->draw_command_end_label(); -} -void RendererSceneRenderRD::_setup_giprobes(RID p_render_buffers, const Transform &p_transform, const PagedArray<RID> &p_gi_probes, uint32_t &r_gi_probes_used) { - r_gi_probes_used = 0; - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - - RD::get_singleton()->draw_command_begin_label("GIProbes Setup"); - - RID gi_probe_buffer = render_buffers_get_gi_probe_buffer(p_render_buffers); - GI::GIProbeData gi_probe_data[RenderBuffers::MAX_GIPROBES]; - - bool giprobes_changed = false; - - Transform to_camera; - to_camera.origin = p_transform.origin; //only translation, make local - - for (int i = 0; i < RenderBuffers::MAX_GIPROBES; i++) { - RID texture; - if (i < (int)p_gi_probes.size()) { - GIProbeInstance *gipi = gi_probe_instance_owner.getornull(p_gi_probes[i]); - - if (gipi) { - texture = gipi->texture; - GI::GIProbeData &gipd = gi_probe_data[i]; - - RID base_probe = gipi->probe; - - Transform to_cell = storage->gi_probe_get_to_cell_xform(gipi->probe) * gipi->transform.affine_inverse() * to_camera; - - gipd.xform[0] = to_cell.basis.elements[0][0]; - gipd.xform[1] = to_cell.basis.elements[1][0]; - gipd.xform[2] = to_cell.basis.elements[2][0]; - gipd.xform[3] = 0; - gipd.xform[4] = to_cell.basis.elements[0][1]; - gipd.xform[5] = to_cell.basis.elements[1][1]; - gipd.xform[6] = to_cell.basis.elements[2][1]; - gipd.xform[7] = 0; - gipd.xform[8] = to_cell.basis.elements[0][2]; - gipd.xform[9] = to_cell.basis.elements[1][2]; - gipd.xform[10] = to_cell.basis.elements[2][2]; - gipd.xform[11] = 0; - gipd.xform[12] = to_cell.origin.x; - gipd.xform[13] = to_cell.origin.y; - gipd.xform[14] = to_cell.origin.z; - gipd.xform[15] = 1; - - Vector3 bounds = storage->gi_probe_get_octree_size(base_probe); - - gipd.bounds[0] = bounds.x; - gipd.bounds[1] = bounds.y; - gipd.bounds[2] = bounds.z; - - gipd.dynamic_range = storage->gi_probe_get_dynamic_range(base_probe) * storage->gi_probe_get_energy(base_probe); - gipd.bias = storage->gi_probe_get_bias(base_probe); - gipd.normal_bias = storage->gi_probe_get_normal_bias(base_probe); - gipd.blend_ambient = !storage->gi_probe_is_interior(base_probe); - gipd.anisotropy_strength = 0; - gipd.ao = storage->gi_probe_get_ao(base_probe); - gipd.ao_size = Math::pow(storage->gi_probe_get_ao_size(base_probe), 4.0f); - gipd.mipmaps = gipi->mipmaps.size(); - } - - r_gi_probes_used++; - } - - if (texture == RID()) { - texture = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); - } - - if (texture != rb->giprobe_textures[i]) { - giprobes_changed = true; - rb->giprobe_textures[i] = texture; - } - } - - if (giprobes_changed) { - if (RD::get_singleton()->uniform_set_is_valid(rb->gi_uniform_set)) { - RD::get_singleton()->free(rb->gi_uniform_set); - } - rb->gi_uniform_set = RID(); - if (rb->volumetric_fog) { - if (RD::get_singleton()->uniform_set_is_valid(rb->volumetric_fog->uniform_set)) { - RD::get_singleton()->free(rb->volumetric_fog->uniform_set); - RD::get_singleton()->free(rb->volumetric_fog->uniform_set2); - } - rb->volumetric_fog->uniform_set = RID(); - rb->volumetric_fog->uniform_set2 = RID(); - } - } - - if (p_gi_probes.size() > 0) { - RD::get_singleton()->buffer_update(gi_probe_buffer, 0, sizeof(GI::GIProbeData) * MIN((uint64_t)RenderBuffers::MAX_GIPROBES, p_gi_probes.size()), gi_probe_data, RD::BARRIER_MASK_COMPUTE); - } - - RD::get_singleton()->draw_command_end_label(); -} - -void RendererSceneRenderRD::_pre_process_gi(RID p_render_buffers, const Transform &p_transform) { - // Do the required buffer transfers and setup before the depth-pre pass, this way GI can - // run in parallel during depth-pre pass and shadow rendering. - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - - /* Update Cascades UBO */ - - if (rb->sdfgi) { - /* Update general SDFGI Buffer */ - - _sdfgi_update_cascades(p_render_buffers); - - GI::SDFGIData sdfgi_data; - - sdfgi_data.grid_size[0] = rb->sdfgi->cascade_size; - sdfgi_data.grid_size[1] = rb->sdfgi->cascade_size; - sdfgi_data.grid_size[2] = rb->sdfgi->cascade_size; - - sdfgi_data.max_cascades = rb->sdfgi->cascades.size(); - sdfgi_data.probe_axis_size = rb->sdfgi->probe_axis_count; - sdfgi_data.cascade_probe_size[0] = sdfgi_data.probe_axis_size - 1; //float version for performance - sdfgi_data.cascade_probe_size[1] = sdfgi_data.probe_axis_size - 1; - sdfgi_data.cascade_probe_size[2] = sdfgi_data.probe_axis_size - 1; - - float csize = rb->sdfgi->cascade_size; - sdfgi_data.probe_to_uvw = 1.0 / float(sdfgi_data.cascade_probe_size[0]); - sdfgi_data.use_occlusion = rb->sdfgi->uses_occlusion; - //sdfgi_data.energy = rb->sdfgi->energy; - - sdfgi_data.y_mult = rb->sdfgi->y_mult; - - float cascade_voxel_size = (csize / sdfgi_data.cascade_probe_size[0]); - float occlusion_clamp = (cascade_voxel_size - 0.5) / cascade_voxel_size; - sdfgi_data.occlusion_clamp[0] = occlusion_clamp; - sdfgi_data.occlusion_clamp[1] = occlusion_clamp; - sdfgi_data.occlusion_clamp[2] = occlusion_clamp; - sdfgi_data.normal_bias = (rb->sdfgi->normal_bias / csize) * sdfgi_data.cascade_probe_size[0]; - - //vec2 tex_pixel_size = 1.0 / vec2(ivec2( (OCT_SIZE+2) * params.probe_axis_size * params.probe_axis_size, (OCT_SIZE+2) * params.probe_axis_size ) ); - //vec3 probe_uv_offset = (ivec3(OCT_SIZE+2,OCT_SIZE+2,(OCT_SIZE+2) * params.probe_axis_size)) * tex_pixel_size.xyx; - - uint32_t oct_size = SDFGI::LIGHTPROBE_OCT_SIZE; - - sdfgi_data.lightprobe_tex_pixel_size[0] = 1.0 / ((oct_size + 2) * sdfgi_data.probe_axis_size * sdfgi_data.probe_axis_size); - sdfgi_data.lightprobe_tex_pixel_size[1] = 1.0 / ((oct_size + 2) * sdfgi_data.probe_axis_size); - sdfgi_data.lightprobe_tex_pixel_size[2] = 1.0; - - sdfgi_data.energy = rb->sdfgi->energy; - - sdfgi_data.lightprobe_uv_offset[0] = float(oct_size + 2) * sdfgi_data.lightprobe_tex_pixel_size[0]; - sdfgi_data.lightprobe_uv_offset[1] = float(oct_size + 2) * sdfgi_data.lightprobe_tex_pixel_size[1]; - sdfgi_data.lightprobe_uv_offset[2] = float((oct_size + 2) * sdfgi_data.probe_axis_size) * sdfgi_data.lightprobe_tex_pixel_size[0]; - - sdfgi_data.occlusion_renormalize[0] = 0.5; - sdfgi_data.occlusion_renormalize[1] = 1.0; - sdfgi_data.occlusion_renormalize[2] = 1.0 / float(sdfgi_data.max_cascades); - - int32_t probe_divisor = rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; - - for (uint32_t i = 0; i < sdfgi_data.max_cascades; i++) { - GI::SDFGIData::ProbeCascadeData &c = sdfgi_data.cascades[i]; - Vector3 pos = Vector3((Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + rb->sdfgi->cascades[i].position)) * rb->sdfgi->cascades[i].cell_size; - Vector3 cam_origin = p_transform.origin; - cam_origin.y *= rb->sdfgi->y_mult; - pos -= cam_origin; //make pos local to camera, to reduce numerical error - c.position[0] = pos.x; - c.position[1] = pos.y; - c.position[2] = pos.z; - c.to_probe = 1.0 / (float(rb->sdfgi->cascade_size) * rb->sdfgi->cascades[i].cell_size / float(rb->sdfgi->probe_axis_count - 1)); - - Vector3i probe_ofs = rb->sdfgi->cascades[i].position / probe_divisor; - c.probe_world_offset[0] = probe_ofs.x; - c.probe_world_offset[1] = probe_ofs.y; - c.probe_world_offset[2] = probe_ofs.z; - - c.to_cell = 1.0 / rb->sdfgi->cascades[i].cell_size; - } - - RD::get_singleton()->buffer_update(gi.sdfgi_ubo, 0, sizeof(GI::SDFGIData), &sdfgi_data, RD::BARRIER_MASK_COMPUTE); - - /* Update dynamic lights in SDFGI cascades */ - - for (uint32_t i = 0; i < rb->sdfgi->cascades.size(); i++) { - SDFGI::Cascade &cascade = rb->sdfgi->cascades[i]; - - SDGIShader::Light lights[SDFGI::MAX_DYNAMIC_LIGHTS]; - uint32_t idx = 0; - for (uint32_t j = 0; j < (uint32_t)render_state.sdfgi_update_data->directional_lights->size(); j++) { - if (idx == SDFGI::MAX_DYNAMIC_LIGHTS) { - break; - } - - LightInstance *li = light_instance_owner.getornull(render_state.sdfgi_update_data->directional_lights->get(j)); - ERR_CONTINUE(!li); - - if (storage->light_directional_is_sky_only(li->light)) { - continue; - } - - Vector3 dir = -li->transform.basis.get_axis(Vector3::AXIS_Z); - dir.y *= rb->sdfgi->y_mult; - dir.normalize(); - lights[idx].direction[0] = dir.x; - lights[idx].direction[1] = dir.y; - lights[idx].direction[2] = dir.z; - Color color = storage->light_get_color(li->light); - color = color.to_linear(); - lights[idx].color[0] = color.r; - lights[idx].color[1] = color.g; - lights[idx].color[2] = color.b; - lights[idx].type = RS::LIGHT_DIRECTIONAL; - lights[idx].energy = storage->light_get_param(li->light, RS::LIGHT_PARAM_ENERGY); - lights[idx].has_shadow = storage->light_has_shadow(li->light); - - idx++; - } - - AABB cascade_aabb; - cascade_aabb.position = Vector3((Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + cascade.position)) * cascade.cell_size; - cascade_aabb.size = Vector3(1, 1, 1) * rb->sdfgi->cascade_size * cascade.cell_size; - - for (uint32_t j = 0; j < render_state.sdfgi_update_data->positional_light_count; j++) { - if (idx == SDFGI::MAX_DYNAMIC_LIGHTS) { - break; - } - - LightInstance *li = light_instance_owner.getornull(render_state.sdfgi_update_data->positional_light_instances[j]); - ERR_CONTINUE(!li); - - uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light); - if (i > max_sdfgi_cascade) { - continue; - } - - if (!cascade_aabb.intersects(li->aabb)) { - continue; - } - - Vector3 dir = -li->transform.basis.get_axis(Vector3::AXIS_Z); - //faster to not do this here - //dir.y *= rb->sdfgi->y_mult; - //dir.normalize(); - lights[idx].direction[0] = dir.x; - lights[idx].direction[1] = dir.y; - lights[idx].direction[2] = dir.z; - Vector3 pos = li->transform.origin; - pos.y *= rb->sdfgi->y_mult; - lights[idx].position[0] = pos.x; - lights[idx].position[1] = pos.y; - lights[idx].position[2] = pos.z; - Color color = storage->light_get_color(li->light); - color = color.to_linear(); - lights[idx].color[0] = color.r; - lights[idx].color[1] = color.g; - lights[idx].color[2] = color.b; - lights[idx].type = storage->light_get_type(li->light); - lights[idx].energy = storage->light_get_param(li->light, RS::LIGHT_PARAM_ENERGY); - lights[idx].has_shadow = storage->light_has_shadow(li->light); - lights[idx].attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_ATTENUATION); - lights[idx].radius = storage->light_get_param(li->light, RS::LIGHT_PARAM_RANGE); - lights[idx].cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE))); - lights[idx].inv_spot_attenuation = 1.0f / storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); - - idx++; - } - - if (idx > 0) { - RD::get_singleton()->buffer_update(cascade.lights_buffer, 0, idx * sizeof(SDGIShader::Light), lights, RD::BARRIER_MASK_COMPUTE); - } - - rb->sdfgi->cascade_dynamic_light_count[i] = idx; - } - } -} - -void RendererSceneRenderRD::_process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_gi_probe_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform, const PagedArray<RID> &p_gi_probes) { - RD::get_singleton()->draw_command_begin_label("GI Render"); - - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(rb == nullptr); - Environment *env = environment_owner.getornull(p_environment); - - if (rb->ambient_buffer.is_null() || rb->using_half_size_gi != gi.half_resolution) { - if (rb->ambient_buffer.is_valid()) { - RD::get_singleton()->free(rb->ambient_buffer); - RD::get_singleton()->free(rb->reflection_buffer); - } - - RD::TextureFormat tf; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf.width = rb->width; - tf.height = rb->height; - if (gi.half_resolution) { - tf.width >>= 1; - tf.height >>= 1; - } - tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; - rb->reflection_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView()); - rb->ambient_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView()); - rb->using_half_size_gi = gi.half_resolution; - - _render_buffers_uniform_set_changed(p_render_buffers); - } - - GI::PushConstant push_constant; - - push_constant.screen_size[0] = rb->width; - push_constant.screen_size[1] = rb->height; - push_constant.z_near = p_projection.get_z_near(); - push_constant.z_far = p_projection.get_z_far(); - push_constant.orthogonal = p_projection.is_orthogonal(); - push_constant.proj_info[0] = -2.0f / (rb->width * p_projection.matrix[0][0]); - push_constant.proj_info[1] = -2.0f / (rb->height * p_projection.matrix[1][1]); - push_constant.proj_info[2] = (1.0f - p_projection.matrix[0][2]) / p_projection.matrix[0][0]; - push_constant.proj_info[3] = (1.0f + p_projection.matrix[1][2]) / p_projection.matrix[1][1]; - push_constant.max_giprobes = MIN((uint64_t)RenderBuffers::MAX_GIPROBES, p_gi_probes.size()); - push_constant.high_quality_vct = gi_probe_quality == RS::GI_PROBE_QUALITY_HIGH; - - bool use_sdfgi = rb->sdfgi != nullptr; - bool use_giprobes = push_constant.max_giprobes > 0; - - if (env) { - push_constant.ao_color[0] = env->ao_color.r; - push_constant.ao_color[1] = env->ao_color.g; - push_constant.ao_color[2] = env->ao_color.b; - } else { - push_constant.ao_color[0] = 0; - push_constant.ao_color[1] = 0; - push_constant.ao_color[2] = 0; - } - - push_constant.cam_rotation[0] = p_transform.basis[0][0]; - push_constant.cam_rotation[1] = p_transform.basis[1][0]; - push_constant.cam_rotation[2] = p_transform.basis[2][0]; - push_constant.cam_rotation[3] = 0; - push_constant.cam_rotation[4] = p_transform.basis[0][1]; - push_constant.cam_rotation[5] = p_transform.basis[1][1]; - push_constant.cam_rotation[6] = p_transform.basis[2][1]; - push_constant.cam_rotation[7] = 0; - push_constant.cam_rotation[8] = p_transform.basis[0][2]; - push_constant.cam_rotation[9] = p_transform.basis[1][2]; - push_constant.cam_rotation[10] = p_transform.basis[2][2]; - push_constant.cam_rotation[11] = 0; - - if (rb->gi_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(rb->gi_uniform_set)) { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.binding = 1; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[j].sdf_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 2; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[j].light_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 3; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[j].light_aniso_0_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 4; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t j = 0; j < SDFGI::MAX_CASCADES; j++) { - if (rb->sdfgi && j < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[j].light_aniso_1_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 5; - if (rb->sdfgi) { - u.ids.push_back(rb->sdfgi->occlusion_texture); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 6; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 7; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 9; - u.ids.push_back(rb->ambient_buffer); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 10; - u.ids.push_back(rb->reflection_buffer); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 11; - if (rb->sdfgi) { - u.ids.push_back(rb->sdfgi->lightprobe_texture); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE)); - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 12; - u.ids.push_back(rb->depth_texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 13; - u.ids.push_back(p_normal_roughness_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 14; - RID buffer = p_gi_probe_buffer.is_valid() ? p_gi_probe_buffer : storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_BLACK); - u.ids.push_back(buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 15; - u.ids.push_back(gi.sdfgi_ubo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 16; - u.ids.push_back(rb->giprobe_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 17; - for (int i = 0; i < RenderBuffers::MAX_GIPROBES; i++) { - u.ids.push_back(rb->giprobe_textures[i]); - } - uniforms.push_back(u); - } - - rb->gi_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi.shader.version_get_shader(gi.shader_version, 0), 0); - } - - GI::Mode mode; - - if (rb->using_half_size_gi) { - mode = (use_sdfgi && use_giprobes) ? GI::MODE_HALF_RES_COMBINED : (use_sdfgi ? GI::MODE_HALF_RES_SDFGI : GI::MODE_HALF_RES_GIPROBE); - } else { - mode = (use_sdfgi && use_giprobes) ? GI::MODE_COMBINED : (use_sdfgi ? GI::MODE_SDFGI : GI::MODE_GIPROBE); - } - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(true); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, gi.pipelines[mode]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->gi_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GI::PushConstant)); + ERR_FAIL_COND_V(rb == nullptr, -1); + ERR_FAIL_COND_V(rb->sdfgi == nullptr, -1); - if (rb->using_half_size_gi) { - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width >> 1, rb->height >> 1, 1); - } else { - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width, rb->height, 1); - } - //do barrier later to allow oeverlap - //RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_NO_BARRIER); //no barriers, let other compute, raster and transfer happen at the same time - RD::get_singleton()->draw_command_end_label(); + return rb->sdfgi->get_pending_region_data(p_region, from, size, bounds); } RID RendererSceneRenderRD::sky_allocate() { - return sky_owner.allocate_rid(); + return sky.allocate_sky_rid(); } void RendererSceneRenderRD::sky_initialize(RID p_rid) { - sky_owner.initialize_rid(p_rid, Sky()); -} - -void RendererSceneRenderRD::_sky_invalidate(Sky *p_sky) { - if (!p_sky->dirty) { - p_sky->dirty = true; - p_sky->dirty_list = dirty_sky_list; - dirty_sky_list = p_sky; - } + sky.initialize_sky_rid(p_rid); } void RendererSceneRenderRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND(!sky); - ERR_FAIL_COND(p_radiance_size < 32 || p_radiance_size > 2048); - if (sky->radiance_size == p_radiance_size) { - return; - } - sky->radiance_size = p_radiance_size; - - if (sky->mode == RS::SKY_MODE_REALTIME && sky->radiance_size != 256) { - WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally."); - sky->radiance_size = 256; - } - - _sky_invalidate(sky); - if (sky->radiance.is_valid()) { - RD::get_singleton()->free(sky->radiance); - sky->radiance = RID(); - } - _clear_reflection_data(sky->reflection); + sky.sky_set_radiance_size(p_sky, p_radiance_size); } void RendererSceneRenderRD::sky_set_mode(RID p_sky, RS::SkyMode p_mode) { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND(!sky); - - if (sky->mode == p_mode) { - return; - } - - sky->mode = p_mode; - - if (sky->mode == RS::SKY_MODE_REALTIME && sky->radiance_size != 256) { - WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally."); - sky_set_radiance_size(p_sky, 256); - } - - _sky_invalidate(sky); - if (sky->radiance.is_valid()) { - RD::get_singleton()->free(sky->radiance); - sky->radiance = RID(); - } - _clear_reflection_data(sky->reflection); + sky.sky_set_mode(p_sky, p_mode); } void RendererSceneRenderRD::sky_set_material(RID p_sky, RID p_material) { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND(!sky); - sky->material = p_material; - _sky_invalidate(sky); + sky.sky_set_material(p_sky, p_material); } Ref<Image> RendererSceneRenderRD::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND_V(!sky, Ref<Image>()); - - _update_dirty_skys(); - - if (sky->radiance.is_valid()) { - RD::TextureFormat tf; - tf.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; - tf.width = p_size.width; - tf.height = p_size.height; - tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; - - RID rad_tex = RD::get_singleton()->texture_create(tf, RD::TextureView()); - storage->get_effects()->copy_cubemap_to_panorama(sky->radiance, rad_tex, p_size, p_bake_irradiance ? roughness_layers : 0, sky->reflection.layers.size() > 1); - Vector<uint8_t> data = RD::get_singleton()->texture_get_data(rad_tex, 0); - RD::get_singleton()->free(rad_tex); - - Ref<Image> img; - img.instance(); - img->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF, data); - for (int i = 0; i < p_size.width; i++) { - for (int j = 0; j < p_size.height; j++) { - Color c = img->get_pixel(i, j); - c.r *= p_energy; - c.g *= p_energy; - c.b *= p_energy; - img->set_pixel(i, j, c); - } - } - return img; - } - - return Ref<Image>(); -} - -void RendererSceneRenderRD::_update_dirty_skys() { - Sky *sky = dirty_sky_list; - - while (sky) { - bool texture_set_dirty = false; - //update sky configuration if texture is missing - - if (sky->radiance.is_null()) { - int mipmaps = Image::get_image_required_mipmaps(sky->radiance_size, sky->radiance_size, Image::FORMAT_RGBAH) + 1; - - uint32_t w = sky->radiance_size, h = sky->radiance_size; - int layers = roughness_layers; - if (sky->mode == RS::SKY_MODE_REALTIME) { - layers = 8; - if (roughness_layers != 8) { - WARN_PRINT("When using REALTIME skies, roughness_layers should be set to 8 in the project settings for best quality reflections"); - } - } - - if (sky_use_cubemap_array) { - //array (higher quality, 6 times more memory) - RD::TextureFormat tf; - tf.array_layers = layers * 6; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf.texture_type = RD::TEXTURE_TYPE_CUBE_ARRAY; - tf.mipmaps = mipmaps; - tf.width = w; - tf.height = h; - tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; - - sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); - - _update_reflection_data(sky->reflection, sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME); - - } else { - //regular cubemap, lower quality (aliasing, less memory) - RD::TextureFormat tf; - tf.array_layers = 6; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf.texture_type = RD::TEXTURE_TYPE_CUBE; - tf.mipmaps = MIN(mipmaps, layers); - tf.width = w; - tf.height = h; - tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; - - sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); - - _update_reflection_data(sky->reflection, sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME); - } - texture_set_dirty = true; - } - - // Create subpass buffers if they haven't been created already - if (sky->half_res_pass.is_null() && !RD::get_singleton()->texture_is_valid(sky->half_res_pass) && sky->screen_size.x >= 4 && sky->screen_size.y >= 4) { - RD::TextureFormat tformat; - tformat.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tformat.width = sky->screen_size.x / 2; - tformat.height = sky->screen_size.y / 2; - tformat.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - tformat.texture_type = RD::TEXTURE_TYPE_2D; - - sky->half_res_pass = RD::get_singleton()->texture_create(tformat, RD::TextureView()); - Vector<RID> texs; - texs.push_back(sky->half_res_pass); - sky->half_res_framebuffer = RD::get_singleton()->framebuffer_create(texs); - texture_set_dirty = true; - } - - if (sky->quarter_res_pass.is_null() && !RD::get_singleton()->texture_is_valid(sky->quarter_res_pass) && sky->screen_size.x >= 4 && sky->screen_size.y >= 4) { - RD::TextureFormat tformat; - tformat.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tformat.width = sky->screen_size.x / 4; - tformat.height = sky->screen_size.y / 4; - tformat.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - tformat.texture_type = RD::TEXTURE_TYPE_2D; - - sky->quarter_res_pass = RD::get_singleton()->texture_create(tformat, RD::TextureView()); - Vector<RID> texs; - texs.push_back(sky->quarter_res_pass); - sky->quarter_res_framebuffer = RD::get_singleton()->framebuffer_create(texs); - texture_set_dirty = true; - } - - if (texture_set_dirty) { - for (int i = 0; i < SKY_TEXTURE_SET_MAX; i++) { - if (sky->texture_uniform_sets[i].is_valid() && RD::get_singleton()->uniform_set_is_valid(sky->texture_uniform_sets[i])) { - RD::get_singleton()->free(sky->texture_uniform_sets[i]); - sky->texture_uniform_sets[i] = RID(); - } - } - } - - sky->reflection.dirty = true; - sky->processing_layer = 0; - - Sky *next = sky->dirty_list; - sky->dirty_list = nullptr; - sky->dirty = false; - sky = next; - } - - dirty_sky_list = nullptr; -} - -RID RendererSceneRenderRD::sky_get_radiance_texture_rd(RID p_sky) const { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND_V(!sky, RID()); - - return sky->radiance; -} - -RID RendererSceneRenderRD::sky_get_radiance_uniform_set_rd(RID p_sky, RID p_shader, int p_set) const { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND_V(!sky, RID()); - - if (sky->uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(sky->uniform_set)) { - sky->uniform_set = RID(); - if (sky->radiance.is_valid()) { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 0; - u.ids.push_back(sky->radiance); - uniforms.push_back(u); - } - - sky->uniform_set = RD::get_singleton()->uniform_set_create(uniforms, p_shader, p_set); - } - } - - return sky->uniform_set; -} - -RID RendererSceneRenderRD::_get_sky_textures(Sky *p_sky, SkyTextureSetVersion p_version) { - if (p_sky->texture_uniform_sets[p_version].is_valid() && RD::get_singleton()->uniform_set_is_valid(p_sky->texture_uniform_sets[p_version])) { - return p_sky->texture_uniform_sets[p_version]; - } - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 0; - if (p_sky->radiance.is_valid() && p_version <= SKY_TEXTURE_SET_QUARTER_RES) { - u.ids.push_back(p_sky->radiance); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 1; // half res - if (p_sky->half_res_pass.is_valid() && p_version != SKY_TEXTURE_SET_HALF_RES && p_version != SKY_TEXTURE_SET_CUBEMAP_HALF_RES) { - if (p_version >= SKY_TEXTURE_SET_CUBEMAP) { - u.ids.push_back(p_sky->reflection.layers[0].views[1]); - } else { - u.ids.push_back(p_sky->half_res_pass); - } - } else { - if (p_version < SKY_TEXTURE_SET_CUBEMAP) { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 2; // quarter res - if (p_sky->quarter_res_pass.is_valid() && p_version != SKY_TEXTURE_SET_QUARTER_RES && p_version != SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES) { - if (p_version >= SKY_TEXTURE_SET_CUBEMAP) { - u.ids.push_back(p_sky->reflection.layers[0].views[2]); - } else { - u.ids.push_back(p_sky->quarter_res_pass); - } - } else { - if (p_version < SKY_TEXTURE_SET_CUBEMAP) { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); - } - } - uniforms.push_back(u); - } - - p_sky->texture_uniform_sets[p_version] = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_TEXTURES); - return p_sky->texture_uniform_sets[p_version]; -} - -RID RendererSceneRenderRD::sky_get_material(RID p_sky) const { - Sky *sky = sky_owner.getornull(p_sky); - ERR_FAIL_COND_V(!sky, RID()); - - return sky->material; -} - -void RendererSceneRenderRD::_draw_sky(bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform) { - ERR_FAIL_COND(!is_environment(p_environment)); - - SkyMaterialData *material = nullptr; - - Sky *sky = sky_owner.getornull(environment_get_sky(p_environment)); - - RID sky_material; - - RS::EnvironmentBG background = environment_get_background(p_environment); - - if (!(background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) || sky) { - ERR_FAIL_COND(!sky); - sky_material = sky_get_material(environment_get_sky(p_environment)); - - if (sky_material.is_valid()) { - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - if (!material || !material->shader_data->valid) { - material = nullptr; - } - } - - if (!material) { - sky_material = sky_shader.default_material; - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - } - } - - if (background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) { - sky_material = sky_scene_state.fog_material; - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - } - - ERR_FAIL_COND(!material); - - SkyShaderData *shader_data = material->shader_data; - - ERR_FAIL_COND(!shader_data); - - Basis sky_transform = environment_get_sky_orientation(p_environment); - sky_transform.invert(); - - float multiplier = environment_get_bg_energy(p_environment); - float custom_fov = environment_get_sky_custom_fov(p_environment); - // Camera - CameraMatrix camera; - - if (custom_fov) { - float near_plane = p_projection.get_z_near(); - float far_plane = p_projection.get_z_far(); - float aspect = p_projection.get_aspect(); - - camera.set_perspective(custom_fov, aspect, near_plane, far_plane); - - } else { - camera = p_projection; - } - - sky_transform = p_transform.basis * sky_transform; - - if (shader_data->uses_quarter_res) { - PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_QUARTER_RES]; - - RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_QUARTER_RES); - - Vector<Color> clear_colors; - clear_colors.push_back(Color(0.0, 0.0, 0.0)); - - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(sky->quarter_res_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_DISCARD, clear_colors); - storage->get_effects()->render_sky(draw_list, time, sky->quarter_res_framebuffer, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); - RD::get_singleton()->draw_list_end(); - } - - if (shader_data->uses_half_res) { - PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_HALF_RES]; - - RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_HALF_RES); - - Vector<Color> clear_colors; - clear_colors.push_back(Color(0.0, 0.0, 0.0)); - - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(sky->half_res_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_DISCARD, clear_colors); - storage->get_effects()->render_sky(draw_list, time, sky->half_res_framebuffer, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); - RD::get_singleton()->draw_list_end(); - } - - PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_BACKGROUND]; - - RID texture_uniform_set; - if (sky) { - texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_BACKGROUND); - } else { - texture_uniform_set = sky_scene_state.fog_only_texture_uniform_set; - } - - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_fb, RD::INITIAL_ACTION_CONTINUE, p_can_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, p_can_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); - storage->get_effects()->render_sky(draw_list, time, p_fb, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); - RD::get_singleton()->draw_list_end(); -} - -void RendererSceneRenderRD::_setup_sky(RID p_environment, RID p_render_buffers, const CameraMatrix &p_projection, const Transform &p_transform, const Size2i p_screen_size) { - ERR_FAIL_COND(!is_environment(p_environment)); - - SkyMaterialData *material = nullptr; - - Sky *sky = sky_owner.getornull(environment_get_sky(p_environment)); - - RID sky_material; - - SkyShaderData *shader_data = nullptr; - - RS::EnvironmentBG background = environment_get_background(p_environment); - - if (!(background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) || sky) { - ERR_FAIL_COND(!sky); - sky_material = sky_get_material(environment_get_sky(p_environment)); - - if (sky_material.is_valid()) { - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - if (!material || !material->shader_data->valid) { - material = nullptr; - } - } - - if (!material) { - sky_material = sky_shader.default_material; - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - } - - ERR_FAIL_COND(!material); - - shader_data = material->shader_data; - - ERR_FAIL_COND(!shader_data); - } - - if (sky) { - // Invalidate supbass buffers if screen size changes - if (sky->screen_size != p_screen_size) { - sky->screen_size = p_screen_size; - sky->screen_size.x = sky->screen_size.x < 4 ? 4 : sky->screen_size.x; - sky->screen_size.y = sky->screen_size.y < 4 ? 4 : sky->screen_size.y; - if (shader_data->uses_half_res) { - if (sky->half_res_pass.is_valid()) { - RD::get_singleton()->free(sky->half_res_pass); - sky->half_res_pass = RID(); - } - _sky_invalidate(sky); - } - if (shader_data->uses_quarter_res) { - if (sky->quarter_res_pass.is_valid()) { - RD::get_singleton()->free(sky->quarter_res_pass); - sky->quarter_res_pass = RID(); - } - _sky_invalidate(sky); - } - } - - // Create new subpass buffers if necessary - if ((shader_data->uses_half_res && sky->half_res_pass.is_null()) || - (shader_data->uses_quarter_res && sky->quarter_res_pass.is_null()) || - sky->radiance.is_null()) { - _sky_invalidate(sky); - _update_dirty_skys(); - } - - if (shader_data->uses_time && time - sky->prev_time > 0.00001) { - sky->prev_time = time; - sky->reflection.dirty = true; - RenderingServerDefault::redraw_request(); - } - - if (material != sky->prev_material) { - sky->prev_material = material; - sky->reflection.dirty = true; - } - - if (material->uniform_set_updated) { - material->uniform_set_updated = false; - sky->reflection.dirty = true; - } - - if (!p_transform.origin.is_equal_approx(sky->prev_position) && shader_data->uses_position) { - sky->prev_position = p_transform.origin; - sky->reflection.dirty = true; - } - - if (shader_data->uses_light) { - // Check whether the directional_light_buffer changes - bool light_data_dirty = false; - - if (sky_scene_state.ubo.directional_light_count != sky_scene_state.last_frame_directional_light_count) { - light_data_dirty = true; - for (uint32_t i = sky_scene_state.ubo.directional_light_count; i < sky_scene_state.max_directional_lights; i++) { - sky_scene_state.directional_lights[i].enabled = false; - } - } - if (!light_data_dirty) { - for (uint32_t i = 0; i < sky_scene_state.ubo.directional_light_count; i++) { - if (sky_scene_state.directional_lights[i].direction[0] != sky_scene_state.last_frame_directional_lights[i].direction[0] || - sky_scene_state.directional_lights[i].direction[1] != sky_scene_state.last_frame_directional_lights[i].direction[1] || - sky_scene_state.directional_lights[i].direction[2] != sky_scene_state.last_frame_directional_lights[i].direction[2] || - sky_scene_state.directional_lights[i].energy != sky_scene_state.last_frame_directional_lights[i].energy || - sky_scene_state.directional_lights[i].color[0] != sky_scene_state.last_frame_directional_lights[i].color[0] || - sky_scene_state.directional_lights[i].color[1] != sky_scene_state.last_frame_directional_lights[i].color[1] || - sky_scene_state.directional_lights[i].color[2] != sky_scene_state.last_frame_directional_lights[i].color[2] || - sky_scene_state.directional_lights[i].enabled != sky_scene_state.last_frame_directional_lights[i].enabled || - sky_scene_state.directional_lights[i].size != sky_scene_state.last_frame_directional_lights[i].size) { - light_data_dirty = true; - break; - } - } - } - - if (light_data_dirty) { - RD::get_singleton()->buffer_update(sky_scene_state.directional_light_buffer, 0, sizeof(SkyDirectionalLightData) * sky_scene_state.max_directional_lights, sky_scene_state.directional_lights); - - RendererSceneRenderRD::SkyDirectionalLightData *temp = sky_scene_state.last_frame_directional_lights; - sky_scene_state.last_frame_directional_lights = sky_scene_state.directional_lights; - sky_scene_state.directional_lights = temp; - sky_scene_state.last_frame_directional_light_count = sky_scene_state.ubo.directional_light_count; - sky->reflection.dirty = true; - } - } - } - - //setup fog variables - sky_scene_state.ubo.volumetric_fog_enabled = false; - if (p_render_buffers.is_valid()) { - if (render_buffers_has_volumetric_fog(p_render_buffers)) { - sky_scene_state.ubo.volumetric_fog_enabled = true; - - float fog_end = render_buffers_get_volumetric_fog_end(p_render_buffers); - if (fog_end > 0.0) { - sky_scene_state.ubo.volumetric_fog_inv_length = 1.0 / fog_end; - } else { - sky_scene_state.ubo.volumetric_fog_inv_length = 1.0; - } - - float fog_detail_spread = render_buffers_get_volumetric_fog_detail_spread(p_render_buffers); //reverse lookup - if (fog_detail_spread > 0.0) { - sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0 / fog_detail_spread; - } else { - sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0; - } - } - - RID fog_uniform_set = render_buffers_get_volumetric_fog_sky_uniform_set(p_render_buffers); - - if (fog_uniform_set != RID()) { - sky_scene_state.fog_uniform_set = fog_uniform_set; - } else { - sky_scene_state.fog_uniform_set = sky_scene_state.default_fog_uniform_set; - } - } - - sky_scene_state.ubo.z_far = p_projection.get_z_far(); - sky_scene_state.ubo.fog_enabled = environment_is_fog_enabled(p_environment); - sky_scene_state.ubo.fog_density = environment_get_fog_density(p_environment); - sky_scene_state.ubo.fog_aerial_perspective = environment_get_fog_aerial_perspective(p_environment); - Color fog_color = environment_get_fog_light_color(p_environment).to_linear(); - float fog_energy = environment_get_fog_light_energy(p_environment); - sky_scene_state.ubo.fog_light_color[0] = fog_color.r * fog_energy; - sky_scene_state.ubo.fog_light_color[1] = fog_color.g * fog_energy; - sky_scene_state.ubo.fog_light_color[2] = fog_color.b * fog_energy; - sky_scene_state.ubo.fog_sun_scatter = environment_get_fog_sun_scatter(p_environment); - - RD::get_singleton()->buffer_update(sky_scene_state.uniform_buffer, 0, sizeof(SkySceneState::UBO), &sky_scene_state.ubo); -} - -void RendererSceneRenderRD::_update_sky(RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform) { - ERR_FAIL_COND(!is_environment(p_environment)); - - Sky *sky = sky_owner.getornull(environment_get_sky(p_environment)); - ERR_FAIL_COND(!sky); - - RID sky_material = sky_get_material(environment_get_sky(p_environment)); - - SkyMaterialData *material = nullptr; - - if (sky_material.is_valid()) { - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - if (!material || !material->shader_data->valid) { - material = nullptr; - } - } - - if (!material) { - sky_material = sky_shader.default_material; - material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); - } - - ERR_FAIL_COND(!material); - - SkyShaderData *shader_data = material->shader_data; - - ERR_FAIL_COND(!shader_data); - - float multiplier = environment_get_bg_energy(p_environment); - - bool update_single_frame = sky->mode == RS::SKY_MODE_REALTIME || sky->mode == RS::SKY_MODE_QUALITY; - RS::SkyMode sky_mode = sky->mode; - - if (sky_mode == RS::SKY_MODE_AUTOMATIC) { - if (shader_data->uses_time || shader_data->uses_position) { - update_single_frame = true; - sky_mode = RS::SKY_MODE_REALTIME; - } else if (shader_data->uses_light || shader_data->ubo_size > 0) { - update_single_frame = false; - sky_mode = RS::SKY_MODE_INCREMENTAL; - } else { - update_single_frame = true; - sky_mode = RS::SKY_MODE_QUALITY; - } - } - - if (sky->processing_layer == 0 && sky_mode == RS::SKY_MODE_INCREMENTAL) { - // On the first frame after creating sky, rebuild in single frame - update_single_frame = true; - sky_mode = RS::SKY_MODE_QUALITY; - } - - int max_processing_layer = sky_use_cubemap_array ? sky->reflection.layers.size() : sky->reflection.layers[0].mipmaps.size(); - - // Update radiance cubemap - if (sky->reflection.dirty && (sky->processing_layer >= max_processing_layer || update_single_frame)) { - static const Vector3 view_normals[6] = { - Vector3(+1, 0, 0), - Vector3(-1, 0, 0), - Vector3(0, +1, 0), - Vector3(0, -1, 0), - Vector3(0, 0, +1), - Vector3(0, 0, -1) - }; - static const Vector3 view_up[6] = { - Vector3(0, -1, 0), - Vector3(0, -1, 0), - Vector3(0, 0, +1), - Vector3(0, 0, -1), - Vector3(0, -1, 0), - Vector3(0, -1, 0) - }; - - CameraMatrix cm; - cm.set_perspective(90, 1, 0.01, 10.0); - CameraMatrix correction; - correction.set_depth_correction(true); - cm = correction * cm; - - if (shader_data->uses_quarter_res) { - PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_QUARTER_RES]; - - Vector<Color> clear_colors; - clear_colors.push_back(Color(0.0, 0.0, 0.0)); - RD::DrawListID cubemap_draw_list; - - for (int i = 0; i < 6; i++) { - Transform local_view; - local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); - RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES); - - cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[2].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); - storage->get_effects()->render_sky(cubemap_draw_list, time, sky->reflection.layers[0].mipmaps[2].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin); - RD::get_singleton()->draw_list_end(); - } - } - - if (shader_data->uses_half_res) { - PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_HALF_RES]; - - Vector<Color> clear_colors; - clear_colors.push_back(Color(0.0, 0.0, 0.0)); - RD::DrawListID cubemap_draw_list; - - for (int i = 0; i < 6; i++) { - Transform local_view; - local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); - RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_CUBEMAP_HALF_RES); - - cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[1].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); - storage->get_effects()->render_sky(cubemap_draw_list, time, sky->reflection.layers[0].mipmaps[1].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin); - RD::get_singleton()->draw_list_end(); - } - } - - RD::DrawListID cubemap_draw_list; - PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP]; - - for (int i = 0; i < 6; i++) { - Transform local_view; - local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); - RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_CUBEMAP); - - cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[0].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); - storage->get_effects()->render_sky(cubemap_draw_list, time, sky->reflection.layers[0].mipmaps[0].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin); - RD::get_singleton()->draw_list_end(); - } - - if (sky_mode == RS::SKY_MODE_REALTIME) { - _create_reflection_fast_filter(sky->reflection, sky_use_cubemap_array); - if (sky_use_cubemap_array) { - _update_reflection_mipmaps(sky->reflection, 0, sky->reflection.layers.size()); - } - } else { - if (update_single_frame) { - for (int i = 1; i < max_processing_layer; i++) { - _create_reflection_importance_sample(sky->reflection, sky_use_cubemap_array, 10, i); - } - if (sky_use_cubemap_array) { - _update_reflection_mipmaps(sky->reflection, 0, sky->reflection.layers.size()); - } - } else { - if (sky_use_cubemap_array) { - // Multi-Frame so just update the first array level - _update_reflection_mipmaps(sky->reflection, 0, 1); - } - } - sky->processing_layer = 1; - } - - sky->reflection.dirty = false; - - } else { - if (sky_mode == RS::SKY_MODE_INCREMENTAL && sky->processing_layer < max_processing_layer) { - _create_reflection_importance_sample(sky->reflection, sky_use_cubemap_array, 10, sky->processing_layer); - - if (sky_use_cubemap_array) { - _update_reflection_mipmaps(sky->reflection, sky->processing_layer, sky->processing_layer + 1); - } - - sky->processing_layer++; - } - } -} - -/* SKY SHADER */ - -void RendererSceneRenderRD::SkyShaderData::set_code(const String &p_code) { - //compile - - code = p_code; - valid = false; - ubo_size = 0; - uniforms.clear(); - - if (code == String()) { - return; //just invalid, but no error - } - - ShaderCompilerRD::GeneratedCode gen_code; - ShaderCompilerRD::IdentifierActions actions; - - uses_time = false; - uses_half_res = false; - uses_quarter_res = false; - uses_position = false; - uses_light = false; - - actions.render_mode_flags["use_half_res_pass"] = &uses_half_res; - actions.render_mode_flags["use_quarter_res_pass"] = &uses_quarter_res; - - actions.usage_flag_pointers["TIME"] = &uses_time; - actions.usage_flag_pointers["POSITION"] = &uses_position; - actions.usage_flag_pointers["LIGHT0_ENABLED"] = &uses_light; - actions.usage_flag_pointers["LIGHT0_ENERGY"] = &uses_light; - actions.usage_flag_pointers["LIGHT0_DIRECTION"] = &uses_light; - actions.usage_flag_pointers["LIGHT0_COLOR"] = &uses_light; - actions.usage_flag_pointers["LIGHT0_SIZE"] = &uses_light; - actions.usage_flag_pointers["LIGHT1_ENABLED"] = &uses_light; - actions.usage_flag_pointers["LIGHT1_ENERGY"] = &uses_light; - actions.usage_flag_pointers["LIGHT1_DIRECTION"] = &uses_light; - actions.usage_flag_pointers["LIGHT1_COLOR"] = &uses_light; - actions.usage_flag_pointers["LIGHT1_SIZE"] = &uses_light; - actions.usage_flag_pointers["LIGHT2_ENABLED"] = &uses_light; - actions.usage_flag_pointers["LIGHT2_ENERGY"] = &uses_light; - actions.usage_flag_pointers["LIGHT2_DIRECTION"] = &uses_light; - actions.usage_flag_pointers["LIGHT2_COLOR"] = &uses_light; - actions.usage_flag_pointers["LIGHT2_SIZE"] = &uses_light; - actions.usage_flag_pointers["LIGHT3_ENABLED"] = &uses_light; - actions.usage_flag_pointers["LIGHT3_ENERGY"] = &uses_light; - actions.usage_flag_pointers["LIGHT3_DIRECTION"] = &uses_light; - actions.usage_flag_pointers["LIGHT3_COLOR"] = &uses_light; - actions.usage_flag_pointers["LIGHT3_SIZE"] = &uses_light; - - actions.uniforms = &uniforms; - - RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; - - Error err = scene_singleton->sky_shader.compiler.compile(RS::SHADER_SKY, code, &actions, path, gen_code); - - ERR_FAIL_COND(err != OK); - - if (version.is_null()) { - version = scene_singleton->sky_shader.shader.version_create(); - } - -#if 0 - print_line("**compiling shader:"); - print_line("**defines:\n"); - for (int i = 0; i < gen_code.defines.size(); i++) { - print_line(gen_code.defines[i]); - } - print_line("\n**uniforms:\n" + gen_code.uniforms); - // print_line("\n**vertex_globals:\n" + gen_code.vertex_global); - // print_line("\n**vertex_code:\n" + gen_code.vertex); - print_line("\n**fragment_globals:\n" + gen_code.fragment_global); - print_line("\n**fragment_code:\n" + gen_code.fragment); - print_line("\n**light_code:\n" + gen_code.light); -#endif - - scene_singleton->sky_shader.shader.version_set_code(version, gen_code.uniforms, gen_code.vertex_global, gen_code.vertex, gen_code.fragment_global, gen_code.light, gen_code.fragment, gen_code.defines); - ERR_FAIL_COND(!scene_singleton->sky_shader.shader.version_is_valid(version)); - - ubo_size = gen_code.uniform_total_size; - ubo_offsets = gen_code.uniform_offsets; - texture_uniforms = gen_code.texture_uniforms; - - //update pipelines - - for (int i = 0; i < SKY_VERSION_MAX; i++) { - RD::PipelineDepthStencilState depth_stencil_state; - depth_stencil_state.enable_depth_test = true; - depth_stencil_state.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; - - RID shader_variant = scene_singleton->sky_shader.shader.version_get_shader(version, i); - pipelines[i].setup(shader_variant, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), depth_stencil_state, RD::PipelineColorBlendState::create_disabled(), 0); - } - - valid = true; -} - -void RendererSceneRenderRD::SkyShaderData::set_default_texture_param(const StringName &p_name, RID p_texture) { - if (!p_texture.is_valid()) { - default_texture_params.erase(p_name); - } else { - default_texture_params[p_name] = p_texture; - } -} - -void RendererSceneRenderRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; - - for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { - if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { - continue; - } - - if (E->get().texture_order >= 0) { - order[E->get().texture_order + 100000] = E->key(); - } else { - order[E->get().order] = E->key(); - } - } - - for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) { - PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]); - pi.name = E->get(); - p_param_list->push_back(pi); - } -} - -void RendererSceneRenderRD::SkyShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const { - for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { - if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { - continue; - } - - RendererStorage::InstanceShaderParam p; - p.info = ShaderLanguage::uniform_to_property_info(E->get()); - p.info.name = E->key(); //supply name - p.index = E->get().instance_index; - p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint); - p_param_list->push_back(p); - } -} - -bool RendererSceneRenderRD::SkyShaderData::is_param_texture(const StringName &p_param) const { - if (!uniforms.has(p_param)) { - return false; - } - - return uniforms[p_param].texture_order >= 0; -} - -bool RendererSceneRenderRD::SkyShaderData::is_animated() const { - return false; -} - -bool RendererSceneRenderRD::SkyShaderData::casts_shadows() const { - return false; -} - -Variant RendererSceneRenderRD::SkyShaderData::get_default_parameter(const StringName &p_parameter) const { - if (uniforms.has(p_parameter)) { - ShaderLanguage::ShaderNode::Uniform uniform = uniforms[p_parameter]; - Vector<ShaderLanguage::ConstantNode::Value> default_value = uniform.default_value; - return ShaderLanguage::constant_value_to_variant(default_value, uniform.type, uniform.hint); - } - return Variant(); -} - -RS::ShaderNativeSourceCode RendererSceneRenderRD::SkyShaderData::get_native_source_code() const { - RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; - - return scene_singleton->sky_shader.shader.version_get_native_source_code(version); -} - -RendererSceneRenderRD::SkyShaderData::SkyShaderData() { - valid = false; -} - -RendererSceneRenderRD::SkyShaderData::~SkyShaderData() { - RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; - ERR_FAIL_COND(!scene_singleton); - //pipeline variants will clear themselves if shader is gone - if (version.is_valid()) { - scene_singleton->sky_shader.shader.version_free(version); - } -} - -RendererStorageRD::ShaderData *RendererSceneRenderRD::_create_sky_shader_func() { - SkyShaderData *shader_data = memnew(SkyShaderData); - return shader_data; -} - -void RendererSceneRenderRD::SkyMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { - RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; - - uniform_set_updated = true; - - if ((uint32_t)ubo_data.size() != shader_data->ubo_size) { - p_uniform_dirty = true; - if (uniform_buffer.is_valid()) { - RD::get_singleton()->free(uniform_buffer); - uniform_buffer = RID(); - } - - ubo_data.resize(shader_data->ubo_size); - if (ubo_data.size()) { - uniform_buffer = RD::get_singleton()->uniform_buffer_create(ubo_data.size()); - memset(ubo_data.ptrw(), 0, ubo_data.size()); //clear - } - - //clear previous uniform set - if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { - RD::get_singleton()->free(uniform_set); - uniform_set = RID(); - } - } - - //check whether buffer changed - if (p_uniform_dirty && ubo_data.size()) { - update_uniform_buffer(shader_data->uniforms, shader_data->ubo_offsets.ptr(), p_parameters, ubo_data.ptrw(), ubo_data.size(), false); - RD::get_singleton()->buffer_update(uniform_buffer, 0, ubo_data.size(), ubo_data.ptrw()); - } - - uint32_t tex_uniform_count = shader_data->texture_uniforms.size(); - - if ((uint32_t)texture_cache.size() != tex_uniform_count) { - texture_cache.resize(tex_uniform_count); - p_textures_dirty = true; - - //clear previous uniform set - if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { - RD::get_singleton()->free(uniform_set); - uniform_set = RID(); - } - } - - if (p_textures_dirty && tex_uniform_count) { - update_textures(p_parameters, shader_data->default_texture_params, shader_data->texture_uniforms, texture_cache.ptrw(), true); - } - - if (shader_data->ubo_size == 0 && shader_data->texture_uniforms.size() == 0) { - // This material does not require an uniform set, so don't create it. - return; - } - - if (!p_textures_dirty && uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { - //no reason to update uniform set, only UBO (or nothing) was needed to update - return; - } - - Vector<RD::Uniform> uniforms; - - { - if (shader_data->ubo_size) { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 0; - u.ids.push_back(uniform_buffer); - uniforms.push_back(u); - } - - const RID *textures = texture_cache.ptrw(); - for (uint32_t i = 0; i < tex_uniform_count; i++) { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 1 + i; - u.ids.push_back(textures[i]); - uniforms.push_back(u); - } - } - - uniform_set = RD::get_singleton()->uniform_set_create(uniforms, scene_singleton->sky_shader.shader.version_get_shader(shader_data->version, 0), SKY_SET_MATERIAL); -} - -RendererSceneRenderRD::SkyMaterialData::~SkyMaterialData() { - if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { - RD::get_singleton()->free(uniform_set); - } - - if (uniform_buffer.is_valid()) { - RD::get_singleton()->free(uniform_buffer); - } -} - -RendererStorageRD::MaterialData *RendererSceneRenderRD::_create_sky_material_func(SkyShaderData *p_shader) { - SkyMaterialData *material_data = memnew(SkyMaterialData); - material_data->shader_data = p_shader; - material_data->last_frame = false; - //update will happen later anyway so do nothing. - return material_data; + return sky.sky_bake_panorama(p_sky, p_energy, p_bake_irradiance, p_size); } RID RendererSceneRenderRD::environment_allocate() { return environment_owner.allocate_rid(); } void RendererSceneRenderRD::environment_initialize(RID p_rid) { - environment_owner.initialize_rid(p_rid, Environment()); + environment_owner.initialize_rid(p_rid, RendererSceneEnvironmentRD()); } void RendererSceneRenderRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->background = p_bg; } void RendererSceneRenderRD::environment_set_sky(RID p_env, RID p_sky) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sky = p_sky; } void RendererSceneRenderRD::environment_set_sky_custom_fov(RID p_env, float p_scale) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sky_custom_fov = p_scale; } void RendererSceneRenderRD::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sky_orientation = p_orientation; } void RendererSceneRenderRD::environment_set_bg_color(RID p_env, const Color &p_color) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->bg_color = p_color; } void RendererSceneRenderRD::environment_set_bg_energy(RID p_env, float p_energy) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->bg_energy = p_energy; } void RendererSceneRenderRD::environment_set_canvas_max_layer(RID p_env, int p_max_layer) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->canvas_max_layer = p_max_layer; } void RendererSceneRenderRD::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - env->ambient_light = p_color; - env->ambient_source = p_ambient; - env->ambient_light_energy = p_energy; - env->ambient_sky_contribution = p_sky_contribution; - env->reflection_source = p_reflection_source; - env->ao_color = p_ao_color; + env->set_ambient_light(p_color, p_ambient, p_energy, p_sky_contribution, p_reflection_source, p_ao_color); } RS::EnvironmentBG RendererSceneRenderRD::environment_get_background(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX); return env->background; } RID RendererSceneRenderRD::environment_get_sky(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RID()); return env->sky; } float RendererSceneRenderRD::environment_get_sky_custom_fov(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->sky_custom_fov; } Basis RendererSceneRenderRD::environment_get_sky_orientation(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Basis()); return env->sky_orientation; } Color RendererSceneRenderRD::environment_get_bg_color(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->bg_color; } float RendererSceneRenderRD::environment_get_bg_energy(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->bg_energy; } int RendererSceneRenderRD::environment_get_canvas_max_layer(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->canvas_max_layer; } Color RendererSceneRenderRD::environment_get_ambient_light_color(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->ambient_light; } RS::EnvironmentAmbientSource RendererSceneRenderRD::environment_get_ambient_source(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG); return env->ambient_source; } float RendererSceneRenderRD::environment_get_ambient_light_energy(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->ambient_light_energy; } float RendererSceneRenderRD::environment_get_ambient_sky_contribution(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->ambient_sky_contribution; } RS::EnvironmentReflectionSource RendererSceneRenderRD::environment_get_reflection_source(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED); return env->reflection_source; } Color RendererSceneRenderRD::environment_get_ao_color(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->ao_color; } void RendererSceneRenderRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - env->exposure = p_exposure; - env->tone_mapper = p_tone_mapper; - if (!env->auto_exposure && p_auto_exposure) { - env->auto_exposure_version = ++auto_exposure_counter; - } - env->auto_exposure = p_auto_exposure; - env->white = p_white; - env->min_luminance = p_min_luminance; - env->max_luminance = p_max_luminance; - env->auto_exp_speed = p_auto_exp_speed; - env->auto_exp_scale = p_auto_exp_scale; + env->set_tonemap(p_tone_mapper, p_exposure, p_white, p_auto_exposure, p_min_luminance, p_max_luminance, p_auto_exp_speed, p_auto_exp_scale); } void RendererSceneRenderRD::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - ERR_FAIL_COND_MSG(p_levels.size() != 7, "Size of array of glow levels must be 7"); - env->glow_enabled = p_enable; - env->glow_levels = p_levels; - env->glow_intensity = p_intensity; - env->glow_strength = p_strength; - env->glow_mix = p_mix; - env->glow_bloom = p_bloom_threshold; - env->glow_blend_mode = p_blend_mode; - env->glow_hdr_bleed_threshold = p_hdr_bleed_threshold; - env->glow_hdr_bleed_scale = p_hdr_bleed_scale; - env->glow_hdr_luminance_cap = p_hdr_luminance_cap; + env->set_glow(p_enable, p_levels, p_intensity, p_strength, p_mix, p_bloom_threshold, p_blend_mode, p_hdr_bleed_threshold, p_hdr_bleed_scale, p_hdr_luminance_cap); } void RendererSceneRenderRD::environment_glow_set_use_bicubic_upscale(bool p_enable) { @@ -3088,100 +314,76 @@ void RendererSceneRenderRD::environment_glow_set_use_high_quality(bool p_enable) } void RendererSceneRenderRD::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); if (low_end) { return; } - env->sdfgi_enabled = p_enable; - env->sdfgi_cascades = p_cascades; - env->sdfgi_min_cell_size = p_min_cell_size; - env->sdfgi_use_occlusion = p_use_occlusion; - env->sdfgi_bounce_feedback = p_bounce_feedback; - env->sdfgi_read_sky_light = p_read_sky; - env->sdfgi_energy = p_energy; - env->sdfgi_normal_bias = p_normal_bias; - env->sdfgi_probe_bias = p_probe_bias; - env->sdfgi_y_scale = p_y_scale; + env->set_sdfgi(p_enable, p_cascades, p_min_cell_size, p_y_scale, p_use_occlusion, p_bounce_feedback, p_read_sky, p_energy, p_normal_bias, p_probe_bias); } void RendererSceneRenderRD::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); - env->fog_enabled = p_enable; - env->fog_light_color = p_light_color; - env->fog_light_energy = p_light_energy; - env->fog_sun_scatter = p_sun_scatter; - env->fog_density = p_density; - env->fog_height = p_height; - env->fog_height_density = p_height_density; - env->fog_aerial_perspective = p_fog_aerial_perspective; + env->set_fog(p_enable, p_light_color, p_light_energy, p_sun_scatter, p_density, p_height, p_height_density, p_fog_aerial_perspective); } bool RendererSceneRenderRD::environment_is_fog_enabled(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->fog_enabled; } Color RendererSceneRenderRD::environment_get_fog_light_color(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->fog_light_color; } float RendererSceneRenderRD::environment_get_fog_light_energy(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->fog_light_energy; } float RendererSceneRenderRD::environment_get_fog_sun_scatter(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->fog_sun_scatter; } float RendererSceneRenderRD::environment_get_fog_density(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->fog_density; } float RendererSceneRenderRD::environment_get_fog_height(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->fog_height; } float RendererSceneRenderRD::environment_get_fog_height_density(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->fog_height_density; } float RendererSceneRenderRD::environment_get_fog_aerial_perspective(RID p_env) const { - const Environment *env = environment_owner.getornull(p_env); + const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->fog_aerial_perspective; } void RendererSceneRenderRD::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); if (low_end) { return; } - env->volumetric_fog_enabled = p_enable; - env->volumetric_fog_density = p_density; - env->volumetric_fog_light = p_light; - env->volumetric_fog_light_energy = p_light_energy; - env->volumetric_fog_length = p_length; - env->volumetric_fog_detail_spread = p_detail_spread; - env->volumetric_fog_gi_inject = p_gi_inject; - env->volumetric_fog_temporal_reprojection = p_temporal_reprojection; - env->volumetric_fog_temporal_reprojection_amount = p_temporal_reprojection_amount; + env->set_volumetric_fog(p_enable, p_density, p_light, p_light_energy, p_length, p_detail_spread, p_gi_inject, p_temporal_reprojection, p_temporal_reprojection_amount); } void RendererSceneRenderRD::environment_set_volumetric_fog_volume_size(int p_size, int p_depth) { @@ -3194,29 +396,25 @@ void RendererSceneRenderRD::environment_set_volumetric_fog_filter_active(bool p_ } void RendererSceneRenderRD::environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) { - sdfgi_ray_count = p_ray_count; + gi.sdfgi_ray_count = p_ray_count; } void RendererSceneRenderRD::environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) { - sdfgi_frames_to_converge = p_frames; + gi.sdfgi_frames_to_converge = p_frames; } void RendererSceneRenderRD::environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) { - sdfgi_frames_to_update_light = p_update; + gi.sdfgi_frames_to_update_light = p_update; } void RendererSceneRenderRD::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); if (low_end) { return; } - env->ssr_enabled = p_enable; - env->ssr_max_steps = p_max_steps; - env->ssr_fade_in = p_fade_int; - env->ssr_fade_out = p_fade_out; - env->ssr_depth_tolerance = p_depth_tolerance; + env->set_ssr(p_enable, p_max_steps, p_fade_int, p_fade_out, p_depth_tolerance); } void RendererSceneRenderRD::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) { @@ -3228,22 +426,14 @@ RS::EnvironmentSSRRoughnessQuality RendererSceneRenderRD::environment_get_ssr_ro } void RendererSceneRenderRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); if (low_end) { return; } - env->ssao_enabled = p_enable; - env->ssao_radius = p_radius; - env->ssao_intensity = p_intensity; - env->ssao_power = p_power; - env->ssao_detail = p_detail; - env->ssao_horizon = p_horizon; - env->ssao_sharpness = p_sharpness; - env->ssao_direct_light_affect = p_light_affect; - env->ssao_ao_channel_affect = p_ao_channel_affect; + env->set_ssao(p_enable, p_radius, p_intensity, p_power, p_detail, p_horizon, p_sharpness, p_light_affect, p_ao_channel_affect); } void RendererSceneRenderRD::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) { @@ -3256,30 +446,30 @@ void RendererSceneRenderRD::environment_set_ssao_quality(RS::EnvironmentSSAOQual } bool RendererSceneRenderRD::environment_is_ssao_enabled(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->ssao_enabled; } float RendererSceneRenderRD::environment_get_ssao_ao_affect(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0.0); return env->ssao_ao_channel_affect; } float RendererSceneRenderRD::environment_get_ssao_light_affect(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0.0); return env->ssao_direct_light_affect; } bool RendererSceneRenderRD::environment_is_ssr_enabled(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->ssr_enabled; } bool RendererSceneRenderRD::environment_is_sdfgi_enabled(RID p_env) const { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->sdfgi_enabled; } @@ -3289,7 +479,7 @@ bool RendererSceneRenderRD::is_environment(RID p_env) const { } Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Ref<Image>()); if (env->background == RS::ENV_BG_CAMERA_FEED || env->background == RS::ENV_BG_CANVAS || env->background == RS::ENV_BG_KEEP) { @@ -3359,7 +549,7 @@ void RendererSceneRenderRD::reflection_atlas_set_size(RID p_ref_atlas, int p_ref RD::get_singleton()->free(ra->depth_buffer); ra->depth_buffer = RID(); for (int i = 0; i < ra->reflections.size(); i++) { - _clear_reflection_data(ra->reflections.write[i].data); + ra->reflections.write[i].data.clear_reflection_data(); if (ra->reflections[i].owner.is_null()) { continue; } @@ -3463,7 +653,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc } if (atlas->reflection.is_null()) { - int mipmaps = MIN(roughness_layers, Image::get_image_required_mipmaps(atlas->size, atlas->size, Image::FORMAT_RGBAH) + 1); + int mipmaps = MIN(sky.roughness_layers, Image::get_image_required_mipmaps(atlas->size, atlas->size, Image::FORMAT_RGBAH) + 1); mipmaps = storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS ? 8 : mipmaps; // always use 8 mipmaps with real time filtering { //reflection atlas was unused, create: @@ -3488,7 +678,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc } atlas->reflections.resize(atlas->count); for (int i = 0; i < atlas->count; i++) { - _update_reflection_data(atlas->reflections.write[i].data, atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS); + atlas->reflections.write[i].data.update_reflection_data(atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS, sky.roughness_layers); for (int j = 0; j < 6; j++) { Vector<RID> fb; fb.push_back(atlas->reflections.write[i].data.layers[0].mipmaps[0].views[j]); @@ -3548,7 +738,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_ins if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) { // Using real time reflections, all roughness is done in one step - _create_reflection_fast_filter(atlas->reflections.write[rpi->atlas_index].data, false); + atlas->reflections.write[rpi->atlas_index].data.create_reflection_fast_filter(storage, false); rpi->rendering = false; rpi->processing_side = 0; rpi->processing_layer = 1; @@ -3556,7 +746,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_ins } if (rpi->processing_layer > 1) { - _create_reflection_importance_sample(atlas->reflections.write[rpi->atlas_index].data, false, 10, rpi->processing_layer); + atlas->reflections.write[rpi->atlas_index].data.create_reflection_importance_sample(storage, false, 10, rpi->processing_layer, sky.sky_ggx_samples_quality); rpi->processing_layer++; if (rpi->processing_layer == atlas->reflections[rpi->atlas_index].data.layers[0].mipmaps.size()) { rpi->rendering = false; @@ -3567,7 +757,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_ins return false; } else { - _create_reflection_importance_sample(atlas->reflections.write[rpi->atlas_index].data, false, rpi->processing_side, rpi->processing_layer); + atlas->reflections.write[rpi->atlas_index].data.create_reflection_importance_sample(storage, false, rpi->processing_side, rpi->processing_layer, sky.sky_ggx_samples_quality); } rpi->processing_side++; @@ -4142,817 +1332,27 @@ void RendererSceneRenderRD::lightmap_instance_set_transform(RID p_lightmap, cons ///////////////////////////////// RID RendererSceneRenderRD::gi_probe_instance_create(RID p_base) { - GIProbeInstance gi_probe; - gi_probe.probe = p_base; - RID rid = gi_probe_instance_owner.make_rid(gi_probe); - return rid; + return gi.gi_probe_instance_create(p_base); } void RendererSceneRenderRD::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - ERR_FAIL_COND(!gi_probe); - - gi_probe->transform = p_xform; + gi.gi_probe_instance_set_transform_to_data(p_probe, p_xform); } bool RendererSceneRenderRD::gi_probe_needs_update(RID p_probe) const { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gi_probe, false); - if (low_end) { return false; } - //return true; - return gi_probe->last_probe_version != storage->gi_probe_get_version(gi_probe->probe); + return gi.gi_probe_needs_update(p_probe); } void RendererSceneRenderRD::gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<GeometryInstance *> &p_dynamic_objects) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - ERR_FAIL_COND(!gi_probe); - if (low_end) { return; } - uint32_t data_version = storage->gi_probe_get_data_version(gi_probe->probe); - - // (RE)CREATE IF NEEDED - - if (gi_probe->last_probe_data_version != data_version) { - //need to re-create everything - if (gi_probe->texture.is_valid()) { - RD::get_singleton()->free(gi_probe->texture); - RD::get_singleton()->free(gi_probe->write_buffer); - gi_probe->mipmaps.clear(); - } - - for (int i = 0; i < gi_probe->dynamic_maps.size(); i++) { - RD::get_singleton()->free(gi_probe->dynamic_maps[i].texture); - RD::get_singleton()->free(gi_probe->dynamic_maps[i].depth); - } - - gi_probe->dynamic_maps.clear(); - - Vector3i octree_size = storage->gi_probe_get_octree_size(gi_probe->probe); - - if (octree_size != Vector3i()) { - //can create a 3D texture - Vector<int> levels = storage->gi_probe_get_level_counts(gi_probe->probe); - - RD::TextureFormat tf; - tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; - tf.width = octree_size.x; - tf.height = octree_size.y; - tf.depth = octree_size.z; - tf.texture_type = RD::TEXTURE_TYPE_3D; - tf.mipmaps = levels.size(); - - tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; - - gi_probe->texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); - - RD::get_singleton()->texture_clear(gi_probe->texture, Color(0, 0, 0, 0), 0, levels.size(), 0, 1); - - { - int total_elements = 0; - for (int i = 0; i < levels.size(); i++) { - total_elements += levels[i]; - } - - gi_probe->write_buffer = RD::get_singleton()->storage_buffer_create(total_elements * 16); - } - - for (int i = 0; i < levels.size(); i++) { - GIProbeInstance::Mipmap mipmap; - mipmap.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), gi_probe->texture, 0, i, RD::TEXTURE_SLICE_3D); - mipmap.level = levels.size() - i - 1; - mipmap.cell_offset = 0; - for (uint32_t j = 0; j < mipmap.level; j++) { - mipmap.cell_offset += levels[j]; - } - mipmap.cell_count = levels[mipmap.level]; - - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 1; - u.ids.push_back(storage->gi_probe_get_octree_buffer(gi_probe->probe)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 2; - u.ids.push_back(storage->gi_probe_get_data_buffer(gi_probe->probe)); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 4; - u.ids.push_back(gi_probe->write_buffer); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 9; - u.ids.push_back(storage->gi_probe_get_sdf_texture(gi_probe->probe)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 10; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - { - Vector<RD::Uniform> copy_uniforms = uniforms; - if (i == 0) { - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 3; - u.ids.push_back(gi_probe_lights_uniform); - copy_uniforms.push_back(u); - } - - mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT], 0); - - copy_uniforms = uniforms; //restore - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 5; - u.ids.push_back(gi_probe->texture); - copy_uniforms.push_back(u); - } - mipmap.second_bounce_uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE], 0); - } else { - mipmap.uniform_set = RD::get_singleton()->uniform_set_create(copy_uniforms, giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP], 0); - } - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 5; - u.ids.push_back(mipmap.texture); - uniforms.push_back(u); - } - - mipmap.write_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE], 0); - - gi_probe->mipmaps.push_back(mipmap); - } - - { - uint32_t dynamic_map_size = MAX(MAX(octree_size.x, octree_size.y), octree_size.z); - uint32_t oversample = nearest_power_of_2_templated(4); - int mipmap_index = 0; - - while (mipmap_index < gi_probe->mipmaps.size()) { - GIProbeInstance::DynamicMap dmap; - - if (oversample > 0) { - dmap.size = dynamic_map_size * (1 << oversample); - dmap.mipmap = -1; - oversample--; - } else { - dmap.size = dynamic_map_size >> mipmap_index; - dmap.mipmap = mipmap_index; - mipmap_index++; - } - - RD::TextureFormat dtf; - dtf.width = dmap.size; - dtf.height = dmap.size; - dtf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT; - - if (gi_probe->dynamic_maps.size() == 0) { - dtf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - } - dmap.texture = RD::get_singleton()->texture_create(dtf, RD::TextureView()); - - if (gi_probe->dynamic_maps.size() == 0) { - //render depth for first one - dtf.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_D32_SFLOAT, RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ? RD::DATA_FORMAT_D32_SFLOAT : RD::DATA_FORMAT_X8_D24_UNORM_PACK32; - dtf.usage_bits = RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; - dmap.fb_depth = RD::get_singleton()->texture_create(dtf, RD::TextureView()); - } - - //just use depth as-is - dtf.format = RD::DATA_FORMAT_R32_SFLOAT; - dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - - dmap.depth = RD::get_singleton()->texture_create(dtf, RD::TextureView()); - - if (gi_probe->dynamic_maps.size() == 0) { - dtf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; - dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - dmap.albedo = RD::get_singleton()->texture_create(dtf, RD::TextureView()); - dmap.normal = RD::get_singleton()->texture_create(dtf, RD::TextureView()); - dmap.orm = RD::get_singleton()->texture_create(dtf, RD::TextureView()); - - Vector<RID> fb; - fb.push_back(dmap.albedo); - fb.push_back(dmap.normal); - fb.push_back(dmap.orm); - fb.push_back(dmap.texture); //emission - fb.push_back(dmap.depth); - fb.push_back(dmap.fb_depth); - - dmap.fb = RD::get_singleton()->framebuffer_create(fb); - - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 3; - u.ids.push_back(gi_probe_lights_uniform); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 5; - u.ids.push_back(dmap.albedo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 6; - u.ids.push_back(dmap.normal); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 7; - u.ids.push_back(dmap.orm); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 8; - u.ids.push_back(dmap.fb_depth); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 9; - u.ids.push_back(storage->gi_probe_get_sdf_texture(gi_probe->probe)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 10; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 11; - u.ids.push_back(dmap.texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 12; - u.ids.push_back(dmap.depth); - uniforms.push_back(u); - } - - dmap.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING], 0); - } - } else { - bool plot = dmap.mipmap >= 0; - bool write = dmap.mipmap < (gi_probe->mipmaps.size() - 1); - - Vector<RD::Uniform> uniforms; - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 5; - u.ids.push_back(gi_probe->dynamic_maps[gi_probe->dynamic_maps.size() - 1].texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 6; - u.ids.push_back(gi_probe->dynamic_maps[gi_probe->dynamic_maps.size() - 1].depth); - uniforms.push_back(u); - } - - if (write) { - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 7; - u.ids.push_back(dmap.texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 8; - u.ids.push_back(dmap.depth); - uniforms.push_back(u); - } - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 9; - u.ids.push_back(storage->gi_probe_get_sdf_texture(gi_probe->probe)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 10; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - if (plot) { - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.binding = 11; - u.ids.push_back(gi_probe->mipmaps[dmap.mipmap].texture); - uniforms.push_back(u); - } - } - - dmap.uniform_set = RD::get_singleton()->uniform_set_create( - uniforms, - giprobe_lighting_shader_version_shaders[(write && plot) ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT : (write ? GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE : GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT)], - 0); - } - - gi_probe->dynamic_maps.push_back(dmap); - } - } - } - - gi_probe->last_probe_data_version = data_version; - p_update_light_instances = true; //just in case - - _base_uniforms_changed(); - } - - // UDPDATE TIME - - if (gi_probe->has_dynamic_object_data) { - //if it has dynamic object data, it needs to be cleared - RD::get_singleton()->texture_clear(gi_probe->texture, Color(0, 0, 0, 0), 0, gi_probe->mipmaps.size(), 0, 1); - } - - uint32_t light_count = 0; - - if (p_update_light_instances || p_dynamic_objects.size() > 0) { - light_count = MIN(gi_probe_max_lights, (uint32_t)p_light_instances.size()); - - { - Transform to_cell = storage->gi_probe_get_to_cell_xform(gi_probe->probe); - Transform to_probe_xform = (gi_probe->transform * to_cell.affine_inverse()).affine_inverse(); - //update lights - - for (uint32_t i = 0; i < light_count; i++) { - GIProbeLight &l = gi_probe_lights[i]; - RID light_instance = p_light_instances[i]; - RID light = light_instance_get_base_light(light_instance); - - l.type = storage->light_get_type(light); - if (l.type == RS::LIGHT_DIRECTIONAL && storage->light_directional_is_sky_only(light)) { - light_count--; - continue; - } - - l.attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_ATTENUATION); - l.energy = storage->light_get_param(light, RS::LIGHT_PARAM_ENERGY) * storage->light_get_param(light, RS::LIGHT_PARAM_INDIRECT_ENERGY); - l.radius = to_cell.basis.xform(Vector3(storage->light_get_param(light, RS::LIGHT_PARAM_RANGE), 0, 0)).length(); - Color color = storage->light_get_color(light).to_linear(); - l.color[0] = color.r; - l.color[1] = color.g; - l.color[2] = color.b; - - l.cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ANGLE))); - l.inv_spot_attenuation = 1.0f / storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ATTENUATION); - - Transform xform = light_instance_get_base_transform(light_instance); - - Vector3 pos = to_probe_xform.xform(xform.origin); - Vector3 dir = to_probe_xform.basis.xform(-xform.basis.get_axis(2)).normalized(); - - l.position[0] = pos.x; - l.position[1] = pos.y; - l.position[2] = pos.z; - - l.direction[0] = dir.x; - l.direction[1] = dir.y; - l.direction[2] = dir.z; - - l.has_shadow = storage->light_has_shadow(light); - } - - RD::get_singleton()->buffer_update(gi_probe_lights_uniform, 0, sizeof(GIProbeLight) * light_count, gi_probe_lights); - } - } - - if (gi_probe->has_dynamic_object_data || p_update_light_instances || p_dynamic_objects.size()) { - // PROCESS MIPMAPS - if (gi_probe->mipmaps.size()) { - //can update mipmaps - - Vector3i probe_size = storage->gi_probe_get_octree_size(gi_probe->probe); - - GIProbePushConstant push_constant; - - push_constant.limits[0] = probe_size.x; - push_constant.limits[1] = probe_size.y; - push_constant.limits[2] = probe_size.z; - push_constant.stack_size = gi_probe->mipmaps.size(); - push_constant.emission_scale = 1.0; - push_constant.propagation = storage->gi_probe_get_propagation(gi_probe->probe); - push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(gi_probe->probe); - push_constant.light_count = light_count; - push_constant.aniso_strength = 0; - - /* print_line("probe update to version " + itos(gi_probe->last_probe_version)); - print_line("propagation " + rtos(push_constant.propagation)); - print_line("dynrange " + rtos(push_constant.dynamic_range)); - */ - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - - int passes; - if (p_update_light_instances) { - passes = storage->gi_probe_is_using_two_bounces(gi_probe->probe) ? 2 : 1; - } else { - passes = 1; //only re-blitting is necessary - } - int wg_size = 64; - int wg_limit_x = RD::get_singleton()->limit_get(RD::LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_X); - - for (int pass = 0; pass < passes; pass++) { - if (p_update_light_instances) { - for (int i = 0; i < gi_probe->mipmaps.size(); i++) { - if (i == 0) { - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[pass == 0 ? GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT : GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE]); - } else if (i == 1) { - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP]); - } - - if (pass == 1 || i > 0) { - RD::get_singleton()->compute_list_add_barrier(compute_list); //wait til previous step is done - } - if (pass == 0 || i > 0) { - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi_probe->mipmaps[i].uniform_set, 0); - } else { - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi_probe->mipmaps[i].second_bounce_uniform_set, 0); - } - - push_constant.cell_offset = gi_probe->mipmaps[i].cell_offset; - push_constant.cell_count = gi_probe->mipmaps[i].cell_count; - - int wg_todo = (gi_probe->mipmaps[i].cell_count - 1) / wg_size + 1; - while (wg_todo) { - int wg_count = MIN(wg_todo, wg_limit_x); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbePushConstant)); - RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1); - wg_todo -= wg_count; - push_constant.cell_offset += wg_count * wg_size; - } - } - - RD::get_singleton()->compute_list_add_barrier(compute_list); //wait til previous step is done - } - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE]); - - for (int i = 0; i < gi_probe->mipmaps.size(); i++) { - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi_probe->mipmaps[i].write_uniform_set, 0); - - push_constant.cell_offset = gi_probe->mipmaps[i].cell_offset; - push_constant.cell_count = gi_probe->mipmaps[i].cell_count; - - int wg_todo = (gi_probe->mipmaps[i].cell_count - 1) / wg_size + 1; - while (wg_todo) { - int wg_count = MIN(wg_todo, wg_limit_x); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbePushConstant)); - RD::get_singleton()->compute_list_dispatch(compute_list, wg_count, 1, 1); - wg_todo -= wg_count; - push_constant.cell_offset += wg_count * wg_size; - } - } - } - - RD::get_singleton()->compute_list_end(); - } - } - - gi_probe->has_dynamic_object_data = false; //clear until dynamic object data is used again - - if (p_dynamic_objects.size() && gi_probe->dynamic_maps.size()) { - Vector3i octree_size = storage->gi_probe_get_octree_size(gi_probe->probe); - int multiplier = gi_probe->dynamic_maps[0].size / MAX(MAX(octree_size.x, octree_size.y), octree_size.z); - - Transform oversample_scale; - oversample_scale.basis.scale(Vector3(multiplier, multiplier, multiplier)); - - Transform to_cell = oversample_scale * storage->gi_probe_get_to_cell_xform(gi_probe->probe); - Transform to_world_xform = gi_probe->transform * to_cell.affine_inverse(); - Transform to_probe_xform = to_world_xform.affine_inverse(); - - AABB probe_aabb(Vector3(), octree_size); - - //this could probably be better parallelized in compute.. - for (int i = 0; i < (int)p_dynamic_objects.size(); i++) { - GeometryInstance *instance = p_dynamic_objects[i]; - - //transform aabb to giprobe - AABB aabb = (to_probe_xform * geometry_instance_get_transform(instance)).xform(geometry_instance_get_aabb(instance)); - - //this needs to wrap to grid resolution to avoid jitter - //also extend margin a bit just in case - Vector3i begin = aabb.position - Vector3i(1, 1, 1); - Vector3i end = aabb.position + aabb.size + Vector3i(1, 1, 1); - - for (int j = 0; j < 3; j++) { - if ((end[j] - begin[j]) & 1) { - end[j]++; //for half extents split, it needs to be even - } - begin[j] = MAX(begin[j], 0); - end[j] = MIN(end[j], octree_size[j] * multiplier); - } - - //aabb = aabb.intersection(probe_aabb); //intersect - aabb.position = begin; - aabb.size = end - begin; - - //print_line("aabb: " + aabb); - - for (int j = 0; j < 6; j++) { - //if (j != 0 && j != 3) { - // continue; - //} - static const Vector3 render_z[6] = { - Vector3(1, 0, 0), - Vector3(0, 1, 0), - Vector3(0, 0, 1), - Vector3(-1, 0, 0), - Vector3(0, -1, 0), - Vector3(0, 0, -1), - }; - static const Vector3 render_up[6] = { - Vector3(0, 1, 0), - Vector3(0, 0, 1), - Vector3(0, 1, 0), - Vector3(0, 1, 0), - Vector3(0, 0, 1), - Vector3(0, 1, 0), - }; - - Vector3 render_dir = render_z[j]; - Vector3 up_dir = render_up[j]; - - Vector3 center = aabb.position + aabb.size * 0.5; - Transform xform; - xform.set_look_at(center - aabb.size * 0.5 * render_dir, center, up_dir); - - Vector3 x_dir = xform.basis.get_axis(0).abs(); - int x_axis = int(Vector3(0, 1, 2).dot(x_dir)); - Vector3 y_dir = xform.basis.get_axis(1).abs(); - int y_axis = int(Vector3(0, 1, 2).dot(y_dir)); - Vector3 z_dir = -xform.basis.get_axis(2); - int z_axis = int(Vector3(0, 1, 2).dot(z_dir.abs())); - - Rect2i rect(aabb.position[x_axis], aabb.position[y_axis], aabb.size[x_axis], aabb.size[y_axis]); - bool x_flip = bool(Vector3(1, 1, 1).dot(xform.basis.get_axis(0)) < 0); - bool y_flip = bool(Vector3(1, 1, 1).dot(xform.basis.get_axis(1)) < 0); - bool z_flip = bool(Vector3(1, 1, 1).dot(xform.basis.get_axis(2)) > 0); - - CameraMatrix cm; - cm.set_orthogonal(-rect.size.width / 2, rect.size.width / 2, -rect.size.height / 2, rect.size.height / 2, 0.0001, aabb.size[z_axis]); - - if (cull_argument.size() == 0) { - cull_argument.push_back(nullptr); - } - cull_argument[0] = instance; - - _render_material(to_world_xform * xform, cm, true, cull_argument, gi_probe->dynamic_maps[0].fb, Rect2i(Vector2i(), rect.size)); - - GIProbeDynamicPushConstant push_constant; - zeromem(&push_constant, sizeof(GIProbeDynamicPushConstant)); - push_constant.limits[0] = octree_size.x; - push_constant.limits[1] = octree_size.y; - push_constant.limits[2] = octree_size.z; - push_constant.light_count = p_light_instances.size(); - push_constant.x_dir[0] = x_dir[0]; - push_constant.x_dir[1] = x_dir[1]; - push_constant.x_dir[2] = x_dir[2]; - push_constant.y_dir[0] = y_dir[0]; - push_constant.y_dir[1] = y_dir[1]; - push_constant.y_dir[2] = y_dir[2]; - push_constant.z_dir[0] = z_dir[0]; - push_constant.z_dir[1] = z_dir[1]; - push_constant.z_dir[2] = z_dir[2]; - push_constant.z_base = xform.origin[z_axis]; - push_constant.z_sign = (z_flip ? -1.0 : 1.0); - push_constant.pos_multiplier = float(1.0) / multiplier; - push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(gi_probe->probe); - push_constant.flip_x = x_flip; - push_constant.flip_y = y_flip; - push_constant.rect_pos[0] = rect.position[0]; - push_constant.rect_pos[1] = rect.position[1]; - push_constant.rect_size[0] = rect.size[0]; - push_constant.rect_size[1] = rect.size[1]; - push_constant.prev_rect_ofs[0] = 0; - push_constant.prev_rect_ofs[1] = 0; - push_constant.prev_rect_size[0] = 0; - push_constant.prev_rect_size[1] = 0; - push_constant.on_mipmap = false; - push_constant.propagation = storage->gi_probe_get_propagation(gi_probe->probe); - push_constant.pad[0] = 0; - push_constant.pad[1] = 0; - push_constant.pad[2] = 0; - - //process lighting - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi_probe->dynamic_maps[0].uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbeDynamicPushConstant)); - RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1); - //print_line("rect: " + itos(i) + ": " + rect); - - for (int k = 1; k < gi_probe->dynamic_maps.size(); k++) { - // enlarge the rect if needed so all pixels fit when downscaled, - // this ensures downsampling is smooth and optimal because no pixels are left behind - - //x - if (rect.position.x & 1) { - rect.size.x++; - push_constant.prev_rect_ofs[0] = 1; //this is used to ensure reading is also optimal - } else { - push_constant.prev_rect_ofs[0] = 0; - } - if (rect.size.x & 1) { - rect.size.x++; - } - - rect.position.x >>= 1; - rect.size.x = MAX(1, rect.size.x >> 1); - - //y - if (rect.position.y & 1) { - rect.size.y++; - push_constant.prev_rect_ofs[1] = 1; - } else { - push_constant.prev_rect_ofs[1] = 0; - } - if (rect.size.y & 1) { - rect.size.y++; - } - - rect.position.y >>= 1; - rect.size.y = MAX(1, rect.size.y >> 1); - - //shrink limits to ensure plot does not go outside map - if (gi_probe->dynamic_maps[k].mipmap > 0) { - for (int l = 0; l < 3; l++) { - push_constant.limits[l] = MAX(1, push_constant.limits[l] >> 1); - } - } - - //print_line("rect: " + itos(i) + ": " + rect); - push_constant.rect_pos[0] = rect.position[0]; - push_constant.rect_pos[1] = rect.position[1]; - push_constant.prev_rect_size[0] = push_constant.rect_size[0]; - push_constant.prev_rect_size[1] = push_constant.rect_size[1]; - push_constant.rect_size[0] = rect.size[0]; - push_constant.rect_size[1] = rect.size[1]; - push_constant.on_mipmap = gi_probe->dynamic_maps[k].mipmap > 0; - - RD::get_singleton()->compute_list_add_barrier(compute_list); - - if (gi_probe->dynamic_maps[k].mipmap < 0) { - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE]); - } else if (k < gi_probe->dynamic_maps.size() - 1) { - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT]); - } else { - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT]); - } - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi_probe->dynamic_maps[k].uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(GIProbeDynamicPushConstant)); - RD::get_singleton()->compute_list_dispatch(compute_list, (rect.size.x - 1) / 8 + 1, (rect.size.y - 1) / 8 + 1, 1); - } - - RD::get_singleton()->compute_list_end(); - } - } - - gi_probe->has_dynamic_object_data = true; //clear until dynamic object data is used again - } - - gi_probe->last_probe_version = storage->gi_probe_get_version(gi_probe->probe); -} - -void RendererSceneRenderRD::_debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_gi_probe); - ERR_FAIL_COND(!gi_probe); - - if (gi_probe->mipmaps.size() == 0) { - return; - } - - CameraMatrix transform = (p_camera_with_transform * CameraMatrix(gi_probe->transform)) * CameraMatrix(storage->gi_probe_get_to_cell_xform(gi_probe->probe).affine_inverse()); - - int level = 0; - Vector3i octree_size = storage->gi_probe_get_octree_size(gi_probe->probe); - - GIProbeDebugPushConstant push_constant; - push_constant.alpha = p_alpha; - push_constant.dynamic_range = storage->gi_probe_get_dynamic_range(gi_probe->probe); - push_constant.cell_offset = gi_probe->mipmaps[level].cell_offset; - push_constant.level = level; - - push_constant.bounds[0] = octree_size.x >> level; - push_constant.bounds[1] = octree_size.y >> level; - push_constant.bounds[2] = octree_size.z >> level; - push_constant.pad = 0; - - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - push_constant.projection[i * 4 + j] = transform.matrix[i][j]; - } - } - - if (giprobe_debug_uniform_set.is_valid()) { - RD::get_singleton()->free(giprobe_debug_uniform_set); - } - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 1; - u.ids.push_back(storage->gi_probe_get_data_buffer(gi_probe->probe)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 2; - u.ids.push_back(gi_probe->texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 3; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - int cell_count; - if (!p_emission && p_lighting && gi_probe->has_dynamic_object_data) { - cell_count = push_constant.bounds[0] * push_constant.bounds[1] * push_constant.bounds[2]; - } else { - cell_count = gi_probe->mipmaps[level].cell_count; - } - - giprobe_debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, giprobe_debug_shader_version_shaders[0], 0); - - int giprobe_debug_pipeline = GI_PROBE_DEBUG_COLOR; - if (p_emission) { - giprobe_debug_pipeline = GI_PROBE_DEBUG_EMISSION; - } else if (p_lighting) { - giprobe_debug_pipeline = gi_probe->has_dynamic_object_data ? GI_PROBE_DEBUG_LIGHT_FULL : GI_PROBE_DEBUG_LIGHT; - } - RD::get_singleton()->draw_list_bind_render_pipeline( - p_draw_list, - giprobe_debug_shader_version_pipelines[giprobe_debug_pipeline].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); - RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, giprobe_debug_uniform_set, 0); - RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(GIProbeDebugPushConstant)); - RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, 36); + gi.gi_probe_update(p_probe, p_update_light_instances, p_light_instances, p_dynamic_objects, this); } void RendererSceneRenderRD::_debug_sdfgi_probes(RID p_render_buffers, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform) { @@ -4963,132 +1363,7 @@ void RendererSceneRenderRD::_debug_sdfgi_probes(RID p_render_buffers, RD::DrawLi return; //nothing to debug } - SDGIShader::DebugProbesPushConstant push_constant; - - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - push_constant.projection[i * 4 + j] = p_camera_with_transform.matrix[i][j]; - } - } - - //gen spheres from strips - uint32_t band_points = 16; - push_constant.band_power = 4; - push_constant.sections_in_band = ((band_points / 2) - 1); - push_constant.band_mask = band_points - 2; - push_constant.section_arc = Math_TAU / float(push_constant.sections_in_band); - push_constant.y_mult = rb->sdfgi->y_mult; - - uint32_t total_points = push_constant.sections_in_band * band_points; - uint32_t total_probes = rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count; - - push_constant.grid_size[0] = rb->sdfgi->cascade_size; - push_constant.grid_size[1] = rb->sdfgi->cascade_size; - push_constant.grid_size[2] = rb->sdfgi->cascade_size; - push_constant.cascade = 0; - - push_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - - if (!rb->sdfgi->debug_probes_uniform_set.is_valid() || !RD::get_singleton()->uniform_set_is_valid(rb->sdfgi->debug_probes_uniform_set)) { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.binding = 1; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.ids.push_back(rb->sdfgi->cascades_ubo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 2; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.ids.push_back(rb->sdfgi->lightprobe_texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 3; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 4; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.ids.push_back(rb->sdfgi->occlusion_texture); - uniforms.push_back(u); - } - - rb->sdfgi->debug_probes_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.debug_probes.version_get_shader(sdfgi_shader.debug_probes_shader, 0), 0); - } - - RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, sdfgi_shader.debug_probes_pipeline[SDGIShader::PROBE_DEBUG_PROBES].get_render_pipeline(RD::INVALID_FORMAT_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); - RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, rb->sdfgi->debug_probes_uniform_set, 0); - RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(SDGIShader::DebugProbesPushConstant)); - RD::get_singleton()->draw_list_draw(p_draw_list, false, total_probes, total_points); - - if (sdfgi_debug_probe_dir != Vector3()) { - print_line("CLICK DEBUG ME?"); - uint32_t cascade = 0; - Vector3 offset = Vector3((Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + rb->sdfgi->cascades[cascade].position)) * rb->sdfgi->cascades[cascade].cell_size * Vector3(1.0, 1.0 / rb->sdfgi->y_mult, 1.0); - Vector3 probe_size = rb->sdfgi->cascades[cascade].cell_size * (rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR) * Vector3(1.0, 1.0 / rb->sdfgi->y_mult, 1.0); - Vector3 ray_from = sdfgi_debug_probe_pos; - Vector3 ray_to = sdfgi_debug_probe_pos + sdfgi_debug_probe_dir * rb->sdfgi->cascades[cascade].cell_size * Math::sqrt(3.0) * rb->sdfgi->cascade_size; - float sphere_radius = 0.2; - float closest_dist = 1e20; - sdfgi_debug_probe_enabled = false; - - Vector3i probe_from = rb->sdfgi->cascades[cascade].position / (rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR); - for (int i = 0; i < (SDFGI::PROBE_DIVISOR + 1); i++) { - for (int j = 0; j < (SDFGI::PROBE_DIVISOR + 1); j++) { - for (int k = 0; k < (SDFGI::PROBE_DIVISOR + 1); k++) { - Vector3 pos = offset + probe_size * Vector3(i, j, k); - Vector3 res; - if (Geometry3D::segment_intersects_sphere(ray_from, ray_to, pos, sphere_radius, &res)) { - float d = ray_from.distance_to(res); - if (d < closest_dist) { - closest_dist = d; - sdfgi_debug_probe_enabled = true; - sdfgi_debug_probe_index = probe_from + Vector3i(i, j, k); - } - } - } - } - } - - if (sdfgi_debug_probe_enabled) { - print_line("found: " + sdfgi_debug_probe_index); - } else { - print_line("no found"); - } - sdfgi_debug_probe_dir = Vector3(); - } - - if (sdfgi_debug_probe_enabled) { - uint32_t cascade = 0; - uint32_t probe_cells = (rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR); - Vector3i probe_from = rb->sdfgi->cascades[cascade].position / probe_cells; - Vector3i ofs = sdfgi_debug_probe_index - probe_from; - if (ofs.x < 0 || ofs.y < 0 || ofs.z < 0) { - return; - } - if (ofs.x > SDFGI::PROBE_DIVISOR || ofs.y > SDFGI::PROBE_DIVISOR || ofs.z > SDFGI::PROBE_DIVISOR) { - return; - } - - uint32_t mult = (SDFGI::PROBE_DIVISOR + 1); - uint32_t index = ofs.z * mult * mult + ofs.y * mult + ofs.x; - - push_constant.probe_debug_index = index; - - uint32_t cell_count = probe_cells * 2 * probe_cells * 2 * probe_cells * 2; - - RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, sdfgi_shader.debug_probes_pipeline[SDGIShader::PROBE_DEBUG_VISIBILITY].get_render_pipeline(RD::INVALID_FORMAT_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer))); - RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, rb->sdfgi->debug_probes_uniform_set, 0); - RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(SDGIShader::DebugProbesPushConstant)); - RD::get_singleton()->draw_list_draw(p_draw_list, false, cell_count, total_points); - } + rb->sdfgi->debug_probes(p_draw_list, p_framebuffer, p_camera_with_transform); } //////////////////////////////// @@ -5277,7 +1552,7 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb return; } - Environment *env = environment_owner.getornull(p_environment); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment); ERR_FAIL_COND(!env); ERR_FAIL_COND(!env->ssr_enabled); @@ -5322,7 +1597,7 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(!rb); - Environment *env = environment_owner.getornull(p_environment); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment); ERR_FAIL_COND(!env); RENDER_TIMESTAMP("Process SSAO"); @@ -5468,7 +1743,7 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(RID p_rende RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(!rb); - Environment *env = environment_owner.getornull(p_environment); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment); //glow (if enabled) CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects); @@ -5661,7 +1936,7 @@ void RendererSceneRenderRD::_render_buffers_debug_draw(RID p_render_buffers, RID } void RendererSceneRenderRD::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) { - Environment *env = environment_owner.getornull(p_env); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->adjustments_enabled = p_enable; @@ -5672,152 +1947,6 @@ void RendererSceneRenderRD::environment_set_adjustment(RID p_env, bool p_enable, env->color_correction = p_color_correction; } -void RendererSceneRenderRD::_sdfgi_debug_draw(RID p_render_buffers, const CameraMatrix &p_projection, const Transform &p_transform) { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(!rb); - - if (!rb->sdfgi) { - return; //eh - } - - if (!rb->sdfgi->debug_uniform_set.is_valid() || !RD::get_singleton()->uniform_set_is_valid(rb->sdfgi->debug_uniform_set)) { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.binding = 1; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { - if (i < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[i].sdf_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 2; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { - if (i < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[i].light_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 3; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { - if (i < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[i].light_aniso_0_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 4; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - for (uint32_t i = 0; i < SDFGI::MAX_CASCADES; i++) { - if (i < rb->sdfgi->cascades.size()) { - u.ids.push_back(rb->sdfgi->cascades[i].light_aniso_1_tex); - } else { - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE)); - } - } - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 5; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.ids.push_back(rb->sdfgi->occlusion_texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 8; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 9; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.ids.push_back(rb->sdfgi->cascades_ubo); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 10; - u.uniform_type = RD::UNIFORM_TYPE_IMAGE; - u.ids.push_back(rb->texture); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.binding = 11; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.ids.push_back(rb->sdfgi->lightprobe_texture); - uniforms.push_back(u); - } - rb->sdfgi->debug_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.debug_shader_version, 0); - } - - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.debug_pipeline); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->debug_uniform_set, 0); - - SDGIShader::DebugPushConstant push_constant; - push_constant.grid_size[0] = rb->sdfgi->cascade_size; - push_constant.grid_size[1] = rb->sdfgi->cascade_size; - push_constant.grid_size[2] = rb->sdfgi->cascade_size; - push_constant.max_cascades = rb->sdfgi->cascades.size(); - push_constant.screen_size[0] = rb->width; - push_constant.screen_size[1] = rb->height; - push_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - push_constant.use_occlusion = rb->sdfgi->uses_occlusion; - push_constant.y_mult = rb->sdfgi->y_mult; - - Vector2 vp_half = p_projection.get_viewport_half_extents(); - push_constant.cam_extent[0] = vp_half.x; - push_constant.cam_extent[1] = vp_half.y; - push_constant.cam_extent[2] = -p_projection.get_z_near(); - - push_constant.cam_transform[0] = p_transform.basis.elements[0][0]; - push_constant.cam_transform[1] = p_transform.basis.elements[1][0]; - push_constant.cam_transform[2] = p_transform.basis.elements[2][0]; - push_constant.cam_transform[3] = 0; - push_constant.cam_transform[4] = p_transform.basis.elements[0][1]; - push_constant.cam_transform[5] = p_transform.basis.elements[1][1]; - push_constant.cam_transform[6] = p_transform.basis.elements[2][1]; - push_constant.cam_transform[7] = 0; - push_constant.cam_transform[8] = p_transform.basis.elements[0][2]; - push_constant.cam_transform[9] = p_transform.basis.elements[1][2]; - push_constant.cam_transform[10] = p_transform.basis.elements[2][2]; - push_constant.cam_transform[11] = 0; - push_constant.cam_transform[12] = p_transform.origin.x; - push_constant.cam_transform[13] = p_transform.origin.y; - push_constant.cam_transform[14] = p_transform.origin.z; - push_constant.cam_transform[15] = 1; - - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::DebugPushConstant)); - - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width, rb->height, 1); - RD::get_singleton()->compute_list_end(); - - Size2 rtsize = storage->render_target_get_size(rb->render_target); - storage->get_effects()->copy_to_fb_rect(rb->texture, storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize), true); -} - RID RendererSceneRenderRD::render_buffers_get_back_buffer_texture(RID p_render_buffers) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND_V(!rb, RID()); @@ -5837,14 +1966,14 @@ RID RendererSceneRenderRD::render_buffers_get_ao_texture(RID p_render_buffers) { RID RendererSceneRenderRD::render_buffers_get_gi_probe_buffer(RID p_render_buffers) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND_V(!rb, RID()); - if (rb->giprobe_buffer.is_null()) { - rb->giprobe_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(GI::GIProbeData) * RenderBuffers::MAX_GIPROBES); + if (rb->gi.giprobe_buffer.is_null()) { + rb->gi.giprobe_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(RendererSceneGIRD::GIProbeData) * RendererSceneGIRD::MAX_GIPROBES); } - return rb->giprobe_buffer; + return rb->gi.giprobe_buffer; } RID RendererSceneRenderRD::render_buffers_get_default_gi_probe_buffer() { - return default_giprobe_buffer; + return gi.default_giprobe_buffer; } RID RendererSceneRenderRD::render_buffers_get_gi_ambient_texture(RID p_render_buffers) { @@ -5893,7 +2022,7 @@ Vector3i RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_offset(RI ERR_FAIL_COND_V(!rb, Vector3i()); ERR_FAIL_COND_V(!rb->sdfgi, Vector3i()); ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), Vector3i()); - int32_t probe_divisor = rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; + int32_t probe_divisor = rb->sdfgi->cascade_size / RendererSceneGIRD::SDFGI::PROBE_DIVISOR; return rb->sdfgi->cascades[p_cascade].position / probe_divisor; } @@ -6142,11 +2271,11 @@ void RendererSceneRenderRD::directional_shadow_quality_set(RS::ShadowQuality p_q } int RendererSceneRenderRD::get_roughness_layers() const { - return roughness_layers; + return sky.roughness_layers; } bool RendererSceneRenderRD::is_using_radiance_cubemap_array() const { - return sky_use_cubemap_array; + return sky.sky_use_cubemap_array; } RendererSceneRenderRD::RenderBufferData *RendererSceneRenderRD::render_buffers_get_data(RID p_render_buffers) { @@ -6223,7 +2352,7 @@ void RendererSceneRenderRD::_setup_reflections(const PagedArray<RID> &p_reflecti } if (cluster.reflection_count) { - RD::get_singleton()->buffer_update(cluster.reflection_buffer, 0, cluster.reflection_count * sizeof(ReflectionData), cluster.reflections, RD::BARRIER_MASK_RASTER | RD::BARRIER_MASK_COMPUTE); + RD::get_singleton()->buffer_update(cluster.reflection_buffer, 0, cluster.reflection_count * sizeof(RendererSceneSkyRD::ReflectionData), cluster.reflections, RD::BARRIER_MASK_RASTER | RD::BARRIER_MASK_COMPUTE); } } @@ -6232,7 +2361,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const r_directional_light_count = 0; r_positional_light_count = 0; - sky_scene_state.ubo.directional_light_count = 0; + sky.sky_scene_state.ubo.directional_light_count = 0; Plane camera_plane(p_camera_transform.origin, -p_camera_transform.basis.get_axis(Vector3::AXIS_Z).normalized()); @@ -6252,8 +2381,8 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const switch (type) { case RS::LIGHT_DIRECTIONAL: { // Copy to SkyDirectionalLightData - if (r_directional_light_count < sky_scene_state.max_directional_lights) { - SkyDirectionalLightData &sky_light_data = sky_scene_state.directional_lights[r_directional_light_count]; + if (r_directional_light_count < sky.sky_scene_state.max_directional_lights) { + RendererSceneSkyRD::SkyDirectionalLightData &sky_light_data = sky.sky_scene_state.directional_lights[r_directional_light_count]; Transform light_transform = li->transform; Vector3 world_direction = light_transform.basis.xform(Vector3(0, 0, 1)).normalized(); @@ -6281,7 +2410,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const angular_diameter = 0.0; } sky_light_data.size = angular_diameter; - sky_scene_state.ubo.directional_light_count++; + sky.sky_scene_state.ubo.directional_light_count++; } if (r_directional_light_count >= cluster.max_directional_lights || storage->light_directional_is_sky_only(base)) { @@ -6816,7 +2945,7 @@ void RendererSceneRenderRD::_volumetric_fog_erase(RenderBuffers *rb) { void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_gi_probe_count) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(!rb); - Environment *env = environment_owner.getornull(p_environment); + RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment); float ratio = float(rb->width) / float((rb->width + rb->height) / 2); uint32_t target_width = uint32_t(float(volumetric_fog_size) * ratio); @@ -6873,7 +3002,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e uniforms.push_back(u); } - rb->volumetric_fog->sky_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_FOG); + rb->volumetric_fog->sky_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky.sky_shader.default_shader_rd, RendererSceneSkyRD::SKY_SET_FOG); } //update volumetric fog @@ -6984,8 +3113,8 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e RD::Uniform u; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; u.binding = 12; - for (int i = 0; i < RenderBuffers::MAX_GIPROBES; i++) { - u.ids.push_back(rb->giprobe_textures[i]); + for (int i = 0; i < RendererSceneGIRD::MAX_GIPROBES; i++) { + u.ids.push_back(rb->gi.giprobe_textures[i]); } uniforms.push_back(u); } @@ -7224,7 +3353,14 @@ bool RendererSceneRenderRD::_needs_post_prepass_render(bool p_use_gi) { void RendererSceneRenderRD::_post_prepass_render(bool p_use_gi) { if (render_state.render_buffers.is_valid()) { if (p_use_gi) { - _sdfgi_update_probes(render_state.render_buffers, render_state.environment); + RenderBuffers *rb = render_buffers_owner.getornull(render_state.render_buffers); + ERR_FAIL_COND(rb == nullptr); + if (rb->sdfgi == nullptr) { + return; + } + + RendererSceneEnvironmentRD *env = environment_owner.getornull(render_state.environment); + rb->sdfgi->update_probes(env, sky.sky_owner.getornull(env->sky)); } } } @@ -7241,7 +3377,13 @@ void RendererSceneRenderRD::_pre_opaque_render(bool p_use_ssao, bool p_use_gi, R // Render shadows while GI is rendering, due to how barriers are handled, this should happen at the same time if (render_state.render_buffers.is_valid() && p_use_gi) { - _sdfgi_store_probes(render_state.render_buffers); + RenderBuffers *rb = render_buffers_owner.getornull(render_state.render_buffers); + ERR_FAIL_COND(rb == nullptr); + if (rb->sdfgi == nullptr) { + return; + } + + rb->sdfgi->store_probes(); } render_state.cube_shadows.clear(); @@ -7308,7 +3450,7 @@ void RendererSceneRenderRD::_pre_opaque_render(bool p_use_ssao, bool p_use_gi, R //start GI if (render_gi) { - _process_gi(render_state.render_buffers, p_normal_roughness_buffer, p_gi_probe_buffer, render_state.environment, render_state.cam_projection, render_state.cam_transform, *render_state.gi_probes); + gi.process_gi(render_state.render_buffers, p_normal_roughness_buffer, p_gi_probe_buffer, render_state.environment, render_state.cam_projection, render_state.cam_transform, *render_state.gi_probes, this); } //Do shadow rendering (in parallel with GI) @@ -7368,6 +3510,13 @@ void RendererSceneRenderRD::_pre_opaque_render(bool p_use_ssao, bool p_use_gi, R } void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data) { + // getting this here now so we can direct call a bunch of things more easily + RenderBuffers *rb = nullptr; + if (p_render_buffers.is_valid()) { + rb = render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND(!rb); // !BAS! Do we fail here or skip the parts that won't work. can't really see a case why we would be rendering without buffers.... + } + //assign render data { render_state.render_buffers = p_render_buffers; @@ -7404,19 +3553,17 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform & } //sdfgi first - if (p_render_buffers.is_valid()) { + if (rb != nullptr && rb->sdfgi != nullptr) { for (int i = 0; i < render_state.render_sdfgi_region_count; i++) { - _render_sdfgi_region(p_render_buffers, render_state.render_sdfgi_regions[i].region, render_state.render_sdfgi_regions[i].instances); + rb->sdfgi->render_region(p_render_buffers, render_state.render_sdfgi_regions[i].region, render_state.render_sdfgi_regions[i].instances, this); } if (render_state.sdfgi_update_data->update_static) { - _render_sdfgi_static_lights(p_render_buffers, render_state.sdfgi_update_data->static_cascade_count, p_sdfgi_update_data->static_cascade_indices, render_state.sdfgi_update_data->static_positional_lights); + rb->sdfgi->render_static_lights(p_render_buffers, render_state.sdfgi_update_data->static_cascade_count, p_sdfgi_update_data->static_cascade_indices, render_state.sdfgi_update_data->static_positional_lights, this); } } Color clear_color; if (p_render_buffers.is_valid()) { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(!rb); clear_color = storage->render_target_get_clear_request_color(rb->render_target); } else { clear_color = storage->get_default_clear_color(); @@ -7424,15 +3571,15 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform & //assign render indices to giprobes for (uint32_t i = 0; i < (uint32_t)p_gi_probes.size(); i++) { - GIProbeInstance *giprobe_inst = gi_probe_instance_owner.getornull(p_gi_probes[i]); + RendererSceneGIRD::GIProbeInstance *giprobe_inst = gi.gi_probe_instance_owner.getornull(p_gi_probes[i]); if (giprobe_inst) { giprobe_inst->render_index = i; } } if (render_buffers_owner.owns(render_state.render_buffers)) { - RenderBuffers *rb = render_buffers_owner.getornull(render_state.render_buffers); - current_cluster_builder = rb->cluster_builder; + RenderBuffers *rs_rb = render_buffers_owner.getornull(render_state.render_buffers); + current_cluster_builder = rs_rb->cluster_builder; } else if (reflection_probe_instance_owner.owns(render_state.reflection_probe)) { ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(render_state.reflection_probe); ReflectionAtlas *ra = reflection_atlas_owner.getornull(rpi->atlas); @@ -7447,14 +3594,17 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform & current_cluster_builder = nullptr; } - if (p_render_buffers.is_valid()) { - _pre_process_gi(p_render_buffers, p_cam_transform); + if (rb != nullptr && rb->sdfgi != nullptr) { + rb->sdfgi->update_cascades(); + + rb->sdfgi->pre_process_gi(p_cam_transform, this); } render_state.gi_probe_count = 0; - if (render_state.render_buffers.is_valid()) { - _setup_giprobes(render_state.render_buffers, render_state.cam_transform, *render_state.gi_probes, render_state.gi_probe_count); - _sdfgi_update_light(render_state.render_buffers, render_state.environment); + if (rb != nullptr && rb->sdfgi != nullptr) { + gi.setup_giprobes(render_state.render_buffers, render_state.cam_transform, *render_state.gi_probes, render_state.gi_probe_count, this); + + rb->sdfgi->update_light(); } render_state.depth_prepass_used = false; @@ -7487,8 +3637,8 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const Transform & _render_buffers_post_process_and_tonemap(p_render_buffers, p_environment, p_camera_effects, p_cam_projection); _render_buffers_debug_draw(p_render_buffers, p_shadow_atlas); - if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SDFGI) { - _sdfgi_debug_draw(p_render_buffers, p_cam_projection, p_cam_transform); + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SDFGI && rb != nullptr && rb->sdfgi != nullptr) { + rb->sdfgi->debug_draw(p_cam_projection, p_cam_transform, rb->width, rb->height, rb->render_target, rb->texture); } } } @@ -7668,366 +3818,6 @@ void RendererSceneRenderRD::render_material(const Transform &p_cam_transform, co _render_material(p_cam_transform, p_cam_projection, p_cam_ortogonal, p_instances, p_framebuffer, p_region); } -void RendererSceneRenderRD::_render_sdfgi_region(RID p_render_buffers, int p_region, const PagedArray<GeometryInstance *> &p_instances) { - //print_line("rendering region " + itos(p_region)); - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(!rb); - ERR_FAIL_COND(!rb->sdfgi); - AABB bounds; - Vector3i from; - Vector3i size; - - int cascade_prev = _sdfgi_get_pending_region_data(p_render_buffers, p_region - 1, from, size, bounds); - int cascade_next = _sdfgi_get_pending_region_data(p_render_buffers, p_region + 1, from, size, bounds); - int cascade = _sdfgi_get_pending_region_data(p_render_buffers, p_region, from, size, bounds); - ERR_FAIL_COND(cascade < 0); - - if (cascade_prev != cascade) { - //initialize render - RD::get_singleton()->texture_clear(rb->sdfgi->render_albedo, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(rb->sdfgi->render_emission, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(rb->sdfgi->render_emission_aniso, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(rb->sdfgi->render_geom_facing, Color(0, 0, 0, 0), 0, 1, 0, 1); - } - - //print_line("rendering cascade " + itos(p_region) + " objects: " + itos(p_cull_count) + " bounds: " + bounds + " from: " + from + " size: " + size + " cell size: " + rtos(rb->sdfgi->cascades[cascade].cell_size)); - _render_sdfgi(p_render_buffers, from, size, bounds, p_instances, rb->sdfgi->render_albedo, rb->sdfgi->render_emission, rb->sdfgi->render_emission_aniso, rb->sdfgi->render_geom_facing); - - if (cascade_next != cascade) { - RD::get_singleton()->draw_command_begin_label("SDFGI Pre-Process Cascade"); - - RENDER_TIMESTAMP(">SDFGI Update SDF"); - //done rendering! must update SDF - //clear dispatch indirect data - - SDGIShader::PreprocessPushConstant push_constant; - zeromem(&push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - - RENDER_TIMESTAMP("Scroll SDF"); - - //scroll - if (rb->sdfgi->cascades[cascade].dirty_regions != SDFGI::Cascade::DIRTY_ALL) { - //for scroll - Vector3i dirty = rb->sdfgi->cascades[cascade].dirty_regions; - push_constant.scroll[0] = dirty.x; - push_constant.scroll[1] = dirty.y; - push_constant.scroll[2] = dirty.z; - } else { - //for no scroll - push_constant.scroll[0] = 0; - push_constant.scroll[1] = 0; - push_constant.scroll[2] = 0; - } - - rb->sdfgi->cascades[cascade].all_dynamic_lights_dirty = true; - - push_constant.grid_size = rb->sdfgi->cascade_size; - push_constant.cascade = cascade; - - if (rb->sdfgi->cascades[cascade].dirty_regions != SDFGI::Cascade::DIRTY_ALL) { - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - - //must pre scroll existing data because not all is dirty - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_SCROLL]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[cascade].scroll_uniform_set, 0); - - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_indirect(compute_list, rb->sdfgi->cascades[cascade].solid_cell_dispatch_buffer, 0); - // no barrier do all together - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_SCROLL_OCCLUSION]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[cascade].scroll_occlusion_uniform_set, 0); - - Vector3i dirty = rb->sdfgi->cascades[cascade].dirty_regions; - Vector3i groups; - groups.x = rb->sdfgi->cascade_size - ABS(dirty.x); - groups.y = rb->sdfgi->cascade_size - ABS(dirty.y); - groups.z = rb->sdfgi->cascade_size - ABS(dirty.z); - - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, groups.x, groups.y, groups.z); - - //no barrier, continue together - - { - //scroll probes and their history also - - SDGIShader::IntegratePushConstant ipush_constant; - ipush_constant.grid_size[1] = rb->sdfgi->cascade_size; - ipush_constant.grid_size[2] = rb->sdfgi->cascade_size; - ipush_constant.grid_size[0] = rb->sdfgi->cascade_size; - ipush_constant.max_cascades = rb->sdfgi->cascades.size(); - ipush_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - ipush_constant.history_index = 0; - ipush_constant.history_size = rb->sdfgi->history_size; - ipush_constant.ray_count = 0; - ipush_constant.ray_bias = 0; - ipush_constant.sky_mode = 0; - ipush_constant.sky_energy = 0; - ipush_constant.sky_color[0] = 0; - ipush_constant.sky_color[1] = 0; - ipush_constant.sky_color[2] = 0; - ipush_constant.y_mult = rb->sdfgi->y_mult; - ipush_constant.store_ambient_texture = false; - - ipush_constant.image_size[0] = rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count; - ipush_constant.image_size[1] = rb->sdfgi->probe_axis_count; - - int32_t probe_divisor = rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; - ipush_constant.cascade = cascade; - ipush_constant.world_offset[0] = rb->sdfgi->cascades[cascade].position.x / probe_divisor; - ipush_constant.world_offset[1] = rb->sdfgi->cascades[cascade].position.y / probe_divisor; - ipush_constant.world_offset[2] = rb->sdfgi->cascades[cascade].position.z / probe_divisor; - - ipush_constant.scroll[0] = dirty.x / probe_divisor; - ipush_constant.scroll[1] = dirty.y / probe_divisor; - ipush_constant.scroll[2] = dirty.z / probe_divisor; - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.integrate_pipeline[SDGIShader::INTEGRATE_MODE_SCROLL]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[cascade].integrate_uniform_set, 0); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdfgi_shader.integrate_default_sky_uniform_set, 1); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &ipush_constant, sizeof(SDGIShader::IntegratePushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count, rb->sdfgi->probe_axis_count, 1); - - RD::get_singleton()->compute_list_add_barrier(compute_list); - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.integrate_pipeline[SDGIShader::INTEGRATE_MODE_SCROLL_STORE]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[cascade].integrate_uniform_set, 0); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdfgi_shader.integrate_default_sky_uniform_set, 1); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &ipush_constant, sizeof(SDGIShader::IntegratePushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count, rb->sdfgi->probe_axis_count, 1); - - RD::get_singleton()->compute_list_add_barrier(compute_list); - - if (rb->sdfgi->bounce_feedback > 0.0) { - //multibounce requires this to be stored so direct light can read from it - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.integrate_pipeline[SDGIShader::INTEGRATE_MODE_STORE]); - - //convert to octahedral to store - ipush_constant.image_size[0] *= SDFGI::LIGHTPROBE_OCT_SIZE; - ipush_constant.image_size[1] *= SDFGI::LIGHTPROBE_OCT_SIZE; - - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[cascade].integrate_uniform_set, 0); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, sdfgi_shader.integrate_default_sky_uniform_set, 1); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &ipush_constant, sizeof(SDGIShader::IntegratePushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->probe_axis_count * rb->sdfgi->probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, rb->sdfgi->probe_axis_count * SDFGI::LIGHTPROBE_OCT_SIZE, 1); - } - } - - //ok finally barrier - RD::get_singleton()->compute_list_end(); - } - - //clear dispatch indirect data - uint32_t dispatch_indirct_data[4] = { 0, 0, 0, 0 }; - RD::get_singleton()->buffer_update(rb->sdfgi->cascades[cascade].solid_cell_dispatch_buffer, 0, sizeof(uint32_t) * 4, dispatch_indirct_data); - - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - - bool half_size = true; //much faster, very little difference - static const int optimized_jf_group_size = 8; - - if (half_size) { - push_constant.grid_size >>= 1; - - uint32_t cascade_half_size = rb->sdfgi->cascade_size >> 1; - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE_HALF]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->sdf_initialize_half_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_half_size, cascade_half_size, cascade_half_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - - //must start with regular jumpflood - - push_constant.half_size = true; - { - RENDER_TIMESTAMP("SDFGI Jump Flood (Half Size)"); - - uint32_t s = cascade_half_size; - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD]); - - int jf_us = 0; - //start with regular jump flood for very coarse reads, as this is impossible to optimize - while (s > 1) { - s /= 2; - push_constant.step_size = s; - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->jump_flood_half_uniform_set[jf_us], 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_half_size, cascade_half_size, cascade_half_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - jf_us = jf_us == 0 ? 1 : 0; - - if (cascade_half_size / (s / 2) >= optimized_jf_group_size) { - break; - } - } - - RENDER_TIMESTAMP("SDFGI Jump Flood Optimized (Half Size)"); - - //continue with optimized jump flood for smaller reads - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD_OPTIMIZED]); - while (s > 1) { - s /= 2; - push_constant.step_size = s; - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->jump_flood_half_uniform_set[jf_us], 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, cascade_half_size, cascade_half_size, cascade_half_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - jf_us = jf_us == 0 ? 1 : 0; - } - } - - // restore grid size for last passes - push_constant.grid_size = rb->sdfgi->cascade_size; - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD_UPSCALE]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->sdf_upscale_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - - //run one pass of fullsize jumpflood to fix up half size arctifacts - - push_constant.half_size = false; - push_constant.step_size = 1; - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD_OPTIMIZED]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->jump_flood_uniform_set[rb->sdfgi->upscale_jfa_uniform_set_index], 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - - } else { - //full size jumpflood - RENDER_TIMESTAMP("SDFGI Jump Flood"); - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD_INITIALIZE]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->sdf_initialize_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size); - - RD::get_singleton()->compute_list_add_barrier(compute_list); - - push_constant.half_size = false; - { - uint32_t s = rb->sdfgi->cascade_size; - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD]); - - int jf_us = 0; - //start with regular jump flood for very coarse reads, as this is impossible to optimize - while (s > 1) { - s /= 2; - push_constant.step_size = s; - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->jump_flood_uniform_set[jf_us], 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - jf_us = jf_us == 0 ? 1 : 0; - - if (rb->sdfgi->cascade_size / (s / 2) >= optimized_jf_group_size) { - break; - } - } - - RENDER_TIMESTAMP("SDFGI Jump Flood Optimized"); - - //continue with optimized jump flood for smaller reads - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_JUMP_FLOOD_OPTIMIZED]); - while (s > 1) { - s /= 2; - push_constant.step_size = s; - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->jump_flood_uniform_set[jf_us], 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size); - RD::get_singleton()->compute_list_add_barrier(compute_list); - jf_us = jf_us == 0 ? 1 : 0; - } - } - } - - RENDER_TIMESTAMP("SDFGI Occlusion"); - - // occlusion - { - uint32_t probe_size = rb->sdfgi->cascade_size / SDFGI::PROBE_DIVISOR; - Vector3i probe_global_pos = rb->sdfgi->cascades[cascade].position / probe_size; - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_OCCLUSION]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->occlusion_uniform_set, 0); - for (int i = 0; i < 8; i++) { - //dispatch all at once for performance - Vector3i offset(i & 1, (i >> 1) & 1, (i >> 2) & 1); - - if ((probe_global_pos.x & 1) != 0) { - offset.x = (offset.x + 1) & 1; - } - if ((probe_global_pos.y & 1) != 0) { - offset.y = (offset.y + 1) & 1; - } - if ((probe_global_pos.z & 1) != 0) { - offset.z = (offset.z + 1) & 1; - } - push_constant.probe_offset[0] = offset.x; - push_constant.probe_offset[1] = offset.y; - push_constant.probe_offset[2] = offset.z; - push_constant.occlusion_index = i; - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - - Vector3i groups = Vector3i(probe_size + 1, probe_size + 1, probe_size + 1) - offset; //if offset, it's one less probe per axis to compute - RD::get_singleton()->compute_list_dispatch(compute_list, groups.x, groups.y, groups.z); - } - RD::get_singleton()->compute_list_add_barrier(compute_list); - } - - RENDER_TIMESTAMP("SDFGI Store"); - - // store - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.preprocess_pipeline[SDGIShader::PRE_PROCESS_STORE]); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, rb->sdfgi->cascades[cascade].sdf_store_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDGIShader::PreprocessPushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, rb->sdfgi->cascade_size); - - RD::get_singleton()->compute_list_end(); - - //clear these textures, as they will have previous garbage on next draw - RD::get_singleton()->texture_clear(rb->sdfgi->cascades[cascade].light_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(rb->sdfgi->cascades[cascade].light_aniso_0_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); - RD::get_singleton()->texture_clear(rb->sdfgi->cascades[cascade].light_aniso_1_tex, Color(0, 0, 0, 0), 0, 1, 0, 1); - -#if 0 - Vector<uint8_t> data = RD::get_singleton()->texture_get_data(rb->sdfgi->cascades[cascade].sdf, 0); - Ref<Image> img; - img.instance(); - for (uint32_t i = 0; i < rb->sdfgi->cascade_size; i++) { - Vector<uint8_t> subarr = data.subarray(128 * 128 * i, 128 * 128 * (i + 1) - 1); - img->create(rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, false, Image::FORMAT_L8, subarr); - img->save_png("res://cascade_sdf_" + itos(cascade) + "_" + itos(i) + ".png"); - } - - //finalize render and update sdf -#endif - -#if 0 - Vector<uint8_t> data = RD::get_singleton()->texture_get_data(rb->sdfgi->render_albedo, 0); - Ref<Image> img; - img.instance(); - for (uint32_t i = 0; i < rb->sdfgi->cascade_size; i++) { - Vector<uint8_t> subarr = data.subarray(128 * 128 * i * 2, 128 * 128 * (i + 1) * 2 - 1); - img->create(rb->sdfgi->cascade_size, rb->sdfgi->cascade_size, false, Image::FORMAT_RGB565, subarr); - img->convert(Image::FORMAT_RGBA8); - img->save_png("res://cascade_" + itos(cascade) + "_" + itos(i) + ".png"); - } - - //finalize render and update sdf -#endif - - RENDER_TIMESTAMP("<SDFGI Update SDF"); - RD::get_singleton()->draw_command_end_label(); - } -} - void RendererSceneRenderRD::render_particle_collider_heightfield(RID p_collider, const Transform &p_transform, const PagedArray<GeometryInstance *> &p_instances) { ERR_FAIL_COND(!storage->particles_collision_is_heightfield(p_collider)); Vector3 extents = storage->particles_collision_get_extents(p_collider) * p_transform.basis.get_scale(); @@ -8045,133 +3835,15 @@ void RendererSceneRenderRD::render_particle_collider_heightfield(RID p_collider, _render_particle_collider_heightfield(fb, cam_xform, cm, p_instances); } -void RendererSceneRenderRD::_render_sdfgi_static_lights(RID p_render_buffers, uint32_t p_cascade_count, const uint32_t *p_cascade_indices, const PagedArray<RID> *p_positional_light_cull_result) { - RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND(!rb); - ERR_FAIL_COND(!rb->sdfgi); - - RD::get_singleton()->draw_command_begin_label("SDFGI Render Static Lighs"); - - _sdfgi_update_cascades(p_render_buffers); //need cascades updated for this - - SDGIShader::Light lights[SDFGI::MAX_STATIC_LIGHTS]; - uint32_t light_count[SDFGI::MAX_STATIC_LIGHTS]; - - for (uint32_t i = 0; i < p_cascade_count; i++) { - ERR_CONTINUE(p_cascade_indices[i] >= rb->sdfgi->cascades.size()); - - SDFGI::Cascade &cc = rb->sdfgi->cascades[p_cascade_indices[i]]; - - { //fill light buffer - - AABB cascade_aabb; - cascade_aabb.position = Vector3((Vector3i(1, 1, 1) * -int32_t(rb->sdfgi->cascade_size >> 1) + cc.position)) * cc.cell_size; - cascade_aabb.size = Vector3(1, 1, 1) * rb->sdfgi->cascade_size * cc.cell_size; - - int idx = 0; - - for (uint32_t j = 0; j < (uint32_t)p_positional_light_cull_result[i].size(); j++) { - if (idx == SDFGI::MAX_STATIC_LIGHTS) { - break; - } - - LightInstance *li = light_instance_owner.getornull(p_positional_light_cull_result[i][j]); - ERR_CONTINUE(!li); - - uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light); - if (p_cascade_indices[i] > max_sdfgi_cascade) { - continue; - } - - if (!cascade_aabb.intersects(li->aabb)) { - continue; - } - - lights[idx].type = storage->light_get_type(li->light); - - Vector3 dir = -li->transform.basis.get_axis(Vector3::AXIS_Z); - if (lights[idx].type == RS::LIGHT_DIRECTIONAL) { - dir.y *= rb->sdfgi->y_mult; //only makes sense for directional - dir.normalize(); - } - lights[idx].direction[0] = dir.x; - lights[idx].direction[1] = dir.y; - lights[idx].direction[2] = dir.z; - Vector3 pos = li->transform.origin; - pos.y *= rb->sdfgi->y_mult; - lights[idx].position[0] = pos.x; - lights[idx].position[1] = pos.y; - lights[idx].position[2] = pos.z; - Color color = storage->light_get_color(li->light); - color = color.to_linear(); - lights[idx].color[0] = color.r; - lights[idx].color[1] = color.g; - lights[idx].color[2] = color.b; - lights[idx].energy = storage->light_get_param(li->light, RS::LIGHT_PARAM_ENERGY); - lights[idx].has_shadow = storage->light_has_shadow(li->light); - lights[idx].attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_ATTENUATION); - lights[idx].radius = storage->light_get_param(li->light, RS::LIGHT_PARAM_RANGE); - lights[idx].cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE))); - lights[idx].inv_spot_attenuation = 1.0f / storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); - - idx++; - } - - if (idx > 0) { - RD::get_singleton()->buffer_update(cc.lights_buffer, 0, idx * sizeof(SDGIShader::Light), lights); - } - - light_count[i] = idx; - } - } - - /* Static Lights */ - RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, sdfgi_shader.direct_light_pipeline[SDGIShader::DIRECT_LIGHT_MODE_STATIC]); - - SDGIShader::DirectLightPushConstant dl_push_constant; - - dl_push_constant.grid_size[0] = rb->sdfgi->cascade_size; - dl_push_constant.grid_size[1] = rb->sdfgi->cascade_size; - dl_push_constant.grid_size[2] = rb->sdfgi->cascade_size; - dl_push_constant.max_cascades = rb->sdfgi->cascades.size(); - dl_push_constant.probe_axis_size = rb->sdfgi->probe_axis_count; - dl_push_constant.bounce_feedback = 0.0; // this is static light, do not multibounce yet - dl_push_constant.y_mult = rb->sdfgi->y_mult; - dl_push_constant.use_occlusion = rb->sdfgi->uses_occlusion; - - //all must be processed - dl_push_constant.process_offset = 0; - dl_push_constant.process_increment = 1; - - for (uint32_t i = 0; i < p_cascade_count; i++) { - ERR_CONTINUE(p_cascade_indices[i] >= rb->sdfgi->cascades.size()); - - SDFGI::Cascade &cc = rb->sdfgi->cascades[p_cascade_indices[i]]; - - dl_push_constant.light_count = light_count[i]; - dl_push_constant.cascade = p_cascade_indices[i]; - - if (dl_push_constant.light_count > 0) { - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cc.sdf_direct_light_uniform_set, 0); - RD::get_singleton()->compute_list_set_push_constant(compute_list, &dl_push_constant, sizeof(SDGIShader::DirectLightPushConstant)); - RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cc.solid_cell_dispatch_buffer, 0); - } - } - - RD::get_singleton()->compute_list_end(); - - RD::get_singleton()->draw_command_end_label(); -} - bool RendererSceneRenderRD::free(RID p_rid) { if (render_buffers_owner.owns(p_rid)) { RenderBuffers *rb = render_buffers_owner.getornull(p_rid); _free_render_buffer_data(rb); memdelete(rb->data); if (rb->sdfgi) { - _sdfgi_erase(rb); + rb->sdfgi->erase(); + memdelete(rb->sdfgi); + rb->sdfgi = nullptr; } if (rb->volumetric_fog) { _volumetric_fog_erase(rb); @@ -8202,8 +3874,8 @@ bool RendererSceneRenderRD::free(RID p_rid) { decal_instance_owner.free(p_rid); } else if (lightmap_instance_owner.owns(p_rid)) { lightmap_instance_owner.free(p_rid); - } else if (gi_probe_instance_owner.owns(p_rid)) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_rid); + } else if (gi.gi_probe_instance_owner.owns(p_rid)) { + RendererSceneGIRD::GIProbeInstance *gi_probe = gi.gi_probe_instance_owner.getornull(p_rid); if (gi_probe->texture.is_valid()) { RD::get_singleton()->free(gi_probe->texture); RD::get_singleton()->free(gi_probe->write_buffer); @@ -8214,37 +3886,10 @@ bool RendererSceneRenderRD::free(RID p_rid) { RD::get_singleton()->free(gi_probe->dynamic_maps[i].depth); } - gi_probe_instance_owner.free(p_rid); - } else if (sky_owner.owns(p_rid)) { - _update_dirty_skys(); - Sky *sky = sky_owner.getornull(p_rid); - - if (sky->radiance.is_valid()) { - RD::get_singleton()->free(sky->radiance); - sky->radiance = RID(); - } - _clear_reflection_data(sky->reflection); - - if (sky->uniform_buffer.is_valid()) { - RD::get_singleton()->free(sky->uniform_buffer); - sky->uniform_buffer = RID(); - } - - if (sky->half_res_pass.is_valid()) { - RD::get_singleton()->free(sky->half_res_pass); - sky->half_res_pass = RID(); - } - - if (sky->quarter_res_pass.is_valid()) { - RD::get_singleton()->free(sky->quarter_res_pass); - sky->quarter_res_pass = RID(); - } - - if (sky->material.is_valid()) { - storage->free(sky->material); - } - - sky_owner.free(p_rid); + gi.gi_probe_instance_owner.free(p_rid); + } else if (sky.sky_owner.owns(p_rid)) { + sky.update_dirty_skys(); + sky.free_sky(p_rid); } else if (light_instance_owner.owns(p_rid)) { LightInstance *light_instance = light_instance_owner.getornull(p_rid); @@ -8278,7 +3923,7 @@ void RendererSceneRenderRD::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_dr } void RendererSceneRenderRD::update() { - _update_dirty_skys(); + sky.update_dirty_skys(); } void RendererSceneRenderRD::set_time(double p_time, double p_step) { @@ -8404,8 +4049,8 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Vecto } void RendererSceneRenderRD::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) { - sdfgi_debug_probe_pos = p_position; - sdfgi_debug_probe_dir = p_dir; + gi.sdfgi_debug_probe_pos = p_position; + gi.sdfgi_debug_probe_dir = p_dir; } RendererSceneRenderRD *RendererSceneRenderRD::singleton = nullptr; @@ -8441,14 +4086,6 @@ RendererSceneRenderRD::RendererSceneRenderRD(RendererStorageRD *p_storage) { storage = p_storage; singleton = this; - roughness_layers = GLOBAL_GET("rendering/reflections/sky_reflections/roughness_layers"); - sky_ggx_samples_quality = GLOBAL_GET("rendering/reflections/sky_reflections/ggx_samples"); - sky_use_cubemap_array = GLOBAL_GET("rendering/reflections/sky_reflections/texture_array_reflections"); - - sdfgi_ray_count = RS::EnvironmentSDFGIRayCount(CLAMP(int32_t(GLOBAL_GET("rendering/global_illumination/sdfgi/probe_ray_count")), 0, int32_t(RS::ENV_SDFGI_RAY_COUNT_MAX - 1))); - sdfgi_frames_to_converge = RS::EnvironmentSDFGIFramesToConverge(CLAMP(int32_t(GLOBAL_GET("rendering/global_illumination/sdfgi/frames_to_converge")), 0, int32_t(RS::ENV_SDFGI_CONVERGE_MAX - 1))); - sdfgi_frames_to_update_light = RS::EnvironmentSDFGIFramesToUpdateLight(CLAMP(int32_t(GLOBAL_GET("rendering/global_illumination/sdfgi/frames_to_update_lights")), 0, int32_t(RS::ENV_SDFGI_UPDATE_LIGHT_MAX - 1))); - directional_shadow.size = GLOBAL_GET("rendering/shadows/directional_shadow/size"); directional_shadow.use_16_bits = GLOBAL_GET("rendering/shadows/directional_shadow/16_bits"); @@ -8460,389 +4097,14 @@ RendererSceneRenderRD::RendererSceneRenderRD(RendererStorageRD *p_storage) { low_end = true; } - if (!low_end) { - //kinda complicated to compute the amount of slots, we try to use as many as we can - - gi_probe_max_lights = 32; - - gi_probe_lights = memnew_arr(GIProbeLight, gi_probe_max_lights); - gi_probe_lights_uniform = RD::get_singleton()->uniform_buffer_create(gi_probe_max_lights * sizeof(GIProbeLight)); - gi_probe_quality = RS::GIProbeQuality(CLAMP(int(GLOBAL_GET("rendering/global_illumination/gi_probes/quality")), 0, 1)); - - String defines = "\n#define MAX_LIGHTS " + itos(gi_probe_max_lights) + "\n"; - - Vector<String> versions; - versions.push_back("\n#define MODE_COMPUTE_LIGHT\n"); - versions.push_back("\n#define MODE_SECOND_BOUNCE\n"); - versions.push_back("\n#define MODE_UPDATE_MIPMAPS\n"); - versions.push_back("\n#define MODE_WRITE_TEXTURE\n"); - versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_LIGHTING\n"); - versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_WRITE\n"); - versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n"); - versions.push_back("\n#define MODE_DYNAMIC\n#define MODE_DYNAMIC_SHRINK\n#define MODE_DYNAMIC_SHRINK_PLOT\n#define MODE_DYNAMIC_SHRINK_WRITE\n"); - - giprobe_shader.initialize(versions, defines); - giprobe_lighting_shader_version = giprobe_shader.version_create(); - for (int i = 0; i < GI_PROBE_SHADER_VERSION_MAX; i++) { - giprobe_lighting_shader_version_shaders[i] = giprobe_shader.version_get_shader(giprobe_lighting_shader_version, i); - giprobe_lighting_shader_version_pipelines[i] = RD::get_singleton()->compute_pipeline_create(giprobe_lighting_shader_version_shaders[i]); - } - } - - if (!low_end) { - String defines; - Vector<String> versions; - versions.push_back("\n#define MODE_DEBUG_COLOR\n"); - versions.push_back("\n#define MODE_DEBUG_LIGHT\n"); - versions.push_back("\n#define MODE_DEBUG_EMISSION\n"); - versions.push_back("\n#define MODE_DEBUG_LIGHT\n#define MODE_DEBUG_LIGHT_FULL\n"); - - giprobe_debug_shader.initialize(versions, defines); - giprobe_debug_shader_version = giprobe_debug_shader.version_create(); - for (int i = 0; i < GI_PROBE_DEBUG_MAX; i++) { - giprobe_debug_shader_version_shaders[i] = giprobe_debug_shader.version_get_shader(giprobe_debug_shader_version, i); - - RD::PipelineRasterizationState rs; - rs.cull_mode = RD::POLYGON_CULL_FRONT; - RD::PipelineDepthStencilState ds; - ds.enable_depth_test = true; - ds.enable_depth_write = true; - ds.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; - - giprobe_debug_shader_version_pipelines[i].setup(giprobe_debug_shader_version_shaders[i], RD::RENDER_PRIMITIVE_TRIANGLES, rs, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(), 0); - } - } - /* SKY SHADER */ - { - // Start with the directional lights for the sky - sky_scene_state.max_directional_lights = 4; - uint32_t directional_light_buffer_size = sky_scene_state.max_directional_lights * sizeof(SkyDirectionalLightData); - sky_scene_state.directional_lights = memnew_arr(SkyDirectionalLightData, sky_scene_state.max_directional_lights); - sky_scene_state.last_frame_directional_lights = memnew_arr(SkyDirectionalLightData, sky_scene_state.max_directional_lights); - sky_scene_state.last_frame_directional_light_count = sky_scene_state.max_directional_lights + 1; - sky_scene_state.directional_light_buffer = RD::get_singleton()->uniform_buffer_create(directional_light_buffer_size); - - String defines = "\n#define MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS " + itos(sky_scene_state.max_directional_lights) + "\n"; - - // Initialize sky - Vector<String> sky_modes; - sky_modes.push_back(""); // Full size - sky_modes.push_back("\n#define USE_HALF_RES_PASS\n"); // Half Res - sky_modes.push_back("\n#define USE_QUARTER_RES_PASS\n"); // Quarter res - sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n"); // Cubemap - sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n#define USE_HALF_RES_PASS\n"); // Half Res Cubemap - sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n#define USE_QUARTER_RES_PASS\n"); // Quarter res Cubemap - sky_shader.shader.initialize(sky_modes, defines); - } - - // register our shader funds - storage->shader_set_data_request_function(RendererStorageRD::SHADER_TYPE_SKY, _create_sky_shader_funcs); - storage->material_set_data_request_function(RendererStorageRD::SHADER_TYPE_SKY, _create_sky_material_funcs); - - { - ShaderCompilerRD::DefaultIdentifierActions actions; - - actions.renames["COLOR"] = "color"; - actions.renames["ALPHA"] = "alpha"; - actions.renames["EYEDIR"] = "cube_normal"; - actions.renames["POSITION"] = "params.position_multiplier.xyz"; - actions.renames["SKY_COORDS"] = "panorama_coords"; - actions.renames["SCREEN_UV"] = "uv"; - actions.renames["TIME"] = "params.time"; - actions.renames["HALF_RES_COLOR"] = "half_res_color"; - actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color"; - actions.renames["RADIANCE"] = "radiance"; - actions.renames["FOG"] = "custom_fog"; - actions.renames["LIGHT0_ENABLED"] = "directional_lights.data[0].enabled"; - actions.renames["LIGHT0_DIRECTION"] = "directional_lights.data[0].direction_energy.xyz"; - actions.renames["LIGHT0_ENERGY"] = "directional_lights.data[0].direction_energy.w"; - actions.renames["LIGHT0_COLOR"] = "directional_lights.data[0].color_size.xyz"; - actions.renames["LIGHT0_SIZE"] = "directional_lights.data[0].color_size.w"; - actions.renames["LIGHT1_ENABLED"] = "directional_lights.data[1].enabled"; - actions.renames["LIGHT1_DIRECTION"] = "directional_lights.data[1].direction_energy.xyz"; - actions.renames["LIGHT1_ENERGY"] = "directional_lights.data[1].direction_energy.w"; - actions.renames["LIGHT1_COLOR"] = "directional_lights.data[1].color_size.xyz"; - actions.renames["LIGHT1_SIZE"] = "directional_lights.data[1].color_size.w"; - actions.renames["LIGHT2_ENABLED"] = "directional_lights.data[2].enabled"; - actions.renames["LIGHT2_DIRECTION"] = "directional_lights.data[2].direction_energy.xyz"; - actions.renames["LIGHT2_ENERGY"] = "directional_lights.data[2].direction_energy.w"; - actions.renames["LIGHT2_COLOR"] = "directional_lights.data[2].color_size.xyz"; - actions.renames["LIGHT2_SIZE"] = "directional_lights.data[2].color_size.w"; - actions.renames["LIGHT3_ENABLED"] = "directional_lights.data[3].enabled"; - actions.renames["LIGHT3_DIRECTION"] = "directional_lights.data[3].direction_energy.xyz"; - actions.renames["LIGHT3_ENERGY"] = "directional_lights.data[3].direction_energy.w"; - actions.renames["LIGHT3_COLOR"] = "directional_lights.data[3].color_size.xyz"; - actions.renames["LIGHT3_SIZE"] = "directional_lights.data[3].color_size.w"; - actions.renames["AT_CUBEMAP_PASS"] = "AT_CUBEMAP_PASS"; - actions.renames["AT_HALF_RES_PASS"] = "AT_HALF_RES_PASS"; - actions.renames["AT_QUARTER_RES_PASS"] = "AT_QUARTER_RES_PASS"; - actions.custom_samplers["RADIANCE"] = "material_samplers[3]"; - actions.usage_defines["HALF_RES_COLOR"] = "\n#define USES_HALF_RES_COLOR\n"; - actions.usage_defines["QUARTER_RES_COLOR"] = "\n#define USES_QUARTER_RES_COLOR\n"; - actions.render_mode_defines["disable_fog"] = "#define DISABLE_FOG\n"; - - actions.sampler_array_name = "material_samplers"; - actions.base_texture_binding_index = 1; - actions.texture_layout_set = 1; - actions.base_uniform_string = "material."; - actions.base_varying_index = 10; - - actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP; - actions.default_repeat = ShaderLanguage::REPEAT_ENABLE; - actions.global_buffer_array_variable = "global_variables.data"; - - sky_shader.compiler.initialize(actions); - } - - { - // default material and shader for sky shader - sky_shader.default_shader = storage->shader_allocate(); - storage->shader_initialize(sky_shader.default_shader); + sky.init(storage); - storage->shader_set_code(sky_shader.default_shader, "shader_type sky; void fragment() { COLOR = vec3(0.0); } \n"); - - sky_shader.default_material = storage->material_allocate(); - storage->material_initialize(sky_shader.default_material); - - storage->material_set_shader(sky_shader.default_material, sky_shader.default_shader); - - SkyMaterialData *md = (SkyMaterialData *)storage->material_get_data(sky_shader.default_material, RendererStorageRD::SHADER_TYPE_SKY); - sky_shader.default_shader_rd = sky_shader.shader.version_get_shader(md->shader_data->version, SKY_VERSION_BACKGROUND); - - sky_scene_state.uniform_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(SkySceneState::UBO)); - - Vector<RD::Uniform> uniforms; - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 0; - u.ids.resize(12); - RID *ids_ptr = u.ids.ptrw(); - ids_ptr[0] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[1] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[2] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[3] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[4] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[5] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[6] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[7] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[8] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[9] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[10] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[11] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 1; - u.ids.push_back(storage->global_variables_get_storage_buffer()); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.binding = 2; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.ids.push_back(sky_scene_state.uniform_buffer); - uniforms.push_back(u); - } - - { - RD::Uniform u; - u.binding = 3; - u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.ids.push_back(sky_scene_state.directional_light_buffer); - uniforms.push_back(u); - } - - sky_scene_state.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_UNIFORMS); - } - - { - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.binding = 0; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - RID vfog = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); - u.ids.push_back(vfog); - uniforms.push_back(u); - } - - sky_scene_state.default_fog_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_FOG); - } - - { - // Need defaults for using fog with clear color - sky_scene_state.fog_shader = storage->shader_allocate(); - storage->shader_initialize(sky_scene_state.fog_shader); - - storage->shader_set_code(sky_scene_state.fog_shader, "shader_type sky; uniform vec4 clear_color; void fragment() { COLOR = clear_color.rgb; } \n"); - sky_scene_state.fog_material = storage->material_allocate(); - storage->material_initialize(sky_scene_state.fog_material); - - storage->material_set_shader(sky_scene_state.fog_material, sky_scene_state.fog_shader); - - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 0; - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 1; - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 2; - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); - uniforms.push_back(u); - } - - sky_scene_state.fog_only_texture_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_TEXTURES); - } + /* GI */ if (!low_end) { - //SDFGI - { - Vector<String> preprocess_modes; - preprocess_modes.push_back("\n#define MODE_SCROLL\n"); - preprocess_modes.push_back("\n#define MODE_SCROLL_OCCLUSION\n"); - preprocess_modes.push_back("\n#define MODE_INITIALIZE_JUMP_FLOOD\n"); - preprocess_modes.push_back("\n#define MODE_INITIALIZE_JUMP_FLOOD_HALF\n"); - preprocess_modes.push_back("\n#define MODE_JUMPFLOOD\n"); - preprocess_modes.push_back("\n#define MODE_JUMPFLOOD_OPTIMIZED\n"); - preprocess_modes.push_back("\n#define MODE_UPSCALE_JUMP_FLOOD\n"); - preprocess_modes.push_back("\n#define MODE_OCCLUSION\n"); - preprocess_modes.push_back("\n#define MODE_STORE\n"); - String defines = "\n#define OCCLUSION_SIZE " + itos(SDFGI::CASCADE_SIZE / SDFGI::PROBE_DIVISOR) + "\n"; - sdfgi_shader.preprocess.initialize(preprocess_modes, defines); - sdfgi_shader.preprocess_shader = sdfgi_shader.preprocess.version_create(); - for (int i = 0; i < SDGIShader::PRE_PROCESS_MAX; i++) { - sdfgi_shader.preprocess_pipeline[i] = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.preprocess.version_get_shader(sdfgi_shader.preprocess_shader, i)); - } - } - - { - //calculate tables - String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; - - Vector<String> direct_light_modes; - direct_light_modes.push_back("\n#define MODE_PROCESS_STATIC\n"); - direct_light_modes.push_back("\n#define MODE_PROCESS_DYNAMIC\n"); - sdfgi_shader.direct_light.initialize(direct_light_modes, defines); - sdfgi_shader.direct_light_shader = sdfgi_shader.direct_light.version_create(); - for (int i = 0; i < SDGIShader::DIRECT_LIGHT_MODE_MAX; i++) { - sdfgi_shader.direct_light_pipeline[i] = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.direct_light.version_get_shader(sdfgi_shader.direct_light_shader, i)); - } - } - - { - //calculate tables - String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; - defines += "\n#define SH_SIZE " + itos(SDFGI::SH_SIZE) + "\n"; - if (sky_use_cubemap_array) { - defines += "\n#define USE_CUBEMAP_ARRAY\n"; - } - - Vector<String> integrate_modes; - integrate_modes.push_back("\n#define MODE_PROCESS\n"); - integrate_modes.push_back("\n#define MODE_STORE\n"); - integrate_modes.push_back("\n#define MODE_SCROLL\n"); - integrate_modes.push_back("\n#define MODE_SCROLL_STORE\n"); - sdfgi_shader.integrate.initialize(integrate_modes, defines); - sdfgi_shader.integrate_shader = sdfgi_shader.integrate.version_create(); - - for (int i = 0; i < SDGIShader::INTEGRATE_MODE_MAX; i++) { - sdfgi_shader.integrate_pipeline[i] = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.integrate.version_get_shader(sdfgi_shader.integrate_shader, i)); - } - - { - Vector<RD::Uniform> uniforms; - - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; - u.binding = 0; - u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_WHITE)); - uniforms.push_back(u); - } - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; - u.binding = 1; - u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); - uniforms.push_back(u); - } - - sdfgi_shader.integrate_default_sky_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sdfgi_shader.integrate.version_get_shader(sdfgi_shader.integrate_shader, 0), 1); - } - } - //GK - { - //calculate tables - String defines = "\n#define SDFGI_OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; - Vector<String> gi_modes; - gi_modes.push_back("\n#define USE_GIPROBES\n"); - gi_modes.push_back("\n#define USE_SDFGI\n"); - gi_modes.push_back("\n#define USE_SDFGI\n\n#define USE_GIPROBES\n"); - gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_GIPROBES\n"); - gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n"); - gi_modes.push_back("\n#define MODE_HALF_RES\n#define USE_SDFGI\n\n#define USE_GIPROBES\n"); - - gi.shader.initialize(gi_modes, defines); - gi.shader_version = gi.shader.version_create(); - for (int i = 0; i < GI::MODE_MAX; i++) { - gi.pipelines[i] = RD::get_singleton()->compute_pipeline_create(gi.shader.version_get_shader(gi.shader_version, i)); - } - - gi.sdfgi_ubo = RD::get_singleton()->uniform_buffer_create(sizeof(GI::SDFGIData)); - } - { - String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; - Vector<String> debug_modes; - debug_modes.push_back(""); - sdfgi_shader.debug.initialize(debug_modes, defines); - sdfgi_shader.debug_shader = sdfgi_shader.debug.version_create(); - sdfgi_shader.debug_shader_version = sdfgi_shader.debug.version_get_shader(sdfgi_shader.debug_shader, 0); - sdfgi_shader.debug_pipeline = RD::get_singleton()->compute_pipeline_create(sdfgi_shader.debug_shader_version); - } - { - String defines = "\n#define OCT_SIZE " + itos(SDFGI::LIGHTPROBE_OCT_SIZE) + "\n"; - - Vector<String> versions; - versions.push_back("\n#define MODE_PROBES\n"); - versions.push_back("\n#define MODE_VISIBILITY\n"); - - sdfgi_shader.debug_probes.initialize(versions, defines); - sdfgi_shader.debug_probes_shader = sdfgi_shader.debug_probes.version_create(); - - { - RD::PipelineRasterizationState rs; - rs.cull_mode = RD::POLYGON_CULL_DISABLED; - RD::PipelineDepthStencilState ds; - ds.enable_depth_test = true; - ds.enable_depth_write = true; - ds.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; - for (int i = 0; i < SDGIShader::PROBE_DEBUG_MAX; i++) { - RID debug_probes_shader_version = sdfgi_shader.debug_probes.version_get_shader(sdfgi_shader.debug_probes_shader, i); - sdfgi_shader.debug_probes_pipeline[i].setup(debug_probes_shader_version, RD::RENDER_PRIMITIVE_TRIANGLE_STRIPS, rs, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(), 0); - } - } - } - default_giprobe_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(GI::GIProbeData) * RenderBuffers::MAX_GIPROBES); + gi.init(storage, &sky); } { //decals @@ -8935,40 +4197,27 @@ RendererSceneRenderRD::~RendererSceneRenderRD() { RD::get_singleton()->free(E->get().cubemap); } - if (sky_scene_state.uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sky_scene_state.uniform_set)) { - RD::get_singleton()->free(sky_scene_state.uniform_set); + if (sky.sky_scene_state.uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sky.sky_scene_state.uniform_set)) { + RD::get_singleton()->free(sky.sky_scene_state.uniform_set); } if (!low_end) { - RD::get_singleton()->free(default_giprobe_buffer); - RD::get_singleton()->free(gi_probe_lights_uniform); - RD::get_singleton()->free(gi.sdfgi_ubo); - - giprobe_debug_shader.version_free(giprobe_debug_shader_version); - giprobe_shader.version_free(giprobe_lighting_shader_version); - gi.shader.version_free(gi.shader_version); - sdfgi_shader.debug_probes.version_free(sdfgi_shader.debug_probes_shader); - sdfgi_shader.debug.version_free(sdfgi_shader.debug_shader); - sdfgi_shader.direct_light.version_free(sdfgi_shader.direct_light_shader); - sdfgi_shader.integrate.version_free(sdfgi_shader.integrate_shader); - sdfgi_shader.preprocess.version_free(sdfgi_shader.preprocess_shader); + gi.free(); volumetric_fog.shader.version_free(volumetric_fog.shader_version); RD::get_singleton()->free(volumetric_fog.params_ubo); - - memdelete_arr(gi_probe_lights); } - SkyMaterialData *md = (SkyMaterialData *)storage->material_get_data(sky_shader.default_material, RendererStorageRD::SHADER_TYPE_SKY); - sky_shader.shader.version_free(md->shader_data->version); - RD::get_singleton()->free(sky_scene_state.directional_light_buffer); - RD::get_singleton()->free(sky_scene_state.uniform_buffer); - memdelete_arr(sky_scene_state.directional_lights); - memdelete_arr(sky_scene_state.last_frame_directional_lights); - storage->free(sky_shader.default_shader); - storage->free(sky_shader.default_material); - storage->free(sky_scene_state.fog_shader); - storage->free(sky_scene_state.fog_material); + RendererSceneSkyRD::SkyMaterialData *md = (RendererSceneSkyRD::SkyMaterialData *)storage->material_get_data(sky.sky_shader.default_material, RendererStorageRD::SHADER_TYPE_SKY); + sky.sky_shader.shader.version_free(md->shader_data->version); + RD::get_singleton()->free(sky.sky_scene_state.directional_light_buffer); + RD::get_singleton()->free(sky.sky_scene_state.uniform_buffer); + memdelete_arr(sky.sky_scene_state.directional_lights); + memdelete_arr(sky.sky_scene_state.last_frame_directional_lights); + storage->free(sky.sky_shader.default_shader); + storage->free(sky.sky_shader.default_material); + storage->free(sky.sky_scene_state.fog_shader); + storage->free(sky.sky_scene_state.fog_material); memdelete_arr(directional_penumbra_shadow_kernel); memdelete_arr(directional_soft_shadow_kernel); memdelete_arr(penumbra_shadow_kernel); diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index e4eaa93212..001cfeb74d 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -35,68 +35,22 @@ #include "core/templates/rid_owner.h" #include "servers/rendering/renderer_compositor.h" #include "servers/rendering/renderer_rd/cluster_builder_rd.h" +#include "servers/rendering/renderer_rd/renderer_scene_environment_rd.h" +#include "servers/rendering/renderer_rd/renderer_scene_gi_rd.h" +#include "servers/rendering/renderer_rd/renderer_scene_sky_rd.h" #include "servers/rendering/renderer_rd/renderer_storage_rd.h" -#include "servers/rendering/renderer_rd/shaders/gi.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/giprobe.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/giprobe_debug.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/sdfgi_debug.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/sdfgi_debug_probes.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl.gen.h" -#include "servers/rendering/renderer_rd/shaders/sky.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/volumetric_fog.glsl.gen.h" #include "servers/rendering/renderer_scene_render.h" #include "servers/rendering/rendering_device.h" class RendererSceneRenderRD : public RendererSceneRender { + friend RendererSceneSkyRD; + friend RendererSceneGIRD; + protected: + RendererStorageRD *storage; double time; - - // Skys need less info from Directional Lights than the normal shaders - struct SkyDirectionalLightData { - float direction[3]; - float energy; - float color[3]; - float size; - uint32_t enabled; - uint32_t pad[3]; - }; - - struct SkySceneState { - struct UBO { - uint32_t volumetric_fog_enabled; - float volumetric_fog_inv_length; - float volumetric_fog_detail_spread; - - float fog_aerial_perspective; - - float fog_light_color[3]; - float fog_sun_scatter; - - uint32_t fog_enabled; - float fog_density; - - float z_far; - uint32_t directional_light_count; - }; - - UBO ubo; - - SkyDirectionalLightData *directional_lights; - SkyDirectionalLightData *last_frame_directional_lights; - uint32_t max_directional_lights; - uint32_t last_frame_directional_light_count; - RID directional_light_buffer; - RID uniform_set; - RID uniform_buffer; - RID fog_uniform_set; - RID default_fog_uniform_set; - - RID fog_shader; - RID fog_material; - RID fog_only_texture_uniform_set; - } sky_scene_state; + double time_step = 0; struct RenderBufferData { virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) = 0; @@ -107,7 +61,6 @@ protected: void _setup_lights(const PagedArray<RID> &p_lights, const Transform &p_camera_transform, RID p_shadow_atlas, bool p_using_shadows, uint32_t &r_directional_light_count, uint32_t &r_positional_light_count); void _setup_decals(const PagedArray<RID> &p_decals, const Transform &p_camera_inverse_xform); void _setup_reflections(const PagedArray<RID> &p_reflections, const Transform &p_camera_inverse_transform, RID p_environment); - void _setup_giprobes(RID p_render_buffers, const Transform &p_transform, const PagedArray<RID> &p_gi_probes, uint32_t &r_gi_probes_used); virtual void _render_scene(RID p_render_buffer, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_gi_probes, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_cluster_buffer, uint32_t p_cluster_size, uint32_t p_cluster_max_elements, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, const Color &p_default_color, float p_screen_lod_threshold) = 0; @@ -121,7 +74,6 @@ protected: virtual void _render_sdfgi(RID p_render_buffers, const Vector3i &p_from, const Vector3i &p_size, const AABB &p_bounds, const PagedArray<GeometryInstance *> &p_instances, const RID &p_albedo_texture, const RID &p_emission_texture, const RID &p_emission_aniso_texture, const RID &p_geom_facing_texture) = 0; virtual void _render_particle_collider_heightfield(RID p_fb, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, const PagedArray<GeometryInstance *> &p_instances) = 0; - virtual void _debug_giprobe(RID p_gi_probe, RenderingDevice::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha); void _debug_sdfgi_probes(RID p_render_buffers, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform); RenderBufferData *render_buffers_get_data(RID p_render_buffers); @@ -134,12 +86,6 @@ protected: void _process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_buffer, RID p_specular_buffer, RID p_metallic, const Color &p_metallic_mask, RID p_environment, const CameraMatrix &p_projection, bool p_use_additive); void _process_sss(RID p_render_buffers, const CameraMatrix &p_camera); - void _setup_sky(RID p_environment, RID p_render_buffers, const CameraMatrix &p_projection, const Transform &p_transform, const Size2i p_screen_size); - void _update_sky(RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform); - void _draw_sky(bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform); - void _pre_process_gi(RID p_render_buffers, const Transform &p_transform); - void _process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_gi_probe_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform, const PagedArray<RID> &p_gi_probes); - bool _needs_post_prepass_render(bool p_use_gi); void _post_prepass_render(bool p_use_gi); void _pre_resolve_render(bool p_use_gi); @@ -150,190 +96,21 @@ protected: // needed for a single argument calls (material and uv2) PagedArrayPool<GeometryInstance *> cull_argument_pool; PagedArray<GeometryInstance *> cull_argument; //need this to exist -private: - RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; - double time_step = 0; - static RendererSceneRenderRD *singleton; - - int roughness_layers; - - RendererStorageRD *storage; - - struct ReflectionData { - struct Layer { - struct Mipmap { - RID framebuffers[6]; - RID views[6]; - Size2i size; - }; - Vector<Mipmap> mipmaps; //per-face view - Vector<RID> views; // per-cubemap view - }; - - struct DownsampleLayer { - struct Mipmap { - RID view; - Size2i size; - }; - Vector<Mipmap> mipmaps; - }; - - RID radiance_base_cubemap; //cubemap for first layer, first cubemap - RID downsampled_radiance_cubemap; - DownsampleLayer downsampled_layer; - RID coefficient_buffer; - - bool dirty = true; - - Vector<Layer> layers; - }; - - void _clear_reflection_data(ReflectionData &rd); - void _update_reflection_data(ReflectionData &rd, int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality); - void _create_reflection_fast_filter(ReflectionData &rd, bool p_use_arrays); - void _create_reflection_importance_sample(ReflectionData &rd, bool p_use_arrays, int p_cube_side, int p_base_layer); - void _update_reflection_mipmaps(ReflectionData &rd, int p_start, int p_end); - - /* Sky shader */ - - enum SkyVersion { - SKY_VERSION_BACKGROUND, - SKY_VERSION_HALF_RES, - SKY_VERSION_QUARTER_RES, - SKY_VERSION_CUBEMAP, - SKY_VERSION_CUBEMAP_HALF_RES, - SKY_VERSION_CUBEMAP_QUARTER_RES, - SKY_VERSION_MAX - }; - - struct SkyShader { - SkyShaderRD shader; - ShaderCompilerRD compiler; - - RID default_shader; - RID default_material; - RID default_shader_rd; - } sky_shader; - - struct SkyShaderData : public RendererStorageRD::ShaderData { - bool valid; - RID version; - - PipelineCacheRD pipelines[SKY_VERSION_MAX]; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; - Vector<ShaderCompilerRD::GeneratedCode::Texture> texture_uniforms; - - Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; - - String path; - String code; - Map<StringName, RID> default_texture_params; - - bool uses_time; - bool uses_position; - bool uses_half_res; - bool uses_quarter_res; - bool uses_light; - - virtual void set_code(const String &p_Code); - virtual void set_default_texture_param(const StringName &p_name, RID p_texture); - virtual void get_param_list(List<PropertyInfo> *p_param_list) const; - virtual void get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const; - virtual bool is_param_texture(const StringName &p_param) const; - virtual bool is_animated() const; - virtual bool casts_shadows() const; - virtual Variant get_default_parameter(const StringName &p_parameter) const; - virtual RS::ShaderNativeSourceCode get_native_source_code() const; - SkyShaderData(); - virtual ~SkyShaderData(); - }; - - RendererStorageRD::ShaderData *_create_sky_shader_func(); - static RendererStorageRD::ShaderData *_create_sky_shader_funcs() { - return static_cast<RendererSceneRenderRD *>(singleton)->_create_sky_shader_func(); - }; - - struct SkyMaterialData : public RendererStorageRD::MaterialData { - uint64_t last_frame; - SkyShaderData *shader_data; - RID uniform_buffer; - RID uniform_set; - Vector<RID> texture_cache; - Vector<uint8_t> ubo_data; - bool uniform_set_updated; - - virtual void set_render_priority(int p_priority) {} - virtual void set_next_pass(RID p_pass) {} - virtual void update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); - virtual ~SkyMaterialData(); - }; - - RendererStorageRD::MaterialData *_create_sky_material_func(SkyShaderData *p_shader); - static RendererStorageRD::MaterialData *_create_sky_material_funcs(RendererStorageRD::ShaderData *p_shader) { - return static_cast<RendererSceneRenderRD *>(singleton)->_create_sky_material_func(static_cast<SkyShaderData *>(p_shader)); - }; - - enum SkyTextureSetVersion { - SKY_TEXTURE_SET_BACKGROUND, - SKY_TEXTURE_SET_HALF_RES, - SKY_TEXTURE_SET_QUARTER_RES, - SKY_TEXTURE_SET_CUBEMAP, - SKY_TEXTURE_SET_CUBEMAP_HALF_RES, - SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES, - SKY_TEXTURE_SET_MAX - }; - - enum SkySet { - SKY_SET_UNIFORMS, - SKY_SET_MATERIAL, - SKY_SET_TEXTURES, - SKY_SET_FOG, - SKY_SET_MAX - }; - /* SKY */ - struct Sky { - RID radiance; - RID half_res_pass; - RID half_res_framebuffer; - RID quarter_res_pass; - RID quarter_res_framebuffer; - Size2i screen_size; + RendererSceneGIRD gi; + RendererSceneSkyRD sky; - RID texture_uniform_sets[SKY_TEXTURE_SET_MAX]; - RID uniform_set; - - RID material; - RID uniform_buffer; - - int radiance_size = 256; - - RS::SkyMode mode = RS::SKY_MODE_AUTOMATIC; - - ReflectionData reflection; - bool dirty = false; - int processing_layer = 0; - Sky *dirty_list = nullptr; - - //State to track when radiance cubemap needs updating - SkyMaterialData *prev_material; - Vector3 prev_position; - float prev_time; - - RID sdfgi_integrate_sky_uniform_set; - }; - - Sky *dirty_sky_list = nullptr; - - void _sky_invalidate(Sky *p_sky); - void _update_dirty_skys(); - RID _get_sky_textures(Sky *p_sky, SkyTextureSetVersion p_version); - - uint32_t sky_ggx_samples_quality; - bool sky_use_cubemap_array; + RendererSceneEnvironmentRD *get_environment(RID p_environment) { + if (p_environment.is_valid()) { + return environment_owner.getornull(p_environment); + } else { + return nullptr; + } + } - mutable RID_Owner<Sky, true> sky_owner; +private: + RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; + static RendererSceneRenderRD *singleton; /* REFLECTION ATLAS */ @@ -347,7 +124,7 @@ private: struct Reflection { RID owner; - ReflectionData data; + RendererSceneSkyRD::ReflectionData data; RID fbs[6]; }; @@ -397,151 +174,6 @@ private: mutable RID_Owner<LightmapInstance> lightmap_instance_owner; - /* GIPROBE INSTANCE */ - - struct GIProbeLight { - uint32_t type; - float energy; - float radius; - float attenuation; - - float color[3]; - float cos_spot_angle; - - float position[3]; - float inv_spot_attenuation; - - float direction[3]; - uint32_t has_shadow; - }; - - struct GIProbePushConstant { - int32_t limits[3]; - uint32_t stack_size; - - float emission_scale; - float propagation; - float dynamic_range; - uint32_t light_count; - - uint32_t cell_offset; - uint32_t cell_count; - float aniso_strength; - uint32_t pad; - }; - - struct GIProbeDynamicPushConstant { - int32_t limits[3]; - uint32_t light_count; - int32_t x_dir[3]; - float z_base; - int32_t y_dir[3]; - float z_sign; - int32_t z_dir[3]; - float pos_multiplier; - uint32_t rect_pos[2]; - uint32_t rect_size[2]; - uint32_t prev_rect_ofs[2]; - uint32_t prev_rect_size[2]; - uint32_t flip_x; - uint32_t flip_y; - float dynamic_range; - uint32_t on_mipmap; - float propagation; - float pad[3]; - }; - - struct GIProbeInstance { - RID probe; - RID texture; - RID write_buffer; - - struct Mipmap { - RID texture; - RID uniform_set; - RID second_bounce_uniform_set; - RID write_uniform_set; - uint32_t level; - uint32_t cell_offset; - uint32_t cell_count; - }; - Vector<Mipmap> mipmaps; - - struct DynamicMap { - RID texture; //color normally, or emission on first pass - RID fb_depth; //actual depth buffer for the first pass, float depth for later passes - RID depth; //actual depth buffer for the first pass, float depth for later passes - RID normal; //normal buffer for the first pass - RID albedo; //emission buffer for the first pass - RID orm; //orm buffer for the first pass - RID fb; //used for rendering, only valid on first map - RID uniform_set; - uint32_t size; - int mipmap; // mipmap to write to, -1 if no mipmap assigned - }; - - Vector<DynamicMap> dynamic_maps; - - int slot = -1; - uint32_t last_probe_version = 0; - uint32_t last_probe_data_version = 0; - - //uint64_t last_pass = 0; - uint32_t render_index = 0; - - bool has_dynamic_object_data = false; - - Transform transform; - }; - - GIProbeLight *gi_probe_lights; - uint32_t gi_probe_max_lights; - RID gi_probe_lights_uniform; - - enum { - GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT, - GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE, - GI_PROBE_SHADER_VERSION_COMPUTE_MIPMAP, - GI_PROBE_SHADER_VERSION_WRITE_TEXTURE, - GI_PROBE_SHADER_VERSION_DYNAMIC_OBJECT_LIGHTING, - GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE, - GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_PLOT, - GI_PROBE_SHADER_VERSION_DYNAMIC_SHRINK_WRITE_PLOT, - GI_PROBE_SHADER_VERSION_MAX - }; - GiprobeShaderRD giprobe_shader; - RID giprobe_lighting_shader_version; - RID giprobe_lighting_shader_version_shaders[GI_PROBE_SHADER_VERSION_MAX]; - RID giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_MAX]; - - mutable RID_Owner<GIProbeInstance> gi_probe_instance_owner; - - RS::GIProbeQuality gi_probe_quality = RS::GI_PROBE_QUALITY_HIGH; - - enum { - GI_PROBE_DEBUG_COLOR, - GI_PROBE_DEBUG_LIGHT, - GI_PROBE_DEBUG_EMISSION, - GI_PROBE_DEBUG_LIGHT_FULL, - GI_PROBE_DEBUG_MAX - }; - - struct GIProbeDebugPushConstant { - float projection[16]; - uint32_t cell_offset; - float dynamic_range; - float alpha; - uint32_t level; - int32_t bounds[3]; - uint32_t pad; - }; - - GiprobeDebugShaderRD giprobe_debug_shader; - RID giprobe_debug_shader_version; - RID giprobe_debug_shader_version_shaders[GI_PROBE_DEBUG_MAX]; - PipelineCacheRD giprobe_debug_shader_version_pipelines[GI_PROBE_DEBUG_MAX]; - RID giprobe_debug_uniform_set; - /* SHADOW ATLAS */ struct ShadowShrinkStage { @@ -690,111 +322,6 @@ private: /* ENVIRONMENT */ - struct Environment { - // BG - RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR; - RID sky; - float sky_custom_fov = 0.0; - Basis sky_orientation; - Color bg_color; - float bg_energy = 1.0; - int canvas_max_layer = 0; - RS::EnvironmentAmbientSource ambient_source = RS::ENV_AMBIENT_SOURCE_BG; - Color ambient_light; - float ambient_light_energy = 1.0; - float ambient_sky_contribution = 1.0; - RS::EnvironmentReflectionSource reflection_source = RS::ENV_REFLECTION_SOURCE_BG; - Color ao_color; - - /// Tonemap - - RS::EnvironmentToneMapper tone_mapper; - float exposure = 1.0; - float white = 1.0; - bool auto_exposure = false; - float min_luminance = 0.2; - float max_luminance = 8.0; - float auto_exp_speed = 0.2; - float auto_exp_scale = 0.5; - uint64_t auto_exposure_version = 0; - - // Fog - bool fog_enabled = false; - Color fog_light_color = Color(0.5, 0.6, 0.7); - float fog_light_energy = 1.0; - float fog_sun_scatter = 0.0; - float fog_density = 0.001; - float fog_height = 0.0; - float fog_height_density = 0.0; //can be negative to invert effect - float fog_aerial_perspective = 0.0; - - /// Volumetric Fog - /// - bool volumetric_fog_enabled = false; - float volumetric_fog_density = 0.01; - Color volumetric_fog_light = Color(0, 0, 0); - float volumetric_fog_light_energy = 0.0; - float volumetric_fog_length = 64.0; - float volumetric_fog_detail_spread = 2.0; - float volumetric_fog_gi_inject = 0.0; - bool volumetric_fog_temporal_reprojection = true; - float volumetric_fog_temporal_reprojection_amount = 0.9; - - /// Glow - - bool glow_enabled = false; - Vector<float> glow_levels; - float glow_intensity = 0.8; - float glow_strength = 1.0; - float glow_bloom = 0.0; - float glow_mix = 0.01; - RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT; - float glow_hdr_bleed_threshold = 1.0; - float glow_hdr_luminance_cap = 12.0; - float glow_hdr_bleed_scale = 2.0; - - /// SSAO - - bool ssao_enabled = false; - float ssao_radius = 1.0; - float ssao_intensity = 2.0; - float ssao_power = 1.5; - float ssao_detail = 0.5; - float ssao_horizon = 0.06; - float ssao_sharpness = 0.98; - float ssao_direct_light_affect = 0.0; - float ssao_ao_channel_affect = 0.0; - - /// SSR - /// - bool ssr_enabled = false; - int ssr_max_steps = 64; - float ssr_fade_in = 0.15; - float ssr_fade_out = 2.0; - float ssr_depth_tolerance = 0.2; - - /// SDFGI - bool sdfgi_enabled = false; - RS::EnvironmentSDFGICascades sdfgi_cascades; - float sdfgi_min_cell_size = 0.2; - bool sdfgi_use_occlusion = false; - float sdfgi_bounce_feedback = 0.0; - bool sdfgi_read_sky_light = false; - float sdfgi_energy = 1.0; - float sdfgi_normal_bias = 1.1; - float sdfgi_probe_bias = 1.1; - RS::EnvironmentSDFGIYScale sdfgi_y_scale = RS::ENV_SDFGI_Y_SCALE_DISABLED; - - /// Adjustments - - bool adjustments_enabled = false; - float adjustments_brightness = 1.0f; - float adjustments_contrast = 1.0f; - float adjustments_saturation = 1.0f; - bool use_1d_color_correction = false; - RID color_correction = RID(); - }; - RS::EnvironmentSSAOQuality ssao_quality = RS::ENV_SSAO_QUALITY_MEDIUM; bool ssao_half_size = false; bool ssao_using_half_size = false; @@ -807,9 +334,7 @@ private: bool glow_high_quality = false; RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::ENV_SSR_ROUGNESS_QUALITY_LOW; - static uint64_t auto_exposure_counter; - - mutable RID_Owner<Environment, true> environment_owner; + mutable RID_Owner<RendererSceneEnvironmentRD, true> environment_owner; /* CAMERA EFFECTS */ @@ -842,14 +367,9 @@ private: ClusterBuilderSharedDataRD cluster_builder_shared; ClusterBuilderRD *current_cluster_builder = nullptr; - struct SDFGI; struct VolumetricFog; struct RenderBuffers { - enum { - MAX_GIPROBES = 8 - }; - RenderBufferData *data = nullptr; int width = 0, height = 0; RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED; @@ -864,7 +384,7 @@ private: RID depth_texture; //main depth texture RID gi_uniform_set; - SDFGI *sdfgi = nullptr; + RendererSceneGIRD::SDFGI *sdfgi = nullptr; VolumetricFog *volumetric_fog = nullptr; ClusterBuilderRD *cluster_builder = nullptr; @@ -906,414 +426,14 @@ private: RID blur_radius[2]; } ssr; - RID giprobe_textures[MAX_GIPROBES]; - RID giprobe_buffer; - RID ambient_buffer; RID reflection_buffer; bool using_half_size_gi = false; - struct GI { - RID full_buffer; - RID full_dispatch; - RID full_mask; - } gi; - }; - - RID default_giprobe_buffer; - - /* SDFGI */ - - struct SDFGI { - enum { - MAX_CASCADES = 8, - CASCADE_SIZE = 128, - PROBE_DIVISOR = 16, - ANISOTROPY_SIZE = 6, - MAX_DYNAMIC_LIGHTS = 128, - MAX_STATIC_LIGHTS = 1024, - LIGHTPROBE_OCT_SIZE = 6, - SH_SIZE = 16 - }; - - struct Cascade { - struct UBO { - float offset[3]; - float to_cell; - int32_t probe_offset[3]; - uint32_t pad; - }; - - //cascade blocks are full-size for volume (128^3), half size for albedo/emission - RID sdf_tex; - RID light_tex; - RID light_aniso_0_tex; - RID light_aniso_1_tex; - - RID light_data; - RID light_aniso_0_data; - RID light_aniso_1_data; - - struct SolidCell { // this struct is unused, but remains as reference for size - uint32_t position; - uint32_t albedo; - uint32_t static_light; - uint32_t static_light_aniso; - }; - - RID solid_cell_dispatch_buffer; //buffer for indirect compute dispatch - RID solid_cell_buffer; - - RID lightprobe_history_tex; - RID lightprobe_average_tex; - - float cell_size; - Vector3i position; - - static const Vector3i DIRTY_ALL; - Vector3i dirty_regions; //(0,0,0 is not dirty, negative is refresh from the end, DIRTY_ALL is refresh all. - - RID sdf_store_uniform_set; - RID sdf_direct_light_uniform_set; - RID scroll_uniform_set; - RID scroll_occlusion_uniform_set; - RID integrate_uniform_set; - RID lights_buffer; - - bool all_dynamic_lights_dirty = true; - }; - - //used for rendering (voxelization) - RID render_albedo; - RID render_emission; - RID render_emission_aniso; - RID render_occlusion[8]; - RID render_geom_facing; - - RID render_sdf[2]; - RID render_sdf_half[2]; - - //used for ping pong processing in cascades - RID sdf_initialize_uniform_set; - RID sdf_initialize_half_uniform_set; - RID jump_flood_uniform_set[2]; - RID jump_flood_half_uniform_set[2]; - RID sdf_upscale_uniform_set; - int upscale_jfa_uniform_set_index; - RID occlusion_uniform_set; - - uint32_t cascade_size = 128; - - LocalVector<Cascade> cascades; - - RID lightprobe_texture; - RID lightprobe_data; - RID occlusion_texture; - RID occlusion_data; - RID ambient_texture; //integrates with volumetric fog - - RID lightprobe_history_scroll; //used for scrolling lightprobes - RID lightprobe_average_scroll; //used for scrolling lightprobes - - uint32_t history_size = 0; - float solid_cell_ratio = 0; - uint32_t solid_cell_count = 0; - - RS::EnvironmentSDFGICascades cascade_mode; - float min_cell_size = 0; - uint32_t probe_axis_count = 0; //amount of probes per axis, this is an odd number because it encloses endpoints - - RID debug_uniform_set; - RID debug_probes_uniform_set; - RID cascades_ubo; - - bool uses_occlusion = false; - float bounce_feedback = 0.0; - bool reads_sky = false; - float energy = 1.0; - float normal_bias = 1.1; - float probe_bias = 1.1; - RS::EnvironmentSDFGIYScale y_scale_mode = RS::ENV_SDFGI_Y_SCALE_DISABLED; - - float y_mult = 1.0; - - uint32_t render_pass = 0; - - int32_t cascade_dynamic_light_count[SDFGI::MAX_CASCADES]; //used dynamically + RendererSceneGIRD::RenderBuffersGI gi; }; - void _sdfgi_update_light(RID p_render_buffers, RID p_environment); - void _sdfgi_update_probes(RID p_render_buffers, RID p_environment); - void _sdfgi_store_probes(RID p_render_buffers); - - RS::EnvironmentSDFGIRayCount sdfgi_ray_count = RS::ENV_SDFGI_RAY_COUNT_16; - RS::EnvironmentSDFGIFramesToConverge sdfgi_frames_to_converge = RS::ENV_SDFGI_CONVERGE_IN_10_FRAMES; - RS::EnvironmentSDFGIFramesToUpdateLight sdfgi_frames_to_update_light = RS::ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES; - - float sdfgi_solid_cell_ratio = 0.25; - Vector3 sdfgi_debug_probe_pos; - Vector3 sdfgi_debug_probe_dir; - bool sdfgi_debug_probe_enabled = false; - Vector3i sdfgi_debug_probe_index; - - struct SDGIShader { - enum SDFGIPreprocessShaderVersion { - PRE_PROCESS_SCROLL, - PRE_PROCESS_SCROLL_OCCLUSION, - PRE_PROCESS_JUMP_FLOOD_INITIALIZE, - PRE_PROCESS_JUMP_FLOOD_INITIALIZE_HALF, - PRE_PROCESS_JUMP_FLOOD, - PRE_PROCESS_JUMP_FLOOD_OPTIMIZED, - PRE_PROCESS_JUMP_FLOOD_UPSCALE, - PRE_PROCESS_OCCLUSION, - PRE_PROCESS_STORE, - PRE_PROCESS_MAX - }; - - struct PreprocessPushConstant { - int32_t scroll[3]; - int32_t grid_size; - - int32_t probe_offset[3]; - int32_t step_size; - - int32_t half_size; - uint32_t occlusion_index; - int32_t cascade; - uint32_t pad; - }; - - SdfgiPreprocessShaderRD preprocess; - RID preprocess_shader; - RID preprocess_pipeline[PRE_PROCESS_MAX]; - - struct DebugPushConstant { - float grid_size[3]; - uint32_t max_cascades; - - int32_t screen_size[2]; - uint32_t use_occlusion; - float y_mult; - - float cam_extent[3]; - uint32_t probe_axis_size; - - float cam_transform[16]; - }; - - SdfgiDebugShaderRD debug; - RID debug_shader; - RID debug_shader_version; - RID debug_pipeline; - - enum ProbeDebugMode { - PROBE_DEBUG_PROBES, - PROBE_DEBUG_VISIBILITY, - PROBE_DEBUG_MAX - }; - - struct DebugProbesPushConstant { - float projection[16]; - - uint32_t band_power; - uint32_t sections_in_band; - uint32_t band_mask; - float section_arc; - - float grid_size[3]; - uint32_t cascade; - - uint32_t pad; - float y_mult; - int32_t probe_debug_index; - int32_t probe_axis_size; - }; - - SdfgiDebugProbesShaderRD debug_probes; - RID debug_probes_shader; - RID debug_probes_shader_version; - - PipelineCacheRD debug_probes_pipeline[PROBE_DEBUG_MAX]; - - struct Light { - float color[3]; - float energy; - - float direction[3]; - uint32_t has_shadow; - - float position[3]; - float attenuation; - - uint32_t type; - float cos_spot_angle; - float inv_spot_attenuation; - float radius; - - float shadow_color[4]; - }; - - struct DirectLightPushConstant { - float grid_size[3]; - uint32_t max_cascades; - - uint32_t cascade; - uint32_t light_count; - uint32_t process_offset; - uint32_t process_increment; - - int32_t probe_axis_size; - float bounce_feedback; - float y_mult; - uint32_t use_occlusion; - }; - - enum { - DIRECT_LIGHT_MODE_STATIC, - DIRECT_LIGHT_MODE_DYNAMIC, - DIRECT_LIGHT_MODE_MAX - }; - SdfgiDirectLightShaderRD direct_light; - RID direct_light_shader; - RID direct_light_pipeline[DIRECT_LIGHT_MODE_MAX]; - - enum { - INTEGRATE_MODE_PROCESS, - INTEGRATE_MODE_STORE, - INTEGRATE_MODE_SCROLL, - INTEGRATE_MODE_SCROLL_STORE, - INTEGRATE_MODE_MAX - }; - struct IntegratePushConstant { - enum { - SKY_MODE_DISABLED, - SKY_MODE_COLOR, - SKY_MODE_SKY, - }; - - float grid_size[3]; - uint32_t max_cascades; - - uint32_t probe_axis_size; - uint32_t cascade; - uint32_t history_index; - uint32_t history_size; - - uint32_t ray_count; - float ray_bias; - int32_t image_size[2]; - - int32_t world_offset[3]; - uint32_t sky_mode; - - int32_t scroll[3]; - float sky_energy; - - float sky_color[3]; - float y_mult; - - uint32_t store_ambient_texture; - uint32_t pad[3]; - }; - - SdfgiIntegrateShaderRD integrate; - RID integrate_shader; - RID integrate_pipeline[INTEGRATE_MODE_MAX]; - - RID integrate_default_sky_uniform_set; - - } sdfgi_shader; - - void _sdfgi_erase(RenderBuffers *rb); - int _sdfgi_get_pending_region_data(RID p_render_buffers, int p_region, Vector3i &r_local_offset, Vector3i &r_local_size, AABB &r_bounds) const; - void _sdfgi_update_cascades(RID p_render_buffers); - /* GI */ - - struct GI { - struct SDFGIData { - float grid_size[3]; - uint32_t max_cascades; - - uint32_t use_occlusion; - int32_t probe_axis_size; - float probe_to_uvw; - float normal_bias; - - float lightprobe_tex_pixel_size[3]; - float energy; - - float lightprobe_uv_offset[3]; - float y_mult; - - float occlusion_clamp[3]; - uint32_t pad3; - - float occlusion_renormalize[3]; - uint32_t pad4; - - float cascade_probe_size[3]; - uint32_t pad5; - - struct ProbeCascadeData { - float position[3]; //offset of (0,0,0) in world coordinates - float to_probe; // 1/bounds * grid_size - int32_t probe_world_offset[3]; - float to_cell; // 1/bounds * grid_size - }; - - ProbeCascadeData cascades[SDFGI::MAX_CASCADES]; - }; - - struct GIProbeData { - float xform[16]; - float bounds[3]; - float dynamic_range; - - float bias; - float normal_bias; - uint32_t blend_ambient; - uint32_t texture_slot; - - float anisotropy_strength; - float ao; - float ao_size; - uint32_t mipmaps; - }; - - struct PushConstant { - int32_t screen_size[2]; - float z_near; - float z_far; - - float proj_info[4]; - float ao_color[3]; - uint32_t max_giprobes; - - uint32_t high_quality_vct; - uint32_t orthogonal; - uint32_t pad[2]; - - float cam_rotation[12]; - }; - - RID sdfgi_ubo; - enum Mode { - MODE_GIPROBE, - MODE_SDFGI, - MODE_COMBINED, - MODE_HALF_RES_GIPROBE, - MODE_HALF_RES_SDFGI, - MODE_HALF_RES_COMBINED, - MODE_MAX - }; - - bool half_resolution = false; - GiShaderRD shader; - RID shader_version; - RID pipelines[MODE_MAX]; - } gi; - bool screen_space_roughness_limiter = false; float screen_space_roughness_limiter_amount = 0.25; float screen_space_roughness_limiter_limit = 0.18; @@ -1326,7 +446,6 @@ private: void _render_buffers_debug_draw(RID p_render_buffers, RID p_shadow_atlas); void _render_buffers_post_process_and_tonemap(RID p_render_buffers, RID p_environment, RID p_camera_effects, const CameraMatrix &p_projection); - void _sdfgi_debug_draw(RID p_render_buffers, const CameraMatrix &p_projection, const Transform &p_transform); /* Cluster */ @@ -1592,17 +711,17 @@ private: uint64_t scene_pass = 0; uint64_t shadow_atlas_realloc_tolerance_msec = 500; + /* !BAS! is this used anywhere? struct SDFGICosineNeighbour { uint32_t neighbour; float weight; }; + */ uint32_t max_cluster_elements = 512; bool low_end = false; void _render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<GeometryInstance *> &p_instances, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0, float p_screen_lod_threshold = 0.0, bool p_open_pass = true, bool p_close_pass = true, bool p_clear_region = true); - void _render_sdfgi_region(RID p_render_buffers, int p_region, const PagedArray<GeometryInstance *> &p_instances); - void _render_sdfgi_static_lights(RID p_render_buffers, uint32_t p_cascade_count, const uint32_t *p_cascade_indices, const PagedArray<RID> *p_positional_light_cull_result); public: virtual Transform geometry_instance_get_transform(GeometryInstance *p_instance) = 0; @@ -1646,12 +765,12 @@ public: /* SDFGI UPDATE */ - int sdfgi_get_lightprobe_octahedron_size() const { return SDFGI::LIGHTPROBE_OCT_SIZE; } virtual void sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position); virtual int sdfgi_get_pending_region_count(RID p_render_buffers) const; virtual AABB sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const; virtual uint32_t sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const; RID sdfgi_get_ubo() const { return gi.sdfgi_ubo; } + /* SKY API */ virtual RID sky_allocate(); @@ -1662,10 +781,6 @@ public: void sky_set_material(RID p_sky, RID p_material); Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size); - RID sky_get_radiance_texture_rd(RID p_sky) const; - RID sky_get_radiance_uniform_set_rd(RID p_sky, RID p_shader, int p_set) const; - RID sky_get_material(RID p_sky) const; - /* ENVIRONMENT API */ virtual RID environment_allocate(); @@ -1974,57 +1089,16 @@ public: return li->transform; } + /* gi light probes */ + RID gi_probe_instance_create(RID p_base); void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform); bool gi_probe_needs_update(RID p_probe) const; void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects); + void gi_probe_set_quality(RS::GIProbeQuality p_quality) { gi.gi_probe_quality = p_quality; } - void gi_probe_set_quality(RS::GIProbeQuality p_quality) { gi_probe_quality = p_quality; } - - _FORCE_INLINE_ uint32_t gi_probe_instance_get_slot(RID p_probe) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - return gi_probe->slot; - } - _FORCE_INLINE_ RID gi_probe_instance_get_base_probe(RID p_probe) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - return gi_probe->probe; - } - _FORCE_INLINE_ Transform gi_probe_instance_get_transform_to_cell(RID p_probe) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - return storage->gi_probe_get_to_cell_xform(gi_probe->probe) * gi_probe->transform.affine_inverse(); - } - - _FORCE_INLINE_ RID gi_probe_instance_get_texture(RID p_probe) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe); - return gi_probe->texture; - } + /* render buffers */ - _FORCE_INLINE_ void gi_probe_instance_set_render_index(RID p_instance, uint32_t p_render_index) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_instance); - ERR_FAIL_COND(!gi_probe); - gi_probe->render_index = p_render_index; - } - - _FORCE_INLINE_ uint32_t gi_probe_instance_get_render_index(RID p_instance) { - GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_instance); - ERR_FAIL_COND_V(!gi_probe, 0); - - return gi_probe->render_index; - } - /* - _FORCE_INLINE_ void gi_probe_instance_set_render_pass(RID p_instance, uint32_t p_render_pass) { - GIProbeInstance *g_probe = gi_probe_instance_owner.getornull(p_instance); - ERR_FAIL_COND(!g_probe); - g_probe->last_pass = p_render_pass; - } - - _FORCE_INLINE_ uint32_t gi_probe_instance_get_render_pass(RID p_instance) { - GIProbeInstance *g_probe = gi_probe_instance_owner.getornull(p_instance); - ERR_FAIL_COND_V(!g_probe, 0); - - return g_probe->last_pass; - } -*/ RID render_buffers_create(); void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding); void gi_set_use_half_resolution(bool p_enable); @@ -2108,7 +1182,7 @@ public: return debug_draw; } - virtual void set_time(double p_time, double p_step); + void set_time(double p_time, double p_step); RID get_reflection_probe_buffer(); RID get_omni_light_buffer(); diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp new file mode 100644 index 0000000000..769335ac16 --- /dev/null +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -0,0 +1,1491 @@ +/*************************************************************************/ +/* renderer_scene_sky_rd.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "renderer_scene_sky_rd.h" +#include "core/config/project_settings.h" +#include "renderer_scene_render_rd.h" +#include "servers/rendering/rendering_server_default.h" + +//////////////////////////////////////////////////////////////////////////////// +// SKY SHADER + +void RendererSceneSkyRD::SkyShaderData::set_code(const String &p_code) { + //compile + + code = p_code; + valid = false; + ubo_size = 0; + uniforms.clear(); + + if (code == String()) { + return; //just invalid, but no error + } + + ShaderCompilerRD::GeneratedCode gen_code; + ShaderCompilerRD::IdentifierActions actions; + + uses_time = false; + uses_half_res = false; + uses_quarter_res = false; + uses_position = false; + uses_light = false; + + actions.render_mode_flags["use_half_res_pass"] = &uses_half_res; + actions.render_mode_flags["use_quarter_res_pass"] = &uses_quarter_res; + + actions.usage_flag_pointers["TIME"] = &uses_time; + actions.usage_flag_pointers["POSITION"] = &uses_position; + actions.usage_flag_pointers["LIGHT0_ENABLED"] = &uses_light; + actions.usage_flag_pointers["LIGHT0_ENERGY"] = &uses_light; + actions.usage_flag_pointers["LIGHT0_DIRECTION"] = &uses_light; + actions.usage_flag_pointers["LIGHT0_COLOR"] = &uses_light; + actions.usage_flag_pointers["LIGHT0_SIZE"] = &uses_light; + actions.usage_flag_pointers["LIGHT1_ENABLED"] = &uses_light; + actions.usage_flag_pointers["LIGHT1_ENERGY"] = &uses_light; + actions.usage_flag_pointers["LIGHT1_DIRECTION"] = &uses_light; + actions.usage_flag_pointers["LIGHT1_COLOR"] = &uses_light; + actions.usage_flag_pointers["LIGHT1_SIZE"] = &uses_light; + actions.usage_flag_pointers["LIGHT2_ENABLED"] = &uses_light; + actions.usage_flag_pointers["LIGHT2_ENERGY"] = &uses_light; + actions.usage_flag_pointers["LIGHT2_DIRECTION"] = &uses_light; + actions.usage_flag_pointers["LIGHT2_COLOR"] = &uses_light; + actions.usage_flag_pointers["LIGHT2_SIZE"] = &uses_light; + actions.usage_flag_pointers["LIGHT3_ENABLED"] = &uses_light; + actions.usage_flag_pointers["LIGHT3_ENERGY"] = &uses_light; + actions.usage_flag_pointers["LIGHT3_DIRECTION"] = &uses_light; + actions.usage_flag_pointers["LIGHT3_COLOR"] = &uses_light; + actions.usage_flag_pointers["LIGHT3_SIZE"] = &uses_light; + + actions.uniforms = &uniforms; + + // !BAS! Contemplate making `SkyShader sky` accessible from this struct or even part of this struct. + RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; + + Error err = scene_singleton->sky.sky_shader.compiler.compile(RS::SHADER_SKY, code, &actions, path, gen_code); + + ERR_FAIL_COND(err != OK); + + if (version.is_null()) { + version = scene_singleton->sky.sky_shader.shader.version_create(); + } + +#if 0 + print_line("**compiling shader:"); + print_line("**defines:\n"); + for (int i = 0; i < gen_code.defines.size(); i++) { + print_line(gen_code.defines[i]); + } + print_line("\n**uniforms:\n" + gen_code.uniforms); + // print_line("\n**vertex_globals:\n" + gen_code.vertex_global); + // print_line("\n**vertex_code:\n" + gen_code.vertex); + print_line("\n**fragment_globals:\n" + gen_code.fragment_global); + print_line("\n**fragment_code:\n" + gen_code.fragment); + print_line("\n**light_code:\n" + gen_code.light); +#endif + + scene_singleton->sky.sky_shader.shader.version_set_code(version, gen_code.uniforms, gen_code.vertex_global, gen_code.vertex, gen_code.fragment_global, gen_code.light, gen_code.fragment, gen_code.defines); + ERR_FAIL_COND(!scene_singleton->sky.sky_shader.shader.version_is_valid(version)); + + ubo_size = gen_code.uniform_total_size; + ubo_offsets = gen_code.uniform_offsets; + texture_uniforms = gen_code.texture_uniforms; + + //update pipelines + + for (int i = 0; i < SKY_VERSION_MAX; i++) { + RD::PipelineDepthStencilState depth_stencil_state; + depth_stencil_state.enable_depth_test = true; + depth_stencil_state.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL; + + RID shader_variant = scene_singleton->sky.sky_shader.shader.version_get_shader(version, i); + pipelines[i].setup(shader_variant, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), depth_stencil_state, RD::PipelineColorBlendState::create_disabled(), 0); + } + + valid = true; +} + +void RendererSceneSkyRD::SkyShaderData::set_default_texture_param(const StringName &p_name, RID p_texture) { + if (!p_texture.is_valid()) { + default_texture_params.erase(p_name); + } else { + default_texture_params[p_name] = p_texture; + } +} + +void RendererSceneSkyRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { + Map<int, StringName> order; + + for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { + if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { + continue; + } + + if (E->get().texture_order >= 0) { + order[E->get().texture_order + 100000] = E->key(); + } else { + order[E->get().order] = E->key(); + } + } + + for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) { + PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]); + pi.name = E->get(); + p_param_list->push_back(pi); + } +} + +void RendererSceneSkyRD::SkyShaderData::get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const { + for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { + if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { + continue; + } + + RendererStorage::InstanceShaderParam p; + p.info = ShaderLanguage::uniform_to_property_info(E->get()); + p.info.name = E->key(); //supply name + p.index = E->get().instance_index; + p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().hint); + p_param_list->push_back(p); + } +} + +bool RendererSceneSkyRD::SkyShaderData::is_param_texture(const StringName &p_param) const { + if (!uniforms.has(p_param)) { + return false; + } + + return uniforms[p_param].texture_order >= 0; +} + +bool RendererSceneSkyRD::SkyShaderData::is_animated() const { + return false; +} + +bool RendererSceneSkyRD::SkyShaderData::casts_shadows() const { + return false; +} + +Variant RendererSceneSkyRD::SkyShaderData::get_default_parameter(const StringName &p_parameter) const { + if (uniforms.has(p_parameter)) { + ShaderLanguage::ShaderNode::Uniform uniform = uniforms[p_parameter]; + Vector<ShaderLanguage::ConstantNode::Value> default_value = uniform.default_value; + return ShaderLanguage::constant_value_to_variant(default_value, uniform.type, uniform.hint); + } + return Variant(); +} + +RS::ShaderNativeSourceCode RendererSceneSkyRD::SkyShaderData::get_native_source_code() const { + RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; + + return scene_singleton->sky.sky_shader.shader.version_get_native_source_code(version); +} + +RendererSceneSkyRD::SkyShaderData::SkyShaderData() { + valid = false; +} + +RendererSceneSkyRD::SkyShaderData::~SkyShaderData() { + RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; + ERR_FAIL_COND(!scene_singleton); + //pipeline variants will clear themselves if shader is gone + if (version.is_valid()) { + scene_singleton->sky.sky_shader.shader.version_free(version); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Sky material + +void RendererSceneSkyRD::SkyMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { + RendererSceneRenderRD *scene_singleton = (RendererSceneRenderRD *)RendererSceneRenderRD::singleton; + + uniform_set_updated = true; + + if ((uint32_t)ubo_data.size() != shader_data->ubo_size) { + p_uniform_dirty = true; + if (uniform_buffer.is_valid()) { + RD::get_singleton()->free(uniform_buffer); + uniform_buffer = RID(); + } + + ubo_data.resize(shader_data->ubo_size); + if (ubo_data.size()) { + uniform_buffer = RD::get_singleton()->uniform_buffer_create(ubo_data.size()); + memset(ubo_data.ptrw(), 0, ubo_data.size()); //clear + } + + //clear previous uniform set + if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { + RD::get_singleton()->free(uniform_set); + uniform_set = RID(); + } + } + + //check whether buffer changed + if (p_uniform_dirty && ubo_data.size()) { + update_uniform_buffer(shader_data->uniforms, shader_data->ubo_offsets.ptr(), p_parameters, ubo_data.ptrw(), ubo_data.size(), false); + RD::get_singleton()->buffer_update(uniform_buffer, 0, ubo_data.size(), ubo_data.ptrw()); + } + + uint32_t tex_uniform_count = shader_data->texture_uniforms.size(); + + if ((uint32_t)texture_cache.size() != tex_uniform_count) { + texture_cache.resize(tex_uniform_count); + p_textures_dirty = true; + + //clear previous uniform set + if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { + RD::get_singleton()->free(uniform_set); + uniform_set = RID(); + } + } + + if (p_textures_dirty && tex_uniform_count) { + update_textures(p_parameters, shader_data->default_texture_params, shader_data->texture_uniforms, texture_cache.ptrw(), true); + } + + if (shader_data->ubo_size == 0 && shader_data->texture_uniforms.size() == 0) { + // This material does not require an uniform set, so don't create it. + return; + } + + if (!p_textures_dirty && uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { + //no reason to update uniform set, only UBO (or nothing) was needed to update + return; + } + + Vector<RD::Uniform> uniforms; + + { + if (shader_data->ubo_size) { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.binding = 0; + u.ids.push_back(uniform_buffer); + uniforms.push_back(u); + } + + const RID *textures = texture_cache.ptrw(); + for (uint32_t i = 0; i < tex_uniform_count; i++) { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 1 + i; + u.ids.push_back(textures[i]); + uniforms.push_back(u); + } + } + + uniform_set = RD::get_singleton()->uniform_set_create(uniforms, scene_singleton->sky.sky_shader.shader.version_get_shader(shader_data->version, 0), SKY_SET_MATERIAL); +} + +RendererSceneSkyRD::SkyMaterialData::~SkyMaterialData() { + if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) { + RD::get_singleton()->free(uniform_set); + } + + if (uniform_buffer.is_valid()) { + RD::get_singleton()->free(uniform_buffer); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// ReflectionData + +void RendererSceneSkyRD::ReflectionData::clear_reflection_data() { + layers.clear(); + radiance_base_cubemap = RID(); + if (downsampled_radiance_cubemap.is_valid()) { + RD::get_singleton()->free(downsampled_radiance_cubemap); + } + downsampled_radiance_cubemap = RID(); + downsampled_layer.mipmaps.clear(); + coefficient_buffer = RID(); +} + +void RendererSceneSkyRD::ReflectionData::update_reflection_data(int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality, int p_roughness_layers) { + //recreate radiance and all data + + int mipmaps = p_mipmaps; + uint32_t w = p_size, h = p_size; + + if (p_use_array) { + int num_layers = p_low_quality ? 8 : p_roughness_layers; + + for (int i = 0; i < num_layers; i++) { + ReflectionData::Layer layer; + uint32_t mmw = w; + uint32_t mmh = h; + layer.mipmaps.resize(mipmaps); + layer.views.resize(mipmaps); + for (int j = 0; j < mipmaps; j++) { + ReflectionData::Layer::Mipmap &mm = layer.mipmaps.write[j]; + mm.size.width = mmw; + mm.size.height = mmh; + for (int k = 0; k < 6; k++) { + mm.views[k] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + i * 6 + k, j); + Vector<RID> fbtex; + fbtex.push_back(mm.views[k]); + mm.framebuffers[k] = RD::get_singleton()->framebuffer_create(fbtex); + } + + layer.views.write[j] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + i * 6, j, RD::TEXTURE_SLICE_CUBEMAP); + + mmw = MAX(1, mmw >> 1); + mmh = MAX(1, mmh >> 1); + } + + layers.push_back(layer); + } + + } else { + mipmaps = p_low_quality ? 8 : mipmaps; + //regular cubemap, lower quality (aliasing, less memory) + ReflectionData::Layer layer; + uint32_t mmw = w; + uint32_t mmh = h; + layer.mipmaps.resize(mipmaps); + layer.views.resize(mipmaps); + for (int j = 0; j < mipmaps; j++) { + ReflectionData::Layer::Mipmap &mm = layer.mipmaps.write[j]; + mm.size.width = mmw; + mm.size.height = mmh; + for (int k = 0; k < 6; k++) { + mm.views[k] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer + k, j); + Vector<RID> fbtex; + fbtex.push_back(mm.views[k]); + mm.framebuffers[k] = RD::get_singleton()->framebuffer_create(fbtex); + } + + layer.views.write[j] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer, j, RD::TEXTURE_SLICE_CUBEMAP); + + mmw = MAX(1, mmw >> 1); + mmh = MAX(1, mmh >> 1); + } + + layers.push_back(layer); + } + + radiance_base_cubemap = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer, 0, RD::TEXTURE_SLICE_CUBEMAP); + + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.width = 64; // Always 64x64 + tf.height = 64; + tf.texture_type = RD::TEXTURE_TYPE_CUBE; + tf.array_layers = 6; + tf.mipmaps = 7; + tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + + downsampled_radiance_cubemap = RD::get_singleton()->texture_create(tf, RD::TextureView()); + { + uint32_t mmw = 64; + uint32_t mmh = 64; + downsampled_layer.mipmaps.resize(7); + for (int j = 0; j < downsampled_layer.mipmaps.size(); j++) { + ReflectionData::DownsampleLayer::Mipmap &mm = downsampled_layer.mipmaps.write[j]; + mm.size.width = mmw; + mm.size.height = mmh; + mm.view = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), downsampled_radiance_cubemap, 0, j, RD::TEXTURE_SLICE_CUBEMAP); + + mmw = MAX(1, mmw >> 1); + mmh = MAX(1, mmh >> 1); + } + } +} + +void RendererSceneSkyRD::ReflectionData::create_reflection_fast_filter(RendererStorageRD *p_storage, bool p_use_arrays) { + p_storage->get_effects()->cubemap_downsample(radiance_base_cubemap, downsampled_layer.mipmaps[0].view, downsampled_layer.mipmaps[0].size); + + for (int i = 1; i < downsampled_layer.mipmaps.size(); i++) { + p_storage->get_effects()->cubemap_downsample(downsampled_layer.mipmaps[i - 1].view, downsampled_layer.mipmaps[i].view, downsampled_layer.mipmaps[i].size); + } + + Vector<RID> views; + if (p_use_arrays) { + for (int i = 1; i < layers.size(); i++) { + views.push_back(layers[i].views[0]); + } + } else { + for (int i = 1; i < layers[0].views.size(); i++) { + views.push_back(layers[0].views[i]); + } + } + + p_storage->get_effects()->cubemap_filter(downsampled_radiance_cubemap, views, p_use_arrays); +} + +void RendererSceneSkyRD::ReflectionData::create_reflection_importance_sample(RendererStorageRD *p_storage, bool p_use_arrays, int p_cube_side, int p_base_layer, uint32_t p_sky_ggx_samples_quality) { + if (p_use_arrays) { + //render directly to the layers + p_storage->get_effects()->cubemap_roughness(radiance_base_cubemap, layers[p_base_layer].views[0], p_cube_side, p_sky_ggx_samples_quality, float(p_base_layer) / (layers.size() - 1.0), layers[p_base_layer].mipmaps[0].size.x); + } else { + p_storage->get_effects()->cubemap_roughness( + layers[0].views[p_base_layer - 1], + layers[0].views[p_base_layer], + p_cube_side, + p_sky_ggx_samples_quality, + float(p_base_layer) / (layers[0].mipmaps.size() - 1.0), + layers[0].mipmaps[p_base_layer].size.x); + } +} + +void RendererSceneSkyRD::ReflectionData::update_reflection_mipmaps(RendererStorageRD *p_storage, int p_start, int p_end) { + for (int i = p_start; i < p_end; i++) { + for (int j = 0; j < layers[i].views.size() - 1; j++) { + RID view = layers[i].views[j]; + RID texture = layers[i].views[j + 1]; + Size2i size = layers[i].mipmaps[j + 1].size; + p_storage->get_effects()->cubemap_downsample(view, texture, size); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// RendererSceneSkyRD::Sky + +void RendererSceneSkyRD::Sky::free(RendererStorageRD *p_storage) { + if (radiance.is_valid()) { + RD::get_singleton()->free(radiance); + radiance = RID(); + } + reflection.clear_reflection_data(); + + if (uniform_buffer.is_valid()) { + RD::get_singleton()->free(uniform_buffer); + uniform_buffer = RID(); + } + + if (half_res_pass.is_valid()) { + RD::get_singleton()->free(half_res_pass); + half_res_pass = RID(); + } + + if (quarter_res_pass.is_valid()) { + RD::get_singleton()->free(quarter_res_pass); + quarter_res_pass = RID(); + } + + if (material.is_valid()) { + p_storage->free(material); + } +} + +RID RendererSceneSkyRD::Sky::get_textures(RendererStorageRD *p_storage, SkyTextureSetVersion p_version, RID p_default_shader_rd) { + if (texture_uniform_sets[p_version].is_valid() && RD::get_singleton()->uniform_set_is_valid(texture_uniform_sets[p_version])) { + return texture_uniform_sets[p_version]; + } + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 0; + if (radiance.is_valid() && p_version <= SKY_TEXTURE_SET_QUARTER_RES) { + u.ids.push_back(radiance); + } else { + u.ids.push_back(p_storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 1; // half res + if (half_res_pass.is_valid() && p_version != SKY_TEXTURE_SET_HALF_RES && p_version != SKY_TEXTURE_SET_CUBEMAP_HALF_RES) { + if (p_version >= SKY_TEXTURE_SET_CUBEMAP) { + u.ids.push_back(reflection.layers[0].views[1]); + } else { + u.ids.push_back(half_res_pass); + } + } else { + if (p_version < SKY_TEXTURE_SET_CUBEMAP) { + u.ids.push_back(p_storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); + } else { + u.ids.push_back(p_storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); + } + } + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 2; // quarter res + if (quarter_res_pass.is_valid() && p_version != SKY_TEXTURE_SET_QUARTER_RES && p_version != SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES) { + if (p_version >= SKY_TEXTURE_SET_CUBEMAP) { + u.ids.push_back(reflection.layers[0].views[2]); + } else { + u.ids.push_back(quarter_res_pass); + } + } else { + if (p_version < SKY_TEXTURE_SET_CUBEMAP) { + u.ids.push_back(p_storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); + } else { + u.ids.push_back(p_storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); + } + } + uniforms.push_back(u); + } + + texture_uniform_sets[p_version] = RD::get_singleton()->uniform_set_create(uniforms, p_default_shader_rd, SKY_SET_TEXTURES); + return texture_uniform_sets[p_version]; +} + +bool RendererSceneSkyRD::Sky::set_radiance_size(int p_radiance_size) { + ERR_FAIL_COND_V(p_radiance_size < 32 || p_radiance_size > 2048, false); + if (radiance_size == p_radiance_size) { + return false; + } + radiance_size = p_radiance_size; + + if (mode == RS::SKY_MODE_REALTIME && radiance_size != 256) { + WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally."); + radiance_size = 256; + } + + if (radiance.is_valid()) { + RD::get_singleton()->free(radiance); + radiance = RID(); + } + reflection.clear_reflection_data(); + + return true; +} + +bool RendererSceneSkyRD::Sky::set_mode(RS::SkyMode p_mode) { + if (mode == p_mode) { + return false; + } + + mode = p_mode; + + if (mode == RS::SKY_MODE_REALTIME && radiance_size != 256) { + WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally."); + set_radiance_size(256); + } + + if (radiance.is_valid()) { + RD::get_singleton()->free(radiance); + radiance = RID(); + } + reflection.clear_reflection_data(); + + return true; +} + +bool RendererSceneSkyRD::Sky::set_material(RID p_material) { + if (material == p_material) { + return false; + } + + material = p_material; + return true; +} + +Ref<Image> RendererSceneSkyRD::Sky::bake_panorama(RendererStorageRD *p_storage, float p_energy, int p_roughness_layers, const Size2i &p_size) { + if (radiance.is_valid()) { + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; + tf.width = p_size.width; + tf.height = p_size.height; + tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT; + + RID rad_tex = RD::get_singleton()->texture_create(tf, RD::TextureView()); + p_storage->get_effects()->copy_cubemap_to_panorama(radiance, rad_tex, p_size, p_roughness_layers, reflection.layers.size() > 1); + Vector<uint8_t> data = RD::get_singleton()->texture_get_data(rad_tex, 0); + RD::get_singleton()->free(rad_tex); + + Ref<Image> img; + img.instance(); + img->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF, data); + for (int i = 0; i < p_size.width; i++) { + for (int j = 0; j < p_size.height; j++) { + Color c = img->get_pixel(i, j); + c.r *= p_energy; + c.g *= p_energy; + c.b *= p_energy; + img->set_pixel(i, j, c); + } + } + return img; + } + + return Ref<Image>(); +} + +//////////////////////////////////////////////////////////////////////////////// +// RendererSceneSkyRD + +RendererStorageRD::ShaderData *RendererSceneSkyRD::_create_sky_shader_func() { + SkyShaderData *shader_data = memnew(SkyShaderData); + return shader_data; +} + +RendererStorageRD::ShaderData *RendererSceneSkyRD::_create_sky_shader_funcs() { + // !BAS! Why isn't _create_sky_shader_func not just static too? + return static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton)->sky._create_sky_shader_func(); +}; + +RendererStorageRD::MaterialData *RendererSceneSkyRD::_create_sky_material_func(SkyShaderData *p_shader) { + SkyMaterialData *material_data = memnew(SkyMaterialData); + material_data->shader_data = p_shader; + material_data->last_frame = false; + //update will happen later anyway so do nothing. + return material_data; +} + +RendererStorageRD::MaterialData *RendererSceneSkyRD::_create_sky_material_funcs(RendererStorageRD::ShaderData *p_shader) { + // !BAS! same here, we could just make _create_sky_material_func static? + return static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton)->sky._create_sky_material_func(static_cast<SkyShaderData *>(p_shader)); +}; + +RendererSceneSkyRD::RendererSceneSkyRD() { + roughness_layers = GLOBAL_GET("rendering/reflections/sky_reflections/roughness_layers"); + sky_ggx_samples_quality = GLOBAL_GET("rendering/reflections/sky_reflections/ggx_samples"); + sky_use_cubemap_array = GLOBAL_GET("rendering/reflections/sky_reflections/texture_array_reflections"); +} + +void RendererSceneSkyRD::init(RendererStorageRD *p_storage) { + storage = p_storage; + + { + // Start with the directional lights for the sky + sky_scene_state.max_directional_lights = 4; + uint32_t directional_light_buffer_size = sky_scene_state.max_directional_lights * sizeof(SkyDirectionalLightData); + sky_scene_state.directional_lights = memnew_arr(SkyDirectionalLightData, sky_scene_state.max_directional_lights); + sky_scene_state.last_frame_directional_lights = memnew_arr(SkyDirectionalLightData, sky_scene_state.max_directional_lights); + sky_scene_state.last_frame_directional_light_count = sky_scene_state.max_directional_lights + 1; + sky_scene_state.directional_light_buffer = RD::get_singleton()->uniform_buffer_create(directional_light_buffer_size); + + String defines = "\n#define MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS " + itos(sky_scene_state.max_directional_lights) + "\n"; + + // Initialize sky + Vector<String> sky_modes; + sky_modes.push_back(""); // Full size + sky_modes.push_back("\n#define USE_HALF_RES_PASS\n"); // Half Res + sky_modes.push_back("\n#define USE_QUARTER_RES_PASS\n"); // Quarter res + sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n"); // Cubemap + sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n#define USE_HALF_RES_PASS\n"); // Half Res Cubemap + sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n#define USE_QUARTER_RES_PASS\n"); // Quarter res Cubemap + sky_shader.shader.initialize(sky_modes, defines); + } + + // register our shader funds + storage->shader_set_data_request_function(RendererStorageRD::SHADER_TYPE_SKY, _create_sky_shader_funcs); + storage->material_set_data_request_function(RendererStorageRD::SHADER_TYPE_SKY, _create_sky_material_funcs); + + { + ShaderCompilerRD::DefaultIdentifierActions actions; + + actions.renames["COLOR"] = "color"; + actions.renames["ALPHA"] = "alpha"; + actions.renames["EYEDIR"] = "cube_normal"; + actions.renames["POSITION"] = "params.position_multiplier.xyz"; + actions.renames["SKY_COORDS"] = "panorama_coords"; + actions.renames["SCREEN_UV"] = "uv"; + actions.renames["TIME"] = "params.time"; + actions.renames["HALF_RES_COLOR"] = "half_res_color"; + actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color"; + actions.renames["RADIANCE"] = "radiance"; + actions.renames["FOG"] = "custom_fog"; + actions.renames["LIGHT0_ENABLED"] = "directional_lights.data[0].enabled"; + actions.renames["LIGHT0_DIRECTION"] = "directional_lights.data[0].direction_energy.xyz"; + actions.renames["LIGHT0_ENERGY"] = "directional_lights.data[0].direction_energy.w"; + actions.renames["LIGHT0_COLOR"] = "directional_lights.data[0].color_size.xyz"; + actions.renames["LIGHT0_SIZE"] = "directional_lights.data[0].color_size.w"; + actions.renames["LIGHT1_ENABLED"] = "directional_lights.data[1].enabled"; + actions.renames["LIGHT1_DIRECTION"] = "directional_lights.data[1].direction_energy.xyz"; + actions.renames["LIGHT1_ENERGY"] = "directional_lights.data[1].direction_energy.w"; + actions.renames["LIGHT1_COLOR"] = "directional_lights.data[1].color_size.xyz"; + actions.renames["LIGHT1_SIZE"] = "directional_lights.data[1].color_size.w"; + actions.renames["LIGHT2_ENABLED"] = "directional_lights.data[2].enabled"; + actions.renames["LIGHT2_DIRECTION"] = "directional_lights.data[2].direction_energy.xyz"; + actions.renames["LIGHT2_ENERGY"] = "directional_lights.data[2].direction_energy.w"; + actions.renames["LIGHT2_COLOR"] = "directional_lights.data[2].color_size.xyz"; + actions.renames["LIGHT2_SIZE"] = "directional_lights.data[2].color_size.w"; + actions.renames["LIGHT3_ENABLED"] = "directional_lights.data[3].enabled"; + actions.renames["LIGHT3_DIRECTION"] = "directional_lights.data[3].direction_energy.xyz"; + actions.renames["LIGHT3_ENERGY"] = "directional_lights.data[3].direction_energy.w"; + actions.renames["LIGHT3_COLOR"] = "directional_lights.data[3].color_size.xyz"; + actions.renames["LIGHT3_SIZE"] = "directional_lights.data[3].color_size.w"; + actions.renames["AT_CUBEMAP_PASS"] = "AT_CUBEMAP_PASS"; + actions.renames["AT_HALF_RES_PASS"] = "AT_HALF_RES_PASS"; + actions.renames["AT_QUARTER_RES_PASS"] = "AT_QUARTER_RES_PASS"; + actions.custom_samplers["RADIANCE"] = "material_samplers[3]"; + actions.usage_defines["HALF_RES_COLOR"] = "\n#define USES_HALF_RES_COLOR\n"; + actions.usage_defines["QUARTER_RES_COLOR"] = "\n#define USES_QUARTER_RES_COLOR\n"; + actions.render_mode_defines["disable_fog"] = "#define DISABLE_FOG\n"; + + actions.sampler_array_name = "material_samplers"; + actions.base_texture_binding_index = 1; + actions.texture_layout_set = 1; + actions.base_uniform_string = "material."; + actions.base_varying_index = 10; + + actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP; + actions.default_repeat = ShaderLanguage::REPEAT_ENABLE; + actions.global_buffer_array_variable = "global_variables.data"; + + sky_shader.compiler.initialize(actions); + } + + { + // default material and shader for sky shader + sky_shader.default_shader = storage->shader_allocate(); + storage->shader_initialize(sky_shader.default_shader); + + storage->shader_set_code(sky_shader.default_shader, "shader_type sky; void fragment() { COLOR = vec3(0.0); } \n"); + + sky_shader.default_material = storage->material_allocate(); + storage->material_initialize(sky_shader.default_material); + + storage->material_set_shader(sky_shader.default_material, sky_shader.default_shader); + + SkyMaterialData *md = (SkyMaterialData *)storage->material_get_data(sky_shader.default_material, RendererStorageRD::SHADER_TYPE_SKY); + sky_shader.default_shader_rd = sky_shader.shader.version_get_shader(md->shader_data->version, SKY_VERSION_BACKGROUND); + + sky_scene_state.uniform_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(SkySceneState::UBO)); + + Vector<RD::Uniform> uniforms; + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + u.binding = 0; + u.ids.resize(12); + RID *ids_ptr = u.ids.ptrw(); + ids_ptr[0] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[1] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[2] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[3] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[4] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[5] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[6] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[7] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[8] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[9] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[10] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[11] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 1; + u.ids.push_back(storage->global_variables_get_storage_buffer()); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.binding = 2; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.ids.push_back(sky_scene_state.uniform_buffer); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; + u.ids.push_back(sky_scene_state.directional_light_buffer); + uniforms.push_back(u); + } + + sky_scene_state.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_UNIFORMS); + } + + { + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.binding = 0; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + RID vfog = storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_3D_WHITE); + u.ids.push_back(vfog); + uniforms.push_back(u); + } + + sky_scene_state.default_fog_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_FOG); + } + + { + // Need defaults for using fog with clear color + sky_scene_state.fog_shader = storage->shader_allocate(); + storage->shader_initialize(sky_scene_state.fog_shader); + + storage->shader_set_code(sky_scene_state.fog_shader, "shader_type sky; uniform vec4 clear_color; void fragment() { COLOR = clear_color.rgb; } \n"); + sky_scene_state.fog_material = storage->material_allocate(); + storage->material_initialize(sky_scene_state.fog_material); + + storage->material_set_shader(sky_scene_state.fog_material, sky_scene_state.fog_shader); + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 0; + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 1; + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; + u.binding = 2; + u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_WHITE)); + uniforms.push_back(u); + } + + sky_scene_state.fog_only_texture_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_TEXTURES); + } +} + +void RendererSceneSkyRD::setup(RendererSceneEnvironmentRD *p_env, RID p_render_buffers, const CameraMatrix &p_projection, const Transform &p_transform, const Size2i p_screen_size, RendererSceneRenderRD *p_scene_render) { + ERR_FAIL_COND(!p_env); // I guess without an environment we also can't have a sky... + + SkyMaterialData *material = nullptr; + Sky *sky = get_sky(p_env->sky); + + RID sky_material; + + SkyShaderData *shader_data = nullptr; + + RS::EnvironmentBG background = p_env->background; + + if (!(background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) || sky) { + // !BAS! Possibly silently fail here, we now get error spam when you select sky as the background but haven't setup the sky yet. + ERR_FAIL_COND(!sky); + sky_material = sky_get_material(p_env->sky); + + if (sky_material.is_valid()) { + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + if (!material || !material->shader_data->valid) { + material = nullptr; + } + } + + if (!material) { + sky_material = sky_shader.default_material; + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + } + + ERR_FAIL_COND(!material); + + shader_data = material->shader_data; + + ERR_FAIL_COND(!shader_data); + } + + if (sky) { + // Invalidate supbass buffers if screen size changes + if (sky->screen_size != p_screen_size) { + sky->screen_size = p_screen_size; + sky->screen_size.x = sky->screen_size.x < 4 ? 4 : sky->screen_size.x; + sky->screen_size.y = sky->screen_size.y < 4 ? 4 : sky->screen_size.y; + if (shader_data->uses_half_res) { + if (sky->half_res_pass.is_valid()) { + RD::get_singleton()->free(sky->half_res_pass); + sky->half_res_pass = RID(); + } + invalidate_sky(sky); + } + if (shader_data->uses_quarter_res) { + if (sky->quarter_res_pass.is_valid()) { + RD::get_singleton()->free(sky->quarter_res_pass); + sky->quarter_res_pass = RID(); + } + invalidate_sky(sky); + } + } + + // Create new subpass buffers if necessary + if ((shader_data->uses_half_res && sky->half_res_pass.is_null()) || + (shader_data->uses_quarter_res && sky->quarter_res_pass.is_null()) || + sky->radiance.is_null()) { + invalidate_sky(sky); + update_dirty_skys(); + } + + if (shader_data->uses_time && p_scene_render->time - sky->prev_time > 0.00001) { + sky->prev_time = p_scene_render->time; + sky->reflection.dirty = true; + RenderingServerDefault::redraw_request(); + } + + if (material != sky->prev_material) { + sky->prev_material = material; + sky->reflection.dirty = true; + } + + if (material->uniform_set_updated) { + material->uniform_set_updated = false; + sky->reflection.dirty = true; + } + + if (!p_transform.origin.is_equal_approx(sky->prev_position) && shader_data->uses_position) { + sky->prev_position = p_transform.origin; + sky->reflection.dirty = true; + } + + if (shader_data->uses_light) { + // Check whether the directional_light_buffer changes + bool light_data_dirty = false; + + if (sky_scene_state.ubo.directional_light_count != sky_scene_state.last_frame_directional_light_count) { + light_data_dirty = true; + for (uint32_t i = sky_scene_state.ubo.directional_light_count; i < sky_scene_state.max_directional_lights; i++) { + sky_scene_state.directional_lights[i].enabled = false; + } + } + if (!light_data_dirty) { + for (uint32_t i = 0; i < sky_scene_state.ubo.directional_light_count; i++) { + if (sky_scene_state.directional_lights[i].direction[0] != sky_scene_state.last_frame_directional_lights[i].direction[0] || + sky_scene_state.directional_lights[i].direction[1] != sky_scene_state.last_frame_directional_lights[i].direction[1] || + sky_scene_state.directional_lights[i].direction[2] != sky_scene_state.last_frame_directional_lights[i].direction[2] || + sky_scene_state.directional_lights[i].energy != sky_scene_state.last_frame_directional_lights[i].energy || + sky_scene_state.directional_lights[i].color[0] != sky_scene_state.last_frame_directional_lights[i].color[0] || + sky_scene_state.directional_lights[i].color[1] != sky_scene_state.last_frame_directional_lights[i].color[1] || + sky_scene_state.directional_lights[i].color[2] != sky_scene_state.last_frame_directional_lights[i].color[2] || + sky_scene_state.directional_lights[i].enabled != sky_scene_state.last_frame_directional_lights[i].enabled || + sky_scene_state.directional_lights[i].size != sky_scene_state.last_frame_directional_lights[i].size) { + light_data_dirty = true; + break; + } + } + } + + if (light_data_dirty) { + RD::get_singleton()->buffer_update(sky_scene_state.directional_light_buffer, 0, sizeof(SkyDirectionalLightData) * sky_scene_state.max_directional_lights, sky_scene_state.directional_lights); + + SkyDirectionalLightData *temp = sky_scene_state.last_frame_directional_lights; + sky_scene_state.last_frame_directional_lights = sky_scene_state.directional_lights; + sky_scene_state.directional_lights = temp; + sky_scene_state.last_frame_directional_light_count = sky_scene_state.ubo.directional_light_count; + sky->reflection.dirty = true; + } + } + } + + //setup fog variables + sky_scene_state.ubo.volumetric_fog_enabled = false; + if (p_render_buffers.is_valid()) { + if (p_scene_render->render_buffers_has_volumetric_fog(p_render_buffers)) { + sky_scene_state.ubo.volumetric_fog_enabled = true; + + float fog_end = p_scene_render->render_buffers_get_volumetric_fog_end(p_render_buffers); + if (fog_end > 0.0) { + sky_scene_state.ubo.volumetric_fog_inv_length = 1.0 / fog_end; + } else { + sky_scene_state.ubo.volumetric_fog_inv_length = 1.0; + } + + float fog_detail_spread = p_scene_render->render_buffers_get_volumetric_fog_detail_spread(p_render_buffers); //reverse lookup + if (fog_detail_spread > 0.0) { + sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0 / fog_detail_spread; + } else { + sky_scene_state.ubo.volumetric_fog_detail_spread = 1.0; + } + } + + RID fog_uniform_set = p_scene_render->render_buffers_get_volumetric_fog_sky_uniform_set(p_render_buffers); + + if (fog_uniform_set != RID()) { + sky_scene_state.fog_uniform_set = fog_uniform_set; + } else { + sky_scene_state.fog_uniform_set = sky_scene_state.default_fog_uniform_set; + } + } + + sky_scene_state.ubo.z_far = p_projection.get_z_far(); + sky_scene_state.ubo.fog_enabled = p_env->fog_enabled; + sky_scene_state.ubo.fog_density = p_env->fog_density; + sky_scene_state.ubo.fog_aerial_perspective = p_env->fog_aerial_perspective; + Color fog_color = p_env->fog_light_color.to_linear(); + float fog_energy = p_env->fog_light_energy; + sky_scene_state.ubo.fog_light_color[0] = fog_color.r * fog_energy; + sky_scene_state.ubo.fog_light_color[1] = fog_color.g * fog_energy; + sky_scene_state.ubo.fog_light_color[2] = fog_color.b * fog_energy; + sky_scene_state.ubo.fog_sun_scatter = p_env->fog_sun_scatter; + + RD::get_singleton()->buffer_update(sky_scene_state.uniform_buffer, 0, sizeof(SkySceneState::UBO), &sky_scene_state.ubo); +} + +void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraMatrix &p_projection, const Transform &p_transform, double p_time) { + ERR_FAIL_COND(!p_env); + + Sky *sky = get_sky(p_env->sky); + ERR_FAIL_COND(!sky); + + RID sky_material = sky_get_material(p_env->sky); + + SkyMaterialData *material = nullptr; + + if (sky_material.is_valid()) { + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + if (!material || !material->shader_data->valid) { + material = nullptr; + } + } + + if (!material) { + sky_material = sky_shader.default_material; + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + } + + ERR_FAIL_COND(!material); + + SkyShaderData *shader_data = material->shader_data; + + ERR_FAIL_COND(!shader_data); + + float multiplier = p_env->bg_energy; + + bool update_single_frame = sky->mode == RS::SKY_MODE_REALTIME || sky->mode == RS::SKY_MODE_QUALITY; + RS::SkyMode sky_mode = sky->mode; + + if (sky_mode == RS::SKY_MODE_AUTOMATIC) { + if (shader_data->uses_time || shader_data->uses_position) { + update_single_frame = true; + sky_mode = RS::SKY_MODE_REALTIME; + } else if (shader_data->uses_light || shader_data->ubo_size > 0) { + update_single_frame = false; + sky_mode = RS::SKY_MODE_INCREMENTAL; + } else { + update_single_frame = true; + sky_mode = RS::SKY_MODE_QUALITY; + } + } + + if (sky->processing_layer == 0 && sky_mode == RS::SKY_MODE_INCREMENTAL) { + // On the first frame after creating sky, rebuild in single frame + update_single_frame = true; + sky_mode = RS::SKY_MODE_QUALITY; + } + + int max_processing_layer = sky_use_cubemap_array ? sky->reflection.layers.size() : sky->reflection.layers[0].mipmaps.size(); + + // Update radiance cubemap + if (sky->reflection.dirty && (sky->processing_layer >= max_processing_layer || update_single_frame)) { + static const Vector3 view_normals[6] = { + Vector3(+1, 0, 0), + Vector3(-1, 0, 0), + Vector3(0, +1, 0), + Vector3(0, -1, 0), + Vector3(0, 0, +1), + Vector3(0, 0, -1) + }; + static const Vector3 view_up[6] = { + Vector3(0, -1, 0), + Vector3(0, -1, 0), + Vector3(0, 0, +1), + Vector3(0, 0, -1), + Vector3(0, -1, 0), + Vector3(0, -1, 0) + }; + + CameraMatrix cm; + cm.set_perspective(90, 1, 0.01, 10.0); + CameraMatrix correction; + correction.set_depth_correction(true); + cm = correction * cm; + + if (shader_data->uses_quarter_res) { + PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_QUARTER_RES]; + + Vector<Color> clear_colors; + clear_colors.push_back(Color(0.0, 0.0, 0.0)); + RD::DrawListID cubemap_draw_list; + + for (int i = 0; i < 6; i++) { + Transform local_view; + local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); + RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES, sky_shader.default_shader_rd); + + cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[2].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + storage->get_effects()->render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[2].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin); + RD::get_singleton()->draw_list_end(); + } + } + + if (shader_data->uses_half_res) { + PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_HALF_RES]; + + Vector<Color> clear_colors; + clear_colors.push_back(Color(0.0, 0.0, 0.0)); + RD::DrawListID cubemap_draw_list; + + for (int i = 0; i < 6; i++) { + Transform local_view; + local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); + RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_CUBEMAP_HALF_RES, sky_shader.default_shader_rd); + + cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[1].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + storage->get_effects()->render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[1].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin); + RD::get_singleton()->draw_list_end(); + } + } + + RD::DrawListID cubemap_draw_list; + PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP]; + + for (int i = 0; i < 6; i++) { + Transform local_view; + local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); + RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_CUBEMAP, sky_shader.default_shader_rd); + + cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[0].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + storage->get_effects()->render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[0].framebuffers[i], sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin); + RD::get_singleton()->draw_list_end(); + } + + if (sky_mode == RS::SKY_MODE_REALTIME) { + sky->reflection.create_reflection_fast_filter(storage, sky_use_cubemap_array); + if (sky_use_cubemap_array) { + sky->reflection.update_reflection_mipmaps(storage, 0, sky->reflection.layers.size()); + } + } else { + if (update_single_frame) { + for (int i = 1; i < max_processing_layer; i++) { + sky->reflection.create_reflection_importance_sample(storage, sky_use_cubemap_array, 10, i, sky_ggx_samples_quality); + } + if (sky_use_cubemap_array) { + sky->reflection.update_reflection_mipmaps(storage, 0, sky->reflection.layers.size()); + } + } else { + if (sky_use_cubemap_array) { + // Multi-Frame so just update the first array level + sky->reflection.update_reflection_mipmaps(storage, 0, 1); + } + } + sky->processing_layer = 1; + } + + sky->reflection.dirty = false; + + } else { + if (sky_mode == RS::SKY_MODE_INCREMENTAL && sky->processing_layer < max_processing_layer) { + sky->reflection.create_reflection_importance_sample(storage, sky_use_cubemap_array, 10, sky->processing_layer, sky_ggx_samples_quality); + + if (sky_use_cubemap_array) { + sky->reflection.update_reflection_mipmaps(storage, sky->processing_layer, sky->processing_layer + 1); + } + + sky->processing_layer++; + } + } +} + +void RendererSceneSkyRD::draw(RendererSceneEnvironmentRD *p_env, bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, const CameraMatrix &p_projection, const Transform &p_transform, double p_time) { + ERR_FAIL_COND(!p_env); + + Sky *sky = get_sky(p_env->sky); + ERR_FAIL_COND(!sky); + + SkyMaterialData *material = nullptr; + RID sky_material; + + RS::EnvironmentBG background = p_env->background; + + if (!(background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) || sky) { + ERR_FAIL_COND(!sky); + sky_material = sky_get_material(p_env->sky); + + if (sky_material.is_valid()) { + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + if (!material || !material->shader_data->valid) { + material = nullptr; + } + } + + if (!material) { + sky_material = sky_shader.default_material; + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + } + } + + if (background == RS::ENV_BG_CLEAR_COLOR || background == RS::ENV_BG_COLOR) { + sky_material = sky_scene_state.fog_material; + material = (SkyMaterialData *)storage->material_get_data(sky_material, RendererStorageRD::SHADER_TYPE_SKY); + } + + ERR_FAIL_COND(!material); + + SkyShaderData *shader_data = material->shader_data; + + ERR_FAIL_COND(!shader_data); + + Basis sky_transform = p_env->sky_orientation; + sky_transform.invert(); + + float multiplier = p_env->bg_energy; + float custom_fov = p_env->sky_custom_fov; + // Camera + CameraMatrix camera; + + if (custom_fov) { + float near_plane = p_projection.get_z_near(); + float far_plane = p_projection.get_z_far(); + float aspect = p_projection.get_aspect(); + + camera.set_perspective(custom_fov, aspect, near_plane, far_plane); + + } else { + camera = p_projection; + } + + sky_transform = p_transform.basis * sky_transform; + + if (shader_data->uses_quarter_res) { + PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_QUARTER_RES]; + + RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_QUARTER_RES, sky_shader.default_shader_rd); + + Vector<Color> clear_colors; + clear_colors.push_back(Color(0.0, 0.0, 0.0)); + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(sky->quarter_res_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_DISCARD, clear_colors); + storage->get_effects()->render_sky(draw_list, p_time, sky->quarter_res_framebuffer, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); + RD::get_singleton()->draw_list_end(); + } + + if (shader_data->uses_half_res) { + PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_HALF_RES]; + + RID texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_HALF_RES, sky_shader.default_shader_rd); + + Vector<Color> clear_colors; + clear_colors.push_back(Color(0.0, 0.0, 0.0)); + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(sky->half_res_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_DISCARD, clear_colors); + storage->get_effects()->render_sky(draw_list, p_time, sky->half_res_framebuffer, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); + RD::get_singleton()->draw_list_end(); + } + + PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_BACKGROUND]; + + RID texture_uniform_set; + if (sky) { + texture_uniform_set = sky->get_textures(storage, SKY_TEXTURE_SET_BACKGROUND, sky_shader.default_shader_rd); + } else { + texture_uniform_set = sky_scene_state.fog_only_texture_uniform_set; + } + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_fb, RD::INITIAL_ACTION_CONTINUE, p_can_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, p_can_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); + storage->get_effects()->render_sky(draw_list, p_time, p_fb, sky_scene_state.uniform_set, sky_scene_state.fog_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); + RD::get_singleton()->draw_list_end(); +} + +void RendererSceneSkyRD::invalidate_sky(Sky *p_sky) { + if (!p_sky->dirty) { + p_sky->dirty = true; + p_sky->dirty_list = dirty_sky_list; + dirty_sky_list = p_sky; + } +} + +void RendererSceneSkyRD::update_dirty_skys() { + Sky *sky = dirty_sky_list; + + while (sky) { + bool texture_set_dirty = false; + //update sky configuration if texture is missing + + if (sky->radiance.is_null()) { + int mipmaps = Image::get_image_required_mipmaps(sky->radiance_size, sky->radiance_size, Image::FORMAT_RGBAH) + 1; + + uint32_t w = sky->radiance_size, h = sky->radiance_size; + int layers = roughness_layers; + if (sky->mode == RS::SKY_MODE_REALTIME) { + layers = 8; + if (roughness_layers != 8) { + WARN_PRINT("When using REALTIME skies, roughness_layers should be set to 8 in the project settings for best quality reflections"); + } + } + + if (sky_use_cubemap_array) { + //array (higher quality, 6 times more memory) + RD::TextureFormat tf; + tf.array_layers = layers * 6; + tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.texture_type = RD::TEXTURE_TYPE_CUBE_ARRAY; + tf.mipmaps = mipmaps; + tf.width = w; + tf.height = h; + tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; + + sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + sky->reflection.update_reflection_data(sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME, roughness_layers); + + } else { + //regular cubemap, lower quality (aliasing, less memory) + RD::TextureFormat tf; + tf.array_layers = 6; + tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.texture_type = RD::TEXTURE_TYPE_CUBE; + tf.mipmaps = MIN(mipmaps, layers); + tf.width = w; + tf.height = h; + tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; + + sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + sky->reflection.update_reflection_data(sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME, roughness_layers); + } + texture_set_dirty = true; + } + + // Create subpass buffers if they haven't been created already + if (sky->half_res_pass.is_null() && !RD::get_singleton()->texture_is_valid(sky->half_res_pass) && sky->screen_size.x >= 4 && sky->screen_size.y >= 4) { + RD::TextureFormat tformat; + tformat.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tformat.width = sky->screen_size.x / 2; + tformat.height = sky->screen_size.y / 2; + tformat.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + tformat.texture_type = RD::TEXTURE_TYPE_2D; + + sky->half_res_pass = RD::get_singleton()->texture_create(tformat, RD::TextureView()); + Vector<RID> texs; + texs.push_back(sky->half_res_pass); + sky->half_res_framebuffer = RD::get_singleton()->framebuffer_create(texs); + texture_set_dirty = true; + } + + if (sky->quarter_res_pass.is_null() && !RD::get_singleton()->texture_is_valid(sky->quarter_res_pass) && sky->screen_size.x >= 4 && sky->screen_size.y >= 4) { + RD::TextureFormat tformat; + tformat.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tformat.width = sky->screen_size.x / 4; + tformat.height = sky->screen_size.y / 4; + tformat.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + tformat.texture_type = RD::TEXTURE_TYPE_2D; + + sky->quarter_res_pass = RD::get_singleton()->texture_create(tformat, RD::TextureView()); + Vector<RID> texs; + texs.push_back(sky->quarter_res_pass); + sky->quarter_res_framebuffer = RD::get_singleton()->framebuffer_create(texs); + texture_set_dirty = true; + } + + if (texture_set_dirty) { + for (int i = 0; i < SKY_TEXTURE_SET_MAX; i++) { + if (sky->texture_uniform_sets[i].is_valid() && RD::get_singleton()->uniform_set_is_valid(sky->texture_uniform_sets[i])) { + RD::get_singleton()->free(sky->texture_uniform_sets[i]); + sky->texture_uniform_sets[i] = RID(); + } + } + } + + sky->reflection.dirty = true; + sky->processing_layer = 0; + + Sky *next = sky->dirty_list; + sky->dirty_list = nullptr; + sky->dirty = false; + sky = next; + } + + dirty_sky_list = nullptr; +} + +RID RendererSceneSkyRD::sky_get_material(RID p_sky) const { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND_V(!sky, RID()); + + return sky->material; +} + +RID RendererSceneSkyRD::allocate_sky_rid() { + return sky_owner.allocate_rid(); +} + +void RendererSceneSkyRD::initialize_sky_rid(RID p_rid) { + sky_owner.initialize_rid(p_rid, Sky()); +} + +RendererSceneSkyRD::Sky *RendererSceneSkyRD::get_sky(RID p_sky) const { + return sky_owner.getornull(p_sky); +} + +void RendererSceneSkyRD::free_sky(RID p_sky) { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND(!sky); + + sky->free(storage); + sky_owner.free(p_sky); +} + +void RendererSceneSkyRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND(!sky); + + if (sky->set_radiance_size(p_radiance_size)) { + invalidate_sky(sky); + } +} + +void RendererSceneSkyRD::sky_set_mode(RID p_sky, RS::SkyMode p_mode) { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND(!sky); + + if (sky->set_mode(p_mode)) { + invalidate_sky(sky); + } +} + +void RendererSceneSkyRD::sky_set_material(RID p_sky, RID p_material) { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND(!sky); + + if (sky->set_material(p_material)) { + invalidate_sky(sky); + } +} + +Ref<Image> RendererSceneSkyRD::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND_V(!sky, Ref<Image>()); + + update_dirty_skys(); + + return sky->bake_panorama(storage, p_energy, p_bake_irradiance ? roughness_layers : 0, p_size); +} + +RID RendererSceneSkyRD::sky_get_radiance_texture_rd(RID p_sky) const { + Sky *sky = get_sky(p_sky); + ERR_FAIL_COND_V(!sky, RID()); + + return sky->radiance; +} diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h new file mode 100644 index 0000000000..73390a586b --- /dev/null +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h @@ -0,0 +1,292 @@ +/*************************************************************************/ +/* renderer_scene_sky_rd.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef RENDERING_SERVER_SCENE_SKY_RD_H +#define RENDERING_SERVER_SCENE_SKY_RD_H + +#include "core/templates/rid_owner.h" +#include "servers/rendering/renderer_compositor.h" +#include "servers/rendering/renderer_rd/renderer_scene_environment_rd.h" +#include "servers/rendering/renderer_rd/renderer_storage_rd.h" +#include "servers/rendering/renderer_rd/shaders/sky.glsl.gen.h" +#include "servers/rendering/renderer_scene_render.h" +#include "servers/rendering/rendering_device.h" + +// Forward declare RendererSceneRenderRD so we can pass it into some of our methods, these classes are pretty tightly bound +class RendererSceneRenderRD; + +class RendererSceneSkyRD { +private: + RendererStorageRD *storage; + +public: + enum SkySet { + SKY_SET_UNIFORMS, + SKY_SET_MATERIAL, + SKY_SET_TEXTURES, + SKY_SET_FOG, + SKY_SET_MAX + }; + + enum SkyTextureSetVersion { + SKY_TEXTURE_SET_BACKGROUND, + SKY_TEXTURE_SET_HALF_RES, + SKY_TEXTURE_SET_QUARTER_RES, + SKY_TEXTURE_SET_CUBEMAP, + SKY_TEXTURE_SET_CUBEMAP_HALF_RES, + SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES, + SKY_TEXTURE_SET_MAX + }; + + enum SkyVersion { + SKY_VERSION_BACKGROUND, + SKY_VERSION_HALF_RES, + SKY_VERSION_QUARTER_RES, + SKY_VERSION_CUBEMAP, + SKY_VERSION_CUBEMAP_HALF_RES, + SKY_VERSION_CUBEMAP_QUARTER_RES, + SKY_VERSION_MAX + }; + + // Skys need less info from Directional Lights than the normal shaders + struct SkyDirectionalLightData { + float direction[3]; + float energy; + float color[3]; + float size; + uint32_t enabled; + uint32_t pad[3]; + }; + + struct SkySceneState { + struct UBO { + uint32_t volumetric_fog_enabled; + float volumetric_fog_inv_length; + float volumetric_fog_detail_spread; + + float fog_aerial_perspective; + + float fog_light_color[3]; + float fog_sun_scatter; + + uint32_t fog_enabled; + float fog_density; + + float z_far; + uint32_t directional_light_count; + }; + + UBO ubo; + + SkyDirectionalLightData *directional_lights; + SkyDirectionalLightData *last_frame_directional_lights; + uint32_t max_directional_lights; + uint32_t last_frame_directional_light_count; + RID directional_light_buffer; + RID uniform_set; + RID uniform_buffer; + RID fog_uniform_set; + RID default_fog_uniform_set; + + RID fog_shader; + RID fog_material; + RID fog_only_texture_uniform_set; + } sky_scene_state; + + struct ReflectionData { + struct Layer { + struct Mipmap { + RID framebuffers[6]; + RID views[6]; + Size2i size; + }; + Vector<Mipmap> mipmaps; //per-face view + Vector<RID> views; // per-cubemap view + }; + + struct DownsampleLayer { + struct Mipmap { + RID view; + Size2i size; + }; + Vector<Mipmap> mipmaps; + }; + + RID radiance_base_cubemap; //cubemap for first layer, first cubemap + RID downsampled_radiance_cubemap; + DownsampleLayer downsampled_layer; + RID coefficient_buffer; + + bool dirty = true; + + Vector<Layer> layers; + + void clear_reflection_data(); + void update_reflection_data(int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality, int p_roughness_layers); + void create_reflection_fast_filter(RendererStorageRD *p_storage, bool p_use_arrays); + void create_reflection_importance_sample(RendererStorageRD *p_storage, bool p_use_arrays, int p_cube_side, int p_base_layer, uint32_t p_sky_ggx_samples_quality); + void update_reflection_mipmaps(RendererStorageRD *p_storage, int p_start, int p_end); + }; + + struct SkyShaderData : public RendererStorageRD::ShaderData { + bool valid; + RID version; + + PipelineCacheRD pipelines[SKY_VERSION_MAX]; + Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + Vector<ShaderCompilerRD::GeneratedCode::Texture> texture_uniforms; + + Vector<uint32_t> ubo_offsets; + uint32_t ubo_size; + + String path; + String code; + Map<StringName, RID> default_texture_params; + + bool uses_time; + bool uses_position; + bool uses_half_res; + bool uses_quarter_res; + bool uses_light; + + virtual void set_code(const String &p_Code); + virtual void set_default_texture_param(const StringName &p_name, RID p_texture); + virtual void get_param_list(List<PropertyInfo> *p_param_list) const; + virtual void get_instance_param_list(List<RendererStorage::InstanceShaderParam> *p_param_list) const; + virtual bool is_param_texture(const StringName &p_param) const; + virtual bool is_animated() const; + virtual bool casts_shadows() const; + virtual Variant get_default_parameter(const StringName &p_parameter) const; + virtual RS::ShaderNativeSourceCode get_native_source_code() const; + SkyShaderData(); + virtual ~SkyShaderData(); + }; + + /* Sky shader */ + + struct SkyShader { + SkyShaderRD shader; + ShaderCompilerRD compiler; + + RID default_shader; + RID default_material; + RID default_shader_rd; + } sky_shader; + + struct SkyMaterialData : public RendererStorageRD::MaterialData { + uint64_t last_frame; + SkyShaderData *shader_data; + RID uniform_buffer; + RID uniform_set; + Vector<RID> texture_cache; + Vector<uint8_t> ubo_data; + bool uniform_set_updated; + + virtual void set_render_priority(int p_priority) {} + virtual void set_next_pass(RID p_pass) {} + virtual void update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual ~SkyMaterialData(); + }; + + struct Sky { + RID radiance; + RID half_res_pass; + RID half_res_framebuffer; + RID quarter_res_pass; + RID quarter_res_framebuffer; + Size2i screen_size; + + RID texture_uniform_sets[SKY_TEXTURE_SET_MAX]; + RID uniform_set; + + RID material; + RID uniform_buffer; + + int radiance_size = 256; + + RS::SkyMode mode = RS::SKY_MODE_AUTOMATIC; + + ReflectionData reflection; + bool dirty = false; + int processing_layer = 0; + Sky *dirty_list = nullptr; + + //State to track when radiance cubemap needs updating + SkyMaterialData *prev_material; + Vector3 prev_position; + float prev_time; + + void free(RendererStorageRD *p_storage); + + RID get_textures(RendererStorageRD *p_storage, SkyTextureSetVersion p_version, RID p_default_shader_rd); + bool set_radiance_size(int p_radiance_size); + bool set_mode(RS::SkyMode p_mode); + bool set_material(RID p_material); + Ref<Image> bake_panorama(RendererStorageRD *p_storage, float p_energy, int p_roughness_layers, const Size2i &p_size); + }; + + uint32_t sky_ggx_samples_quality; + bool sky_use_cubemap_array; + Sky *dirty_sky_list = nullptr; + mutable RID_Owner<Sky, true> sky_owner; + int roughness_layers; + + RendererStorageRD::ShaderData *_create_sky_shader_func(); + static RendererStorageRD::ShaderData *_create_sky_shader_funcs(); + + RendererStorageRD::MaterialData *_create_sky_material_func(SkyShaderData *p_shader); + static RendererStorageRD::MaterialData *_create_sky_material_funcs(RendererStorageRD::ShaderData *p_shader); + + RendererSceneSkyRD(); + + void init(RendererStorageRD *p_storage); + + void setup(RendererSceneEnvironmentRD *p_env, RID p_render_buffers, const CameraMatrix &p_projection, const Transform &p_transform, const Size2i p_screen_size, RendererSceneRenderRD *p_scene_render); + void update(RendererSceneEnvironmentRD *p_env, const CameraMatrix &p_projection, const Transform &p_transform, double p_time); + void draw(RendererSceneEnvironmentRD *p_env, bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, const CameraMatrix &p_projection, const Transform &p_transform, double p_time); + + void invalidate_sky(Sky *p_sky); + void update_dirty_skys(); + + RID sky_get_material(RID p_sky) const; + + RID allocate_sky_rid(); + void initialize_sky_rid(RID p_rid); + Sky *get_sky(RID p_sky) const; + void free_sky(RID p_sky); + void sky_set_radiance_size(RID p_sky, int p_radiance_size); + void sky_set_mode(RID p_sky, RS::SkyMode p_mode); + void sky_set_material(RID p_sky, RID p_material); + Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size); + + RID sky_get_radiance_texture_rd(RID p_sky) const; +}; + +#endif /* RENDERING_SERVER_SCENE_SKY_RD_H */ diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h index 68256dc155..cd3d4604eb 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.h +++ b/servers/rendering/renderer_rd/renderer_storage_rd.h @@ -2263,7 +2263,7 @@ public: void render_info_end_capture() {} int get_captured_render_info(RS::RenderInfo p_info) { return 0; } - int get_render_info(RS::RenderInfo p_info) { return 0; } + uint64_t get_render_info(RS::RenderInfo p_info) { return 0; } String get_video_adapter_name() const { return String(); } String get_video_adapter_vendor() const { return String(); } diff --git a/servers/rendering/renderer_rd/shaders/SCsub b/servers/rendering/renderer_rd/shaders/SCsub index c192574ff2..0f85e3fa30 100644 --- a/servers/rendering/renderer_rd/shaders/SCsub +++ b/servers/rendering/renderer_rd/shaders/SCsub @@ -11,7 +11,7 @@ if "RD_GLSL" in env["BUILDERS"]: env.RD_GLSL("cubemap_roughness.glsl") env.RD_GLSL("cubemap_downsampler.glsl") env.RD_GLSL("cubemap_filter.glsl") - env.RD_GLSL("scene_forward.glsl") + env.RD_GLSL("scene_forward_clustered.glsl") env.RD_GLSL("sky.glsl") env.RD_GLSL("tonemap.glsl") env.RD_GLSL("cube_to_dp.glsl") diff --git a/servers/rendering/renderer_rd/shaders/scene_forward.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 1cea9bf8db..7b86dac143 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -4,7 +4,7 @@ VERSION_DEFINES -#include "scene_forward_inc.glsl" +#include "scene_forward_clustered_inc.glsl" /* INPUT ATTRIBS */ @@ -327,7 +327,7 @@ VERTEX_SHADER_CODE VERSION_DEFINES -#include "scene_forward_inc.glsl" +#include "scene_forward_clustered_inc.glsl" /* Varyings */ diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl index d78890fa9e..d78890fa9e 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl diff --git a/servers/rendering/renderer_storage.h b/servers/rendering/renderer_storage.h index 69ad2cc191..22cf6acb19 100644 --- a/servers/rendering/renderer_storage.h +++ b/servers/rendering/renderer_storage.h @@ -608,7 +608,7 @@ public: virtual void render_info_end_capture() = 0; virtual int get_captured_render_info(RS::RenderInfo p_info) = 0; - virtual int get_render_info(RS::RenderInfo p_info) = 0; + virtual uint64_t get_render_info(RS::RenderInfo p_info) = 0; virtual String get_video_adapter_name() const = 0; virtual String get_video_adapter_vendor() const = 0; diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index 61d1efaf22..c6fe6a07e0 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -257,7 +257,7 @@ void RenderingServerDefault::finish() { /* STATUS INFORMATION */ -int RenderingServerDefault::get_render_info(RenderInfo p_info) { +uint64_t RenderingServerDefault::get_render_info(RenderInfo p_info) { return RSG::storage->get_render_info(p_info); } diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 73b463f6e7..c6be07a3de 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -901,7 +901,7 @@ public: /* STATUS INFORMATION */ - virtual int get_render_info(RenderInfo p_info) override; + virtual uint64_t get_render_info(RenderInfo p_info) override; virtual String get_video_adapter_name() const override; virtual String get_video_adapter_vendor() const override; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index cb98a71e86..df1a7d58d0 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -558,13 +558,13 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { return _make_token(TK_ERROR, "Invalid numeric constant"); } hexa_found = true; - } else if (GETCHAR(i) == 'e') { - if (hexa_found || exponent_found || float_suffix_found) { + } else if (GETCHAR(i) == 'e' && !hexa_found) { + if (exponent_found || float_suffix_found) { return _make_token(TK_ERROR, "Invalid numeric constant"); } exponent_found = true; - } else if (GETCHAR(i) == 'f') { - if (hexa_found || exponent_found) { + } else if (GETCHAR(i) == 'f' && !hexa_found) { + if (exponent_found) { return _make_token(TK_ERROR, "Invalid numeric constant"); } float_suffix_found = true; @@ -5926,15 +5926,15 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun pos = _get_tkpos(); tk = _get_token(); if (tk.type != TK_SEMICOLON) { - //all is good _set_error("Expected ';' after discard"); + return ERR_PARSE_ERROR; } p_block->statements.push_back(flow); } else if (tk.type == TK_CF_BREAK) { if (!p_can_break) { - //all is good - _set_error("Breaking is not allowed here"); + _set_error("'break' is not allowed outside of a loop or 'switch' statement"); + return ERR_PARSE_ERROR; } ControlFlowNode *flow = alloc_node<ControlFlowNode>(); @@ -5943,8 +5943,8 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun pos = _get_tkpos(); tk = _get_token(); if (tk.type != TK_SEMICOLON) { - //all is good _set_error("Expected ';' after break"); + return ERR_PARSE_ERROR; } p_block->statements.push_back(flow); @@ -5959,8 +5959,8 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun } else if (tk.type == TK_CF_CONTINUE) { if (!p_can_continue) { - //all is good - _set_error("Continuing is not allowed here"); + _set_error("'continue' is not allowed outside of a loop"); + return ERR_PARSE_ERROR; } ControlFlowNode *flow = alloc_node<ControlFlowNode>(); @@ -5971,6 +5971,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun if (tk.type != TK_SEMICOLON) { //all is good _set_error("Expected ';' after continue"); + return ERR_PARSE_ERROR; } p_block->statements.push_back(flow); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 65065841a6..6a8bb83ec1 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -1419,7 +1419,7 @@ public: INFO_VERTEX_MEM_USED, }; - virtual int get_render_info(RenderInfo p_info) = 0; + virtual uint64_t get_render_info(RenderInfo p_info) = 0; virtual String get_video_adapter_name() const = 0; virtual String get_video_adapter_vendor() const = 0; diff --git a/tests/test_hashing_context.h b/tests/test_hashing_context.h new file mode 100644 index 0000000000..728a5f2cfa --- /dev/null +++ b/tests/test_hashing_context.h @@ -0,0 +1,165 @@ +/*************************************************************************/ +/* test_hashing_context.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef TEST_HASHING_CONTEXT_H +#define TEST_HASHING_CONTEXT_H + +#include "core/crypto/hashing_context.h" + +#include "tests/test_macros.h" + +namespace TestHashingContext { + +TEST_CASE("[HashingContext] Default - MD5/SHA1/SHA256") { + HashingContext ctx; + + static const uint8_t md5_expected[] = { + 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e + }; + static const uint8_t sha1_expected[] = { + 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, + 0xaf, 0xd8, 0x07, 0x09 + }; + static const uint8_t sha256_expected[] = { + 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, + 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 + }; + + CHECK(ctx.start(HashingContext::HASH_MD5) == OK); + PackedByteArray result = ctx.finish(); + REQUIRE(result.size() == 16); + CHECK(memcmp(result.ptr(), md5_expected, 16) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA1) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 20); + CHECK(memcmp(result.ptr(), sha1_expected, 20) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA256) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 32); + CHECK(memcmp(result.ptr(), sha256_expected, 32) == 0); +} + +TEST_CASE("[HashingContext] Multiple updates - MD5/SHA1/SHA256") { + HashingContext ctx; + const String s = "xyz"; + + const PackedByteArray s_byte_parts[] = { + String("x").to_ascii_buffer(), + String("y").to_ascii_buffer(), + String("z").to_ascii_buffer() + }; + + static const uint8_t md5_expected[] = { + 0xd1, 0x6f, 0xb3, 0x6f, 0x09, 0x11, 0xf8, 0x78, 0x99, 0x8c, 0x13, 0x61, 0x91, 0xaf, 0x70, 0x5e + }; + static const uint8_t sha1_expected[] = { + 0x66, 0xb2, 0x74, 0x17, 0xd3, 0x7e, 0x02, 0x4c, 0x46, 0x52, 0x6c, 0x2f, 0x6d, 0x35, 0x8a, 0x75, + 0x4f, 0xc5, 0x52, 0xf3 + }; + static const uint8_t sha256_expected[] = { + 0x36, 0x08, 0xbc, 0xa1, 0xe4, 0x4e, 0xa6, 0xc4, 0xd2, 0x68, 0xeb, 0x6d, 0xb0, 0x22, 0x60, 0x26, + 0x98, 0x92, 0xc0, 0xb4, 0x2b, 0x86, 0xbb, 0xf1, 0xe7, 0x7a, 0x6f, 0xa1, 0x6c, 0x3c, 0x92, 0x82 + }; + + CHECK(ctx.start(HashingContext::HASH_MD5) == OK); + CHECK(ctx.update(s_byte_parts[0]) == OK); + CHECK(ctx.update(s_byte_parts[1]) == OK); + CHECK(ctx.update(s_byte_parts[2]) == OK); + PackedByteArray result = ctx.finish(); + REQUIRE(result.size() == 16); + CHECK(memcmp(result.ptr(), md5_expected, 16) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA1) == OK); + CHECK(ctx.update(s_byte_parts[0]) == OK); + CHECK(ctx.update(s_byte_parts[1]) == OK); + CHECK(ctx.update(s_byte_parts[2]) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 20); + CHECK(memcmp(result.ptr(), sha1_expected, 20) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA256) == OK); + CHECK(ctx.update(s_byte_parts[0]) == OK); + CHECK(ctx.update(s_byte_parts[1]) == OK); + CHECK(ctx.update(s_byte_parts[2]) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 32); + CHECK(memcmp(result.ptr(), sha256_expected, 32) == 0); +} + +TEST_CASE("[HashingContext] Invalid use of start") { + HashingContext ctx; + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.start(static_cast<HashingContext::HashType>(-1)) == ERR_UNAVAILABLE, + "Using invalid hash types should fail."); + ERR_PRINT_ON; + + REQUIRE(ctx.start(HashingContext::HASH_MD5) == OK); + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.start(HashingContext::HASH_MD5) == ERR_ALREADY_IN_USE, + "Calling 'start' twice before 'finish' should fail."); + ERR_PRINT_ON; +} + +TEST_CASE("[HashingContext] Invalid use of update") { + HashingContext ctx; + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.update(PackedByteArray()) == ERR_UNCONFIGURED, + "Calling 'update' before 'start' should fail."); + ERR_PRINT_ON; + + REQUIRE(ctx.start(HashingContext::HASH_MD5) == OK); + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.update(PackedByteArray()) == FAILED, + "Calling 'update' with an empty byte array should fail."); + ERR_PRINT_ON; +} + +TEST_CASE("[HashingContext] Invalid use of finish") { + HashingContext ctx; + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.finish() == PackedByteArray(), + "Calling 'finish' before 'start' should return an empty byte array."); + ERR_PRINT_ON; +} +} // namespace TestHashingContext + +#endif // TEST_HASHING_CONTEXT_H diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 7e9f8319a0..f2a546de9b 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -48,6 +48,7 @@ #include "test_geometry_3d.h" #include "test_gradient.h" #include "test_gui.h" +#include "test_hashing_context.h" #include "test_image.h" #include "test_json.h" #include "test_list.h" diff --git a/tests/test_string.h b/tests/test_string.h index 17f24fb0d8..6febf22765 100644 --- a/tests/test_string.h +++ b/tests/test_string.h @@ -1318,6 +1318,20 @@ TEST_CASE("[String] humanize_size") { CHECK(String::humanize_size(100523550) == "95.86 MiB"); CHECK(String::humanize_size(5345555000) == "4.97 GiB"); } + +TEST_CASE("[String] validate_node_name") { + String numeric_only = "12345"; + CHECK(numeric_only.validate_node_name() == "12345"); + + String name_with_spaces = "Name with spaces"; + CHECK(name_with_spaces.validate_node_name() == "Name with spaces"); + + String name_with_kana = "Name with kana ゴドツ"; + CHECK(name_with_kana.validate_node_name() == "Name with kana ゴドツ"); + + String name_with_invalid_chars = "Name with invalid characters :.@removed!"; + CHECK(name_with_invalid_chars.validate_node_name() == "Name with invalid characters removed!"); +} } // namespace TestString #endif // TEST_STRING_H |