diff options
43 files changed, 631 insertions, 444 deletions
@@ -29,6 +29,8 @@ Eric M <itsjusteza@gmail.com> Eric Rybicki <info@ericrybicki.com> <stratos695@googlemail.com> Erik Selecký <35656626+rxlecky@users.noreply.github.com> Erik Selecký <35656626+rxlecky@users.noreply.github.com> <35656626+SeleckyErik@users.noreply.github.com> +Eveline Jarosz <marqin.pl@gmail.com> +Eveline Jarosz <marqin.pl@gmail.com> <marqin.pl+git@gmail.com> Fabian <supagu@gmail.com> Ferenc Arn <tagcup@yahoo.com> Ferenc Arn <tagcup@yahoo.com> <tagcup@users.noreply.github.com> @@ -43,8 +45,6 @@ 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> Hugo Locurcio <hugo.locurcio@hugo.pro> <hugo.l@openmailbox.org> Hugo Locurcio <hugo.locurcio@hugo.pro> <Calinou@users.noreply.github.com> Hugo Locurcio <hugo.locurcio@hugo.pro> Calinou <calinou@opmbx.org> @@ -107,6 +107,7 @@ Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Pieter-Jan Briers <pieterjan.briers+git@gmail.com> <pieterjan.briers@gmail.com> Poommetee Ketson <poommetee@protonmail.com> Przemysław Gołąb (n-pigeon) <golab.przemyslaw@gmail.com> +Rafał Mikrut <mikrutrafal@protonmail.com> Rafał Mikrut <mikrutrafal@protonmail.com> <mikrutrafal54@gmail.com> Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@posteo.de> Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@users.noreply.github.com> @@ -116,6 +117,7 @@ RaphaelHunter <raphael10241024@gmail.com> <Raphael10241024@gmail.com> RaphaelHunter <raphael10241024@gmail.com> <raphael20141024@gmail.com> Rémi Verschelde <rverschelde@gmail.com> <remi@verschelde.fr> Rhody Lugo <rhodylugo@gmail.com> <rhodylugo@me.com> +Ricardo Subtil <ricasubtil@gmail.com> Robin Hübner <profan@prfn.se> <robinhubner@gmail.com> romulox_x <romulox_x@yahoo.com> Ruslan Mustakov <r.mustakov@gmail.com> <ruslan.mustakov@xored.com> diff --git a/AUTHORS.md b/AUTHORS.md index 5147da3700..0a0e3a9c21 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -36,6 +36,7 @@ name is available. Andrii Doroshenko (Xrayez) Andy Moss (MillionOstrich) Angad Kambli (angad-k) + Anilforextra (AnilBK) Anish Bhobe (KidRigger) Anton Yabchinskiy (a12n) Anutrix @@ -76,6 +77,7 @@ name is available. Eric Rybicki (ericrybick) Erik Selecký (rxlecky) est31 + Eveline Jarosz (Marqin) Fabian Mathews (supagu) Fabio Alessandrelli (Faless) fabriceci @@ -99,7 +101,6 @@ name is available. Hiroshi Ogawa (hi-ogawa) homer666 hoontee - Hubert Jarosz (Marqin) Hugo Locurcio (Calinou) Ian Bishop (ianb96) Ibrahn Sahir (ibrahn) @@ -109,9 +110,9 @@ name is available. J08nY Jakub Grzesik (kubecz3k) James Buck (jbuck3) + Jean-Michel Bernard (jmb462) Jérôme Gully (Nutriz) Jia Jun Chai (SkyLucilfer) - jmb462 Joan Fons Sanchez (JFonS) Johannes Witt (HaSa1002) Johan Manuel (29jm) @@ -119,6 +120,7 @@ name is available. Juan Linietsky (reduz) Julian Murgia (StraToN) Julien Nguyen (Blackiris) + Jummit Justo Delgado (mrcdk) Kelly Thomas (KellyThomas) kleonc @@ -137,7 +139,7 @@ name is available. Marc Gilleron (Zylann) Marcin Zawiejski (dragmz) Marcus Brummer (mbrlabs) - Marcus (MCrafterzz) + Marcus Elg (MCrafterzz) Mariano Javier Suligoy (MarianoGnu) Mario Schlack (hurikhan) Martin Capitanio (capnm) diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index da60213038..e84302620e 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -80,6 +80,13 @@ Copyright: 2008-2016, The Android Open Source Project 2002, Google, Inc. License: Apache-2.0 +Files: ./scene/animation/easing_equations.h +Comment: Robert Penner's Easing Functions +Copyright: 2001, Robert Penner + 2007-2021 Juan Linietsky, Ariel Manzur. + 2014-2021 Godot Engine contributors. +License: Expat + Files: ./servers/physics_3d/collision_solver_3d_sat.cpp Comment: Open Dynamics Engine Copyright: 2001-2003, Russell L. Smith, Alen Ladavac, Nguyen Binh @@ -307,11 +314,6 @@ Comment: Fast Filtering of Reflection Probes Copyright: 2016, Activision Publishing, Inc. License: Expat -Files: ./thirdparty/misc/easing_equations.cpp -Comment: Robert Penner's Easing Functions -Copyright: 2001, Robert Penner -License: BSD-3-clause - Files: ./thirdparty/misc/fastlz.c ./thirdparty/misc/fastlz.h Comment: FastLZ @@ -23,7 +23,6 @@ generous deed immortalized in the next stable release of Godot Engine. ## Silver sponsors ASIFA-Hollywood <https://www.asifa-hollywood.org> - LITSLINK <https://litslink.com> ## Bronze sponsors @@ -41,6 +40,7 @@ generous deed immortalized in the next stable release of Godot Engine. AD Ford alex brown + Andrew Bowen Andrew Dunai Angry Skull anti666 @@ -65,7 +65,6 @@ generous deed immortalized in the next stable release of Godot Engine. Jonah Stich Justin Arnold Justo Delgado Baudí - Kamil Brzezinskip Marcel Kräml Marek Belski Matthieu Huvé @@ -93,24 +92,26 @@ generous deed immortalized in the next stable release of Godot Engine. Acheron Adam Brown albinaask - Alvaro A Baena R Andres Hernandez + Arisaka Mayuki Asher Glick Barugon + Benito Carlo Cabanilla Daniel James David Gehrig David Graham David Snopek - Don B Ed Morley Ellen Poe Florian Rämisch Gamejunkey + Jacobus Dens Jakub Grzesik Javier Roman Joan Fons Johnny IV Young + Jonathan Wright Jon Woodward Karl Werf Klavdij Voncina @@ -119,13 +120,14 @@ generous deed immortalized in the next stable release of Godot Engine. Maciej Pendolski Manuele Finocchiaro Markus Wiesner - Mason Bially Matthew Hillier Michael + Mick Monster Vial Officine Pixel S.n.c. + Patrick Brock + Pedro Silva Petrus Prinsloo - Rene Retro Village Rob Messick Roland Fredenhagen @@ -133,8 +135,10 @@ generous deed immortalized in the next stable release of Godot Engine. Sarksus Scott B Sean + segfault-god Sergey Sofox + Stephan Kessler Stephen Molyneaux Taylor Ritenour Tom Langwaldt @@ -142,22 +146,21 @@ generous deed immortalized in the next stable release of Godot Engine. tukon Vagabond Arcade Vitaliy Sapronenko - William Wold Xeno Coliseum Zaven Muradyan Adam Nakonieczny + Adam Nelson + Alexander Erlemann Alexander J Maynard - Alex de la Mare - Alexey Dyadchenko Alex Khayrullin alice gambrell Andrew Cunningham Andrew Farr + Andriy Antanas Paskauskas Antoni Batchelli Arch Henderson III - Arisaka Mayuki Arthur S. Muszynski Ben Botwin Brandon Hawkinson @@ -181,11 +184,8 @@ generous deed immortalized in the next stable release of Godot Engine. Daniel Tebbutt Darrian Little Dennis Belfrage - Dev To be curious - Digital Denizen Dimitri Nüscheler Donn Eddy - Easypete Edgar Sun Eric Eric Brand @@ -200,6 +200,7 @@ generous deed immortalized in the next stable release of Godot Engine. General Chicken Geoffroy Warin GGGames.org + gisora GrayDwarf Guilherme Felipe de C. G. da Silva Harvey Fong @@ -210,22 +211,22 @@ generous deed immortalized in the next stable release of Godot Engine. Hunter Barabas Jake Burga James Couzens + James Zahn Jan Sælid Jared Jared White - Jeppe Zapp + Jennifer Wilcox Jesús Chicharro Joel Fivat Johnathan Kupferer - John Knight Jonathan Turner + Josef Stumpfegger Jose Malheiro Jose Manuel Muñoz Perez Joseph Crane Joshie Sparks Joshua Flores Joshua Lesperance - Juan T Chen Juan Velandia Judd Julián Absatz @@ -237,13 +238,13 @@ generous deed immortalized in the next stable release of Godot Engine. kinfox Kis Levente Lorand Kos - Lain Ballard Laszlo Kiss leetNightshade Leo Fidel R Liban Liam Smyth LoparPanda Luca Vazzano + Luke MadScientistCarl Marcus Dobler Marcus Richter @@ -253,6 +254,7 @@ generous deed immortalized in the next stable release of Godot Engine. Martin Soucek matt Matt Greene + Matthew Hall Matthias Toepp Mecha Kaiju X medecau @@ -264,27 +266,24 @@ generous deed immortalized in the next stable release of Godot Engine. MikadoSC Mike Barbee minz1 - MuffinManKen nate etan Nick Abousselam + Nicola Cocchiaro Nicole Barovic + Nikita Bliznyuk Oliver Dick Oscar Campos - Patrick Ting Paul Hocker Paul Von Zimmerman Pavel Kotlyar - Pedro Silva Pete Goodwin - Peter Richmond Petr Malac PhaineOfCatz - pl + Piotr Wyszyński + Pyxl Raymond Harris - Renato Fontes Rene Tailleur Rhodochrone - Ricardo Alcantara Rob Robert McDermott Robert Willes @@ -295,6 +294,7 @@ generous deed immortalized in the next stable release of Godot Engine. Ronnie Ashlock Ronny Mühle Ryan Scott + Samuel Hummerstone Samuel Judd Samuel Smart Sean Morgan @@ -304,6 +304,7 @@ generous deed immortalized in the next stable release of Godot Engine. Sergey Fonaryov Sergey Minakov Shishir Tandale + Sing Chun Lee SKison Song Junwoo spacechase0 @@ -316,6 +317,7 @@ generous deed immortalized in the next stable release of Godot Engine. Thomas Kurz Tim Howard Tobias Bocanegra + Tobias Raggl Todd Smith Torbulous toto bibi @@ -333,37 +335,36 @@ generous deed immortalized in the next stable release of Godot Engine. Yifan Lai Yuancheng Zhang Zie Weaver - Zoran Kukulj ## Silver donors 1D_Inc Aaron Oldenburg + A. B. Actual_Dio Adam Brunnmeier Adam Carr Adam Long Adam McCurdy Adam N Webber + Adam R Pope Adam Smeltzer Adam Szymański Adisibio Adrien de Pierres - Agar3s - Giovanny Beltrán Ahmet Kalyoncu Aidan O'Flannagain Aki Mimoto Alan Beauchamp + Alberto Salazar Muñoz Alberto Vilches Albin Jonasson Svärdsby Alder Stefano AleMax + Ales Jelovcan Alessandro Senese - Alexander Erlemann Alexander Ravenheart - Alexander Ryndin Alexander Walter (SilvanuZ) - Alexandre Beaudoin Alex Chan Alex Clavelle alex raeside @@ -379,6 +380,7 @@ generous deed immortalized in the next stable release of Godot Engine. Ano Nim Anthony Avina Anton Bouwer + Antti Vesanen Arch Toasty Arda Erol Armin Preiml @@ -394,14 +396,17 @@ generous deed immortalized in the next stable release of Godot Engine. Bartosz Bielecki Benedikt Benoit Jauvin-Girard + Ben Ridley Ben Vercammen Bernd Jänichen Bernhard Werner Bill Thibault + bitbrain Bjarne Voigtländer Black Block blackjacksike Blair Allen + Blunderjack Bobby CC Wong Borkzilla Bram @@ -409,19 +414,19 @@ generous deed immortalized in the next stable release of Godot Engine. Brian Klein Brodie Fairhall Bronson Zgeb - Bùi Việt Thành + Bruno Hurth Burney Waring bwhirt Caleb Gartner Caleb Makela Cameron Meyer Carlos Cejudo + Carlos Rios Carl van der Geest Casey Cassidy James Cédric Givord Chad Steadman - Charles Alston Chris Chapin Chris Langford Christian Clavet @@ -447,13 +452,16 @@ generous deed immortalized in the next stable release of Godot Engine. David Bôle David May David Maziarka + David Rapisarda deadwithbread Devin Carraway Diego Pereira Dima Fedotov + Dimitri Roche Dmitry Fisher Dmytro Korchynskyi Dominik Wetzel + Don B Douglas Plumley Dragontrapper Dr Ewan Murray @@ -473,12 +481,12 @@ generous deed immortalized in the next stable release of Godot Engine. Eric Walkingshaw Eric Williams Erkki Seppälä - Evan Rose Faisal Alkubaisi Fancy Ants Studios fby Fekinox Felix Bohmann + Filip Lundby Forty Doubleu Francisco Garcia Florez Francois Holland @@ -489,6 +497,7 @@ generous deed immortalized in the next stable release of Godot Engine. George Marques Georgi Petkov Graham Overby + Green Fox Greg Lincoln Greg Olson Greyson Richey @@ -503,7 +512,6 @@ generous deed immortalized in the next stable release of Godot Engine. Hunter Jones Ian ORourke Ian Williams - Iiari IndustrialRobot Ivan Nikolaev iveks @@ -515,6 +523,7 @@ generous deed immortalized in the next stable release of Godot Engine. Jako Danar James James A F Manley + James Gary James Guardino James Quincy James Thomas @@ -546,7 +555,6 @@ generous deed immortalized in the next stable release of Godot Engine. Jonatan R Jonathan Bieber Jonathan G - Jonathan Wright Jon Bonazza Jon Sully Jordan West @@ -565,9 +573,9 @@ generous deed immortalized in the next stable release of Godot Engine. Julian Murgia June Little Justin Hamilton + Justin Hurst Justin Oaksford Justin Spedding - Justin W. Flory KaDokta Karol Porzycki Keedong Park @@ -575,7 +583,6 @@ generous deed immortalized in the next stable release of Godot Engine. Keith Bradner Kenji Kawabata Ken Minardo - Kenneth Lee Kent Jofur Ketafuki Kevin van Rooijen @@ -585,6 +592,7 @@ generous deed immortalized in the next stable release of Godot Engine. Kolandrious Konstantin Goncharov kormai + Kquona Krishna Nadoor Kristian Nygaard Jensen KR McGinley @@ -596,7 +604,6 @@ generous deed immortalized in the next stable release of Godot Engine. Kyuppin Lasse le Dous Laurent CHEA - Laurent Tréguier Laxman Pradhan LEMMiNO Leonardo Dimano @@ -614,11 +621,12 @@ generous deed immortalized in the next stable release of Godot Engine. Mark Malone Markus Martin Markus Michael Egger + Markus Ort Martin FIbik Martin Holas Martin Liška Martin Trbola - Marvin + Martin Zabinski Mathieu Matt Edwards Matthew Booe @@ -642,6 +650,7 @@ generous deed immortalized in the next stable release of Godot Engine. Mike Mike Birkhead Mike Copley + Mitchell Mitchell J. Wagner MJacred ModularMind @@ -666,25 +675,21 @@ generous deed immortalized in the next stable release of Godot Engine. Nicolas Goll-Perrier Nicolas Rosset Nicolas SAN AGUSTIN + Nils Nordmark Nima Farid Noel Billig - Nuno Dionísio NZ oceoh Okatima Oleg Reva - Omar Delarosa - Orfist Oriol Muñoz Princep oscar1000108 Oscar Domingo Pascal - Patrick Brock Patrick Nafarrete Paul Gieske Paweł Kowal Paweł Łyczkowski - p_brighenti Peter Höglund Philip Cohoe Philip Ludington (MrPhil) @@ -695,43 +700,44 @@ generous deed immortalized in the next stable release of Godot Engine. pwab RabidTunes Rackat + RackBar Dingum Rad Cat Rafa Laguna Raffaele Aramo Rainer Amler Rami Hanano Rammeow - RAMupgrade Remi Rampin Reneator + René Habermann Riccardo Marini Richard Hayes Richard Ivánek Richard Néveri Riley - Robert Farr (Larington) Rob Ruana Rodrigo Loli Roger Smith + Roglozor Roland Rząsa Roman Tinkov Ronald Ho Hip (CrimsonZA) Ronan - Ross Squires Roy Scayged + Ryan Ryan Groom Sam Caulfield Sam Edson Scott Longley Sean Lynch Sebastian Michailidis - segfault-god SeongWan Kim SeungJong k Shaidak Shane Shane Sicienski Shane Spoor + Silver1063 simdee Simon Jonas Larsen Simon Schoenenberger @@ -741,10 +747,12 @@ generous deed immortalized in the next stable release of Godot Engine. smbe19 smo1704 Solene Waked + Sophie Winter Spencer Everhart Squirrel Stéphane Roussel Steve Cloete + Steven Drovie summerblind Sung soo Choi Svenne Krap @@ -753,6 +761,7 @@ generous deed immortalized in the next stable release of Godot Engine. Tarch Terry the9thdude + The Domis4 Theodore Lindsey TheVoiceInMyHead thomas @@ -790,6 +799,7 @@ generous deed immortalized in the next stable release of Godot Engine. Vi Watch Vladimir Savin Vladislav Smirnov + VoxelVisions.com Vytenis Narušis werner mendizabal Wiley Thompson diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 9af3f868d2..045ab67ce8 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -151,8 +151,8 @@ Face3::Side Face3::get_side_of(const Face3 &p_face, ClockDirection p_clock_dir) } Vector3 Face3::get_random_point_inside() const { - real_t a = Math::random(0, 1); - real_t b = Math::random(0, 1); + real_t a = Math::random(0.0, 1.0); + real_t b = Math::random(0.0, 1.0); if (a > b) { SWAP(a, b); } diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index 060b619892..496a557844 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -279,7 +279,7 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, const } //construct matrix - Transform2D res(Math::atan2(v.y, v.x), p1.lerp(p2, p_c)); + Transform2D res(v.angle(), p1.lerp(p2, p_c)); res.scale_basis(s1.lerp(s2, p_c)); return res; } diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index b53dc05a00..16e43d7d06 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -79,7 +79,7 @@ real_t Vector2::angle_to(const Vector2 &p_vector2) const { } real_t Vector2::angle_to_point(const Vector2 &p_vector2) const { - return Math::atan2(y - p_vector2.y, x - p_vector2.x); + return (*this - p_vector2).angle(); } real_t Vector2::dot(const Vector2 &p_other) const { diff --git a/core/templates/pooled_list.h b/core/templates/pooled_list.h index b4a6d2d1dd..b139dadb75 100644 --- a/core/templates/pooled_list.h +++ b/core/templates/pooled_list.h @@ -28,13 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#pragma once +#ifndef POOLED_LIST_H +#define POOLED_LIST_H + +#include "core/templates/local_vector.h" // Simple template to provide a pool with O(1) allocate and free. // The freelist could alternatively be a linked list placed within the unused elements // to use less memory, however a separate freelist is probably more cache friendly. - -// NOTE : Take great care when using this with non POD types. The construction and destruction +// +// NOTE: Take great care when using this with non POD types. The construction and destruction // is done in the LocalVector, NOT as part of the pool. So requesting a new item does not guarantee // a constructor is run, and free does not guarantee a destructor. // You should generally handle clearing @@ -42,9 +45,6 @@ // This is by design for fastest use in the BVH. If you want a more general pool // that does call constructors / destructors on request / free, this should probably be // a separate template. - -#include "core/templates/local_vector.h" - template <class T, bool force_trivial = false> class PooledList { LocalVector<T, uint32_t, force_trivial> list; @@ -93,3 +93,5 @@ public: _used_size--; } }; + +#endif // POOLED_LIST_H diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index f487e718f4..dcded6e61f 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -377,11 +377,11 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const { return obj->emit_signal(name, p_arguments, p_argcount); } -Error Signal::connect(const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) { +Error Signal::connect(const Callable &p_callable, uint32_t p_flags) { Object *object = get_object(); ERR_FAIL_COND_V(!object, ERR_UNCONFIGURED); - return object->connect(name, p_callable, p_binds, p_flags); + return object->connect(name, p_callable, varray(), p_flags); } void Signal::disconnect(const Callable &p_callable) { diff --git a/core/variant/callable.h b/core/variant/callable.h index 52094af3aa..de886492ea 100644 --- a/core/variant/callable.h +++ b/core/variant/callable.h @@ -159,7 +159,7 @@ public: operator String() const; Error emit(const Variant **p_arguments, int p_argcount) const; - Error connect(const Callable &p_callable, const Vector<Variant> &p_binds = Vector<Variant>(), uint32_t p_flags = 0); + Error connect(const Callable &p_callable, uint32_t p_flags = 0); void disconnect(const Callable &p_callable); bool is_connected(const Callable &p_callable) const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index c3fe4117ac..32d6778a2b 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1690,7 +1690,7 @@ static void _register_variant_builtin_methods() { bind_method(Signal, get_object_id, sarray(), varray()); bind_method(Signal, get_name, sarray(), varray()); - bind_method(Signal, connect, sarray("callable", "binds", "flags"), varray(Array(), 0)); + bind_method(Signal, connect, sarray("callable", "flags"), varray(0)); bind_method(Signal, disconnect, sarray("callable"), varray()); bind_method(Signal, is_connected, sarray("callable"), varray()); bind_method(Signal, get_connections, sarray(), varray()); diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml index b70725123b..f78266a20c 100644 --- a/doc/classes/Signal.xml +++ b/doc/classes/Signal.xml @@ -32,10 +32,16 @@ <method name="connect"> <return type="int" /> <argument index="0" name="callable" type="Callable" /> - <argument index="1" name="binds" type="Array" default="[]" /> - <argument index="2" name="flags" type="int" default="0" /> - <description> - Connects this signal to the specified [Callable], optionally providing binds and connection flags. + <argument index="1" name="flags" type="int" default="0" /> + <description> + Connects this signal to the specified [Callable], optionally providing connection flags. You can provide additional arguments to the connected method call by using [method Callable.bind]. + [codeblock] + for button in $Buttons.get_children(): + button.pressed.connect(on_pressed.bind(button)) + + func on_pressed(button): + print(button.name, " was pressed") + [/codeblock] </description> </method> <method name="disconnect"> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index ede6e2fdd5..f94018c96b 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -86,6 +86,7 @@ [code]initial_value[/code] is the starting value of the interpolation. [code]delta_value[/code] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code]. [code]duration[/code] is the total time of the interpolation. + [b]Note:[/b] If [code]duration[/code] is equal to [code]0[/code], the method will always return the final value, regardless of [code]elapsed_time[/code] provided. </description> </method> <method name="is_running"> diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 5fda1c76ef..ab857dc3ad 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -501,6 +501,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da error->set_text(0, time); error->set_text_align(0, TreeItem::ALIGN_LEFT); + const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), SNAME("Editor")); + error->set_custom_color(0, color); + error->set_custom_color(1, color); + String error_title; if (oe.callstack.size() > 0) { // If available, use the script's stack in the error title. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b4850e6ebb..e719797e03 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6105,9 +6105,9 @@ EditorNode::EditorNode() { dock_tab_move_right = memnew(Button); dock_tab_move_right->set_flat(true); if (gui_base->is_layout_rtl()) { - dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); - } else { dock_tab_move_right->set_icon(theme->get_icon("Back", "EditorIcons")); + } else { + dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); } dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE); dock_tab_move_right->connect("pressed", callable_mp(this, &EditorNode::_dock_move_right)); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 648e60a554..5b52554335 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -127,12 +127,7 @@ void ImportDock::set_edit_path(const String &p_path) { } } - import_as->add_separator(); - import_as->add_item(TTR("Keep File (No Import)")); - import_as->set_item_metadata(import_as->get_item_count() - 1, "keep"); - if (importer_name == "keep") { - import_as->select(import_as->get_item_count() - 1); - } + _add_keep_import_option(importer_name); import->set_disabled(false); import_as->set_disabled(false); @@ -141,6 +136,15 @@ void ImportDock::set_edit_path(const String &p_path) { imported->set_text(p_path.get_file()); } +void ImportDock::_add_keep_import_option(const String &p_importer_name) { + import_as->add_separator(); + import_as->add_item(TTR("Keep File (No Import)")); + import_as->set_item_metadata(import_as->get_item_count() - 1, "keep"); + if (p_importer_name == "keep") { + import_as->select(import_as->get_item_count() - 1); + } +} + void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { List<ResourceImporter::ImportOption> options; @@ -270,6 +274,8 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { } } + _add_keep_import_option(params->importer->get_importer_name()); + _update_preset_menu(); params->paths = p_paths; diff --git a/editor/import_dock.h b/editor/import_dock.h index 2be48dd505..3c28bbcd89 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -66,6 +66,7 @@ class ImportDock : public VBoxContainer { void _importer_selected(int i_idx); void _update_options(const Ref<ConfigFile> &p_config = Ref<ConfigFile>()); void _update_preset_menu(); + void _add_keep_import_option(const String &p_importer_name); void _property_toggled(const StringName &p_prop, bool p_checked); void _reimport_attempt(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 1758ba7048..faa3b58dbb 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2927,7 +2927,7 @@ void CanvasItemEditor::_draw_ruler_tool() { viewport->draw_string(font, text_pos, TS->format_number(vformat("%.1f px", length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); if (draw_secondary_lines) { - const real_t horizontal_angle_rad = atan2(length_vector.y, length_vector.x); + const real_t horizontal_angle_rad = length_vector.angle(); const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad; const int horizontal_angle = round(180 * horizontal_angle_rad / Math_PI); const int vertical_angle = round(180 * vertical_angle_rad / Math_PI); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 903a3689b0..5ac58795d1 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -362,6 +362,7 @@ void GPUParticles3DEditor::_generate_emission_points() { Ref<ImageTexture> tex; tex.instantiate(); + tex->create_from_image(image); Ref<ParticlesMaterial> material = node->get_process_material(); ERR_FAIL_COND(material.is_null()); @@ -390,6 +391,7 @@ void GPUParticles3DEditor::_generate_emission_points() { Ref<ImageTexture> tex2; tex2.instantiate(); + tex2->create_from_image(image2); material->set_emission_normal_texture(tex2); } else { diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 3207a989bd..16cafda899 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -244,6 +244,7 @@ void ItemListEditor::_node_removed(Node *p_node) { void ItemListEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) { add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + clear_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); del_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } else if (p_notification == NOTIFICATION_READY) { get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed)); @@ -258,6 +259,12 @@ void ItemListEditor::_add_pressed() { item_plugins[selected_idx]->add_item(); } +void ItemListEditor::_clear_pressed() { + for (int i = item_plugins[selected_idx]->get_item_count() - 1; i >= 0; i--) { + item_plugins[selected_idx]->erase(i); + } +} + void ItemListEditor::_delete_pressed() { if (selected_idx == -1) { return; @@ -350,6 +357,11 @@ ItemListEditor::ItemListEditor() { hbc->add_spacer(); + clear_button = memnew(Button); + clear_button->set_text(TTR("Delete All")); + hbc->add_child(clear_button); + clear_button->connect("pressed", callable_mp(this, &ItemListEditor::_clear_pressed)); + del_button = memnew(Button); del_button->set_text(TTR("Delete")); hbc->add_child(del_button); diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h index 8c77f3d952..8f61aef083 100644 --- a/editor/plugins/item_list_editor_plugin.h +++ b/editor/plugins/item_list_editor_plugin.h @@ -204,6 +204,7 @@ class ItemListEditor : public HBoxContainer { Tree *tree; Button *add_button; Button *del_button; + Button *clear_button; int selected_idx; @@ -213,6 +214,7 @@ class ItemListEditor : public HBoxContainer { void _add_pressed(); void _delete_pressed(); + void _clear_pressed(); void _node_removed(Node *p_node); diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index bf21c8510a..9ea9fc61de 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -2138,7 +2138,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a retvalue = gdfs; - Error err = sig.connect(Callable(gdfs.ptr(), "_signal_callback"), varray(gdfs), Object::CONNECT_ONESHOT); + Error err = sig.connect(callable_bind(Callable(gdfs.ptr(), "_signal_callback"), retvalue), Object::CONNECT_ONESHOT); if (err != OK) { err_text = "Error connecting to signal: " + sig.get_name() + " during await."; OPCODE_BREAK; diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 2336153c0d..ef1411fb3b 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -131,20 +131,6 @@ hb_position_t TextServerAdvanced::hb_bmp_get_glyph_h_kerning(hb_font_t *p_font, return bm_font->face->kerning_map[Vector2i(p_left_glyph, p_right_glyph)].x * 64; } -hb_position_t TextServerAdvanced::hb_bmp_get_glyph_v_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data) { - const hb_bmp_font_t *bm_font = reinterpret_cast<const hb_bmp_font_t *>(p_font_data); - - if (!bm_font->face) { - return 0; - } - - if (!bm_font->face->kerning_map.has(Vector2i(p_left_glyph, p_right_glyph))) { - return 0; - } - - return bm_font->face->kerning_map[Vector2i(p_left_glyph, p_right_glyph)].y * 64; -} - hb_bool_t TextServerAdvanced::hb_bmp_get_glyph_v_origin(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_position_t *r_x, hb_position_t *r_y, void *p_user_data) { const hb_bmp_font_t *bm_font = reinterpret_cast<const hb_bmp_font_t *>(p_font_data); @@ -205,7 +191,6 @@ void TextServerAdvanced::hb_bmp_create_font_funcs() { hb_font_funcs_set_glyph_v_advance_func(funcs, hb_bmp_get_glyph_v_advance, nullptr, nullptr); hb_font_funcs_set_glyph_v_origin_func(funcs, hb_bmp_get_glyph_v_origin, nullptr, nullptr); hb_font_funcs_set_glyph_h_kerning_func(funcs, hb_bmp_get_glyph_h_kerning, nullptr, nullptr); - hb_font_funcs_set_glyph_v_kerning_func(funcs, hb_bmp_get_glyph_v_kerning, nullptr, nullptr); hb_font_funcs_set_glyph_extents_func(funcs, hb_bmp_get_glyph_extents, nullptr, nullptr); hb_font_funcs_make_immutable(funcs); diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index 5989035800..fc0e7a09a7 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -269,7 +269,6 @@ class TextServerAdvanced : public TextServer { static hb_position_t hb_bmp_get_glyph_h_advance(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, void *p_user_data); static hb_position_t hb_bmp_get_glyph_v_advance(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, void *p_user_data); static hb_position_t hb_bmp_get_glyph_h_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data); - static hb_position_t hb_bmp_get_glyph_v_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data); static hb_bool_t hb_bmp_get_glyph_v_origin(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_position_t *r_x, hb_position_t *r_y, void *p_user_data); static hb_bool_t hb_bmp_get_glyph_extents(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_glyph_extents_t *r_extents, void *p_user_data); static hb_bool_t hb_bmp_get_font_h_extents(hb_font_t *p_font, void *p_font_data, hb_font_extents_t *r_metrics, void *p_user_data); diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub index 71c402358f..8726d32d61 100644 --- a/platform/uwp/SCsub +++ b/platform/uwp/SCsub @@ -7,7 +7,7 @@ files = [ "#platform/windows/windows_terminal_logger.cpp", "joypad_uwp.cpp", "context_egl_uwp.cpp", - "app.cpp", + "app_uwp.cpp", "os_uwp.cpp", ] diff --git a/platform/uwp/app.cpp b/platform/uwp/app_uwp.cpp index 1da17ffc5d..50e33e6c49 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app_uwp.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* app.cpp */ +/* app_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -32,7 +32,7 @@ // This file demonstrates how to initialize EGL in a Windows Store app, using ICoreWindow. // -#include "app.h" +#include "app_uwp.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" diff --git a/platform/uwp/app.h b/platform/uwp/app_uwp.h index 0b02527dae..8d4a0b90c3 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app_uwp.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* app.h */ +/* app_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#pragma once +#ifndef APP_UWP_H +#define APP_UWP_H #include <string> @@ -111,3 +112,4 @@ namespace GodotUWP } /* clang-format on */ +#endif // APP_UWP_H diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index cf2632f380..bf26ec1f20 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -727,7 +727,7 @@ void CPUParticles2D::_particles_process(double p_delta) { p.hue_rot_rand = Math::randf(); p.anim_offset_rand = Math::randf(); - real_t angle1_rad = Math::atan2(direction.y, direction.x) + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread); + real_t angle1_rad = direction.angle() + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread); Vector2 rot = Vector2(Math::cos(angle1_rad), Math::sin(angle1_rad)); p.velocity = rot * Math::lerp(parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], Math::randf()); diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index 72ea6541e3..cbf0d50c4e 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -464,7 +464,7 @@ void NavigationRegion2D::_notification(int p_what) { draw_line(a, b, doors_color); // Draw a circle to illustrate the margins. - real_t angle = (b - a).angle(); + real_t angle = b.angle_to_point(a); draw_arc(a, radius, angle + Math_PI / 2.0, angle - Math_PI / 2.0 + Math_TAU, 10, doors_color); draw_arc(b, radius, angle - Math_PI / 2.0, angle + Math_PI / 2.0, 10, doors_color); } diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 4bbbc3575d..63a0fb9b89 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -456,7 +456,7 @@ void Bone2D::calculate_length_and_rotation() { if (child) { Vector2 child_local_pos = to_local(child->get_global_position()); length = child_local_pos.length(); - bone_angle = Math::atan2(child_local_pos.normalized().y, child_local_pos.normalized().x); + bone_angle = child_local_pos.normalized().angle(); calculated = true; break; } diff --git a/scene/animation/SCsub b/scene/animation/SCsub index cc33a5af84..d0aa0bc8aa 100644 --- a/scene/animation/SCsub +++ b/scene/animation/SCsub @@ -6,11 +6,8 @@ Import("env") thirdparty_obj = [] -thirdparty_sources = "#thirdparty/misc/easing_equations.cpp" - env_thirdparty = env.Clone() env_thirdparty.disable_warnings() -env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources) env.scene_sources += thirdparty_obj # Godot source files diff --git a/scene/animation/easing_equations.h b/scene/animation/easing_equations.h new file mode 100644 index 0000000000..c38d083b7f --- /dev/null +++ b/scene/animation/easing_equations.h @@ -0,0 +1,405 @@ +/*************************************************************************/ +/* easing_equations.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. */ +/*************************************************************************/ + +/* + * Derived from Robert Penner's easing equations: http://robertpenner.com/easing/ + * + * Copyright (c) 2001 Robert Penner + * + * 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 EASING_EQUATIONS_H +#define EASING_EQUATIONS_H + +namespace linear { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return c * t / d + b; +} +}; // namespace linear + +namespace sine { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return -c * cos(t / d * (Math_PI / 2)) + c + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + return c * sin(t / d * (Math_PI / 2)) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + return -c / 2 * (cos(Math_PI * t / d) - 1) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace sine + +namespace quint { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return c * pow(t / d, 5) + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + return c * (pow(t / d - 1, 5) + 1) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + t = t / d * 2; + + if (t < 1) { + return c / 2 * pow(t, 5) + b; + } + return c / 2 * (pow(t - 2, 5) + 2) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace quint + +namespace quart { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return c * pow(t / d, 4) + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + return -c * (pow(t / d - 1, 4) - 1) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + t = t / d * 2; + + if (t < 1) { + return c / 2 * pow(t, 4) + b; + } + return -c / 2 * (pow(t - 2, 4) - 2) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace quart + +namespace quad { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return c * pow(t / d, 2) + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + t /= d; + return -c * t * (t - 2) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + t = t / d * 2; + + if (t < 1) { + return c / 2 * pow(t, 2) + b; + } + return -c / 2 * ((t - 1) * (t - 3) - 1) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace quad + +namespace expo { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + if (t == 0) { + return b; + } + return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + if (t == d) { + return b + c; + } + return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + if (t == 0) { + return b; + } + + if (t == d) { + return b + c; + } + + t = t / d * 2; + + if (t < 1) { + return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005; + } + return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace expo + +namespace elastic { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + if (t == 0) { + return b; + } + + t /= d; + if (t == 1) { + return b + c; + } + + t -= 1; + float p = d * 0.3f; + float a = c * pow(2, 10 * t); + float s = p / 4; + + return -(a * sin((t * d - s) * (2 * Math_PI) / p)) + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + if (t == 0) { + return b; + } + + t /= d; + if (t == 1) { + return b + c; + } + + float p = d * 0.3f; + float s = p / 4; + + return (c * pow(2, -10 * t) * sin((t * d - s) * (2 * Math_PI) / p) + c + b); +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + if (t == 0) { + return b; + } + + if ((t /= d / 2) == 2) { + return b + c; + } + + float p = d * (0.3f * 1.5f); + float a = c; + float s = p / 4; + + if (t < 1) { + t -= 1; + a *= pow(2, 10 * t); + return -0.5f * (a * sin((t * d - s) * (2 * Math_PI) / p)) + b; + } + + t -= 1; + a *= pow(2, -10 * t); + return a * sin((t * d - s) * (2 * Math_PI) / p) * 0.5f + c + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace elastic + +namespace cubic { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + t /= d; + return c * t * t * t + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + t = t / d - 1; + return c * (t * t * t + 1) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + t /= d / 2; + if (t < 1) { + return c / 2 * t * t * t + b; + } + + t -= 2; + return c / 2 * (t * t * t + 2) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace cubic + +namespace circ { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + t /= d; + return -c * (sqrt(1 - t * t) - 1) + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + t = t / d - 1; + return c * sqrt(1 - t * t) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + t /= d / 2; + if (t < 1) { + return -c / 2 * (sqrt(1 - t * t) - 1) + b; + } + + t -= 2; + return c / 2 * (sqrt(1 - t * t) + 1) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace circ + +namespace bounce { +static real_t out(real_t t, real_t b, real_t c, real_t d) { + t /= d; + + if (t < (1 / 2.75f)) { + return c * (7.5625f * t * t) + b; + } + + if (t < (2 / 2.75f)) { + t -= 1.5f / 2.75f; + return c * (7.5625f * t * t + 0.75f) + b; + } + + if (t < (2.5 / 2.75)) { + t -= 2.25f / 2.75f; + return c * (7.5625f * t * t + 0.9375f) + b; + } + + t -= 2.625f / 2.75f; + return c * (7.5625f * t * t + 0.984375f) + b; +} + +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return c - out(d - t, 0, c, d) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return in(t * 2, b, c / 2, d); + } + return out(t * 2 - d, b + c / 2, c / 2, d); +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace bounce + +namespace back { +static real_t in(real_t t, real_t b, real_t c, real_t d) { + float s = 1.70158f; + t /= d; + + return c * t * t * ((s + 1) * t - s) + b; +} + +static real_t out(real_t t, real_t b, real_t c, real_t d) { + float s = 1.70158f; + t = t / d - 1; + + return c * (t * t * ((s + 1) * t + s) + 1) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + float s = 1.70158f * 1.525f; + t /= d / 2; + + if (t < 1) { + return c / 2 * (t * t * ((s + 1) * t - s)) + b; + } + + t -= 2; + return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b; +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + return in(t * 2 - d, b + c / 2, c / 2, d); +} +}; // namespace back + +#endif diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 2847031375..c43b83747b 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -30,8 +30,23 @@ #include "tween.h" +#include "scene/animation/easing_equations.h" #include "scene/main/node.h" +Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = { + { &linear::in, &linear::in, &linear::in, &linear::in }, // Linear is the same for each easing. + { &sine::in, &sine::out, &sine::in_out, &sine::out_in }, + { &quint::in, &quint::out, &quint::in_out, &quint::out_in }, + { &quart::in, &quart::out, &quart::in_out, &quart::out_in }, + { &quad::in, &quad::out, &quad::in_out, &quad::out_in }, + { &expo::in, &expo::out, &expo::in_out, &expo::out_in }, + { &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in }, + { &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in }, + { &circ::in, &circ::out, &circ::in_out, &circ::out_in }, + { &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in }, + { &back::in, &back::out, &back::in_out, &back::out_in }, +}; + void Tweener::set_tween(Ref<Tween> p_tween) { tween = p_tween; } @@ -317,6 +332,16 @@ bool Tween::should_pause() { return pause_mode != TWEEN_PAUSE_PROCESS; } +real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t p_time, real_t p_initial, real_t p_delta, real_t p_duration) { + if (p_duration == 0) { + // Special case to avoid dividing by 0 in equations. + return p_initial + p_delta; + } + + interpolater func = interpolaters[p_trans_type][p_ease_type]; + return func(p_time, p_initial, p_delta, p_duration); +} + Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, TransitionType p_trans, EaseType p_ease) { ERR_FAIL_INDEX_V(p_trans, TransitionType::TRANS_MAX, Variant()); ERR_FAIL_INDEX_V(p_ease, EaseType::EASE_MAX, Variant()); diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 5d1106bb41..c7d1d7ef82 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -227,17 +227,17 @@ void CodeEdit::_notification(int p_what) { end = font->get_string_size(line.substr(0, line.rfind(String::chr(0xFFFF))), font_size).x; } - Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent() + font_height * i + yofs); + Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent(font_size) + font_height * i + yofs); round_ofs = round_ofs.round(); draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HALIGN_LEFT, -1, font_size, font_color); if (end > 0) { // Draw an underline for the currently edited function parameter. - const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + line_spacing); + const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + yofs); draw_line(b, b + Vector2(end - begin, 0), font_color, 2); // Draw a translucent text highlight as well. const Rect2 highlight_rect = Rect2( - hint_ofs + sb->get_offset() + Vector2(begin, 0), + b - Vector2(0, font_height), Vector2(end - begin, font_height)); draw_rect(highlight_rect, font_color * Color(1, 1, 1, 0.2)); } diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 046715e17e..611035fff9 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -827,7 +827,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { real_t dist = center.distance_to(bev->get_position()); if (dist <= center.x) { - real_t rad = Math::atan2(bev->get_position().y - center.y, bev->get_position().x - center.x); + real_t rad = bev->get_position().angle_to_point(center); h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU; s = CLAMP(dist / center.x, 0, 1); } else { @@ -844,7 +844,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { real_t dist = center.distance_to(bev->get_position()); if (dist >= center.x * 0.84 && dist <= center.x) { - real_t rad = Math::atan2(bev->get_position().y - center.y, bev->get_position().x - center.x); + real_t rad = bev->get_position().angle_to_point(center); h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU; spinning = true; } else { @@ -889,12 +889,12 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { Vector2 center = c->get_size() / 2.0; if (picker_type == SHAPE_VHS_CIRCLE) { real_t dist = center.distance_to(mev->get_position()); - real_t rad = Math::atan2(mev->get_position().y - center.y, mev->get_position().x - center.x); + real_t rad = mev->get_position().angle_to_point(center); h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU; s = CLAMP(dist / center.x, 0, 1); } else { if (spinning) { - real_t rad = Math::atan2(mev->get_position().y - center.y, mev->get_position().x - center.x); + real_t rad = mev->get_position().angle_to_point(center); h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU; } else { real_t corner_x = (c == wheel_uv) ? center.x - Math_SQRT12 * c->get_size().width * 0.42 : 0; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index cbdf2a498a..ecf735d7f5 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -31,6 +31,9 @@ #include "graph_node.h" #include "core/string/translation.h" +#ifdef TOOLS_ENABLED +#include "graph_edit.h" +#endif struct _MinSizeCache { int min_size; @@ -458,6 +461,27 @@ void GraphNode::_shape() { title_buf->add_string(title, font, font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale()); } +#ifdef TOOLS_ENABLED +void GraphNode::_edit_set_position(const Point2 &p_position) { + GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent()); + if (graph) { + Point2 offset = (p_position + graph->get_scroll_ofs()) * graph->get_zoom(); + set_position_offset(offset); + } + set_position(p_position); +} + +void GraphNode::_validate_property(PropertyInfo &property) const { + Control::_validate_property(property); + GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent()); + if (graph) { + if (property.name == "rect_position") { + property.usage |= PROPERTY_USAGE_READ_ONLY; + } + } +} +#endif + void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) { ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set slot with p_idx (%d) lesser than zero.", p_idx)); diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index c7c7006bfc..2238cfdb56 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -98,6 +98,11 @@ private: Overlay overlay = OVERLAY_DISABLED; +#ifdef TOOLS_ENABLED + void _edit_set_position(const Point2 &p_position) override; + void _validate_property(PropertyInfo &property) const override; +#endif + protected: virtual void gui_input(const Ref<InputEvent> &p_ev) override; void _notification(int p_what); diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 3ca2d1c1e9..deb5c364cb 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -241,6 +241,7 @@ void Tabs::_shape(int p_tab) { tabs.write[p_tab].xl_text = atr(tabs[p_tab].text); tabs.write[p_tab].text_buf->clear(); + tabs.write[p_tab].text_buf->set_width(-1); if (tabs[p_tab].text_direction == Control::TEXT_DIRECTION_INHERITED) { tabs.write[p_tab].text_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); } else { @@ -529,7 +530,6 @@ bool Tabs::get_offset_buttons_visible() const { void Tabs::set_tab_title(int p_tab, const String &p_title) { ERR_FAIL_INDEX(p_tab, tabs.size()); tabs.write[p_tab].text = p_title; - tabs.write[p_tab].xl_text = atr(p_title); _shape(p_tab); update(); minimum_size_changed(); diff --git a/scene/resources/skeleton_modification_2d_twoboneik.cpp b/scene/resources/skeleton_modification_2d_twoboneik.cpp index 88d80a501f..4f752896a9 100644 --- a/scene/resources/skeleton_modification_2d_twoboneik.cpp +++ b/scene/resources/skeleton_modification_2d_twoboneik.cpp @@ -144,7 +144,7 @@ void SkeletonModification2DTwoBoneIK::_execute(float p_delta) { // With modifications by TwistedTwigleg Vector2 target_difference = target->get_global_position() - joint_one_bone->get_global_position(); float joint_one_to_target = target_difference.length(); - float angle_atan = Math::atan2(target_difference.y, target_difference.x); + float angle_atan = target_difference.angle(); float bone_one_length = joint_one_bone->get_length() * MIN(joint_one_bone->get_global_scale().x, joint_one_bone->get_global_scale().y); float bone_two_length = joint_two_bone->get_length() * MIN(joint_two_bone->get_global_scale().x, joint_two_bone->get_global_scale().y); diff --git a/servers/physics_2d/body_direct_state_2d_sw.cpp b/servers/physics_2d/body_direct_state_2d_sw.cpp index 58250c3077..1e924a831e 100644 --- a/servers/physics_2d/body_direct_state_2d_sw.cpp +++ b/servers/physics_2d/body_direct_state_2d_sw.cpp @@ -59,6 +59,7 @@ real_t PhysicsDirectBodyState2DSW::get_inverse_inertia() const { } void PhysicsDirectBodyState2DSW::set_linear_velocity(const Vector2 &p_velocity) { + body->set_active(true); body->set_linear_velocity(p_velocity); } @@ -67,6 +68,7 @@ Vector2 PhysicsDirectBodyState2DSW::get_linear_velocity() const { } void PhysicsDirectBodyState2DSW::set_angular_velocity(real_t p_velocity) { + body->set_active(true); body->set_angular_velocity(p_velocity); } @@ -87,26 +89,32 @@ Vector2 PhysicsDirectBodyState2DSW::get_velocity_at_local_position(const Vector2 } void PhysicsDirectBodyState2DSW::add_central_force(const Vector2 &p_force) { + body->set_active(true); body->add_central_force(p_force); } void PhysicsDirectBodyState2DSW::add_force(const Vector2 &p_force, const Vector2 &p_position) { + body->set_active(true); body->add_force(p_force, p_position); } void PhysicsDirectBodyState2DSW::add_torque(real_t p_torque) { + body->set_active(true); body->add_torque(p_torque); } void PhysicsDirectBodyState2DSW::apply_central_impulse(const Vector2 &p_impulse) { + body->set_active(true); body->apply_central_impulse(p_impulse); } void PhysicsDirectBodyState2DSW::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) { + body->set_active(true); body->apply_impulse(p_impulse, p_position); } void PhysicsDirectBodyState2DSW::apply_torque_impulse(real_t p_torque) { + body->set_active(true); body->apply_torque_impulse(p_torque); } diff --git a/servers/physics_3d/body_direct_state_3d_sw.cpp b/servers/physics_3d/body_direct_state_3d_sw.cpp index d197dd288d..e74baefc3a 100644 --- a/servers/physics_3d/body_direct_state_3d_sw.cpp +++ b/servers/physics_3d/body_direct_state_3d_sw.cpp @@ -66,6 +66,7 @@ Basis PhysicsDirectBodyState3DSW::get_inverse_inertia_tensor() const { } void PhysicsDirectBodyState3DSW::set_linear_velocity(const Vector3 &p_velocity) { + body->set_active(true); body->set_linear_velocity(p_velocity); } @@ -74,6 +75,7 @@ Vector3 PhysicsDirectBodyState3DSW::get_linear_velocity() const { } void PhysicsDirectBodyState3DSW::set_angular_velocity(const Vector3 &p_velocity) { + body->set_active(true); body->set_angular_velocity(p_velocity); } @@ -94,26 +96,32 @@ Vector3 PhysicsDirectBodyState3DSW::get_velocity_at_local_position(const Vector3 } void PhysicsDirectBodyState3DSW::add_central_force(const Vector3 &p_force) { + body->set_active(true); body->add_central_force(p_force); } void PhysicsDirectBodyState3DSW::add_force(const Vector3 &p_force, const Vector3 &p_position) { + body->set_active(true); body->add_force(p_force, p_position); } void PhysicsDirectBodyState3DSW::add_torque(const Vector3 &p_torque) { + body->set_active(true); body->add_torque(p_torque); } void PhysicsDirectBodyState3DSW::apply_central_impulse(const Vector3 &p_impulse) { + body->set_active(true); body->apply_central_impulse(p_impulse); } void PhysicsDirectBodyState3DSW::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) { + body->set_active(true); body->apply_impulse(p_impulse, p_position); } void PhysicsDirectBodyState3DSW::apply_torque_impulse(const Vector3 &p_impulse) { + body->set_active(true); body->apply_torque_impulse(p_impulse); } diff --git a/thirdparty/README.md b/thirdparty/README.md index 990bd30320..2d24beec15 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -422,10 +422,6 @@ Collection of single-file libraries used in Godot components. * Upstream: https://research.activision.com/publications/archives/fast-filtering-of-reflection-probes File coeffs_const_8.txt (retrieved April 2020) * License: MIT -- `easing_equations.cpp` - * Upstream: http://robertpenner.com/easing/ via https://github.com/jesusgollonet/ofpennereasing (modified to fit Godot types) - * Version: git (af72c147c3a74e7e872aa28c7e2abfcced04fdce, 2008) + Godot types and style changes - * License: BSD-3-Clause - `fastlz.{c,h}` * Upstream: https://github.com/ariya/FastLZ * Version: 0.5.0 (4f20f54d46f5a6dd4fae4def134933369b7602d2, 2020) diff --git a/thirdparty/misc/easing_equations.cpp b/thirdparty/misc/easing_equations.cpp deleted file mode 100644 index ce32c1a362..0000000000 --- a/thirdparty/misc/easing_equations.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Adapted from Penner Easing equations' C++ port. - * Source: https://github.com/jesusgollonet/ofpennereasing - * License: BSD-3-clause - */ - -#include "scene/animation/tween.h" - -const real_t pi = 3.1415926535898; - -/////////////////////////////////////////////////////////////////////////// -// linear -/////////////////////////////////////////////////////////////////////////// -namespace linear { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return c * t / d + b; -} -}; // namespace linear -/////////////////////////////////////////////////////////////////////////// -// sine -/////////////////////////////////////////////////////////////////////////// -namespace sine { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return -c * cos(t / d * (pi / 2)) + c + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * sin(t / d * (pi / 2)) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - return -c / 2 * (cos(pi * t / d) - 1) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace sine -/////////////////////////////////////////////////////////////////////////// -// quint -/////////////////////////////////////////////////////////////////////////// -namespace quint { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * pow(t / d, 5) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * (pow(t / d - 1, 5) + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t = t / d * 2; - if (t < 1) return c / 2 * pow(t, 5) + b; - return c / 2 * (pow(t - 2, 5) + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace quint -/////////////////////////////////////////////////////////////////////////// -// quart -/////////////////////////////////////////////////////////////////////////// -namespace quart { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * pow(t / d, 4) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - return -c * (pow(t / d - 1, 4) - 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t = t / d * 2; - if (t < 1) return c / 2 * pow(t, 4) + b; - return -c / 2 * (pow(t - 2, 4) - 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace quart -/////////////////////////////////////////////////////////////////////////// -// quad -/////////////////////////////////////////////////////////////////////////// -namespace quad { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c * pow(t / d, 2) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - t = t / d; - return -c * t * (t - 2) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t = t / d * 2; - if (t < 1) return c / 2 * pow(t, 2) + b; - return -c / 2 * ((t - 1) * (t - 3) - 1) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace quad -/////////////////////////////////////////////////////////////////////////// -// expo -/////////////////////////////////////////////////////////////////////////// -namespace expo { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - if (t == d) return b + c; - return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if (t == d) return b + c; - t = t / d * 2; - if (t < 1) return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005; - return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace expo -/////////////////////////////////////////////////////////////////////////// -// elastic -/////////////////////////////////////////////////////////////////////////// -namespace elastic { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if ((t /= d) == 1) return b + c; - float p = d * 0.3f; - float a = c; - float s = p / 4; - float postFix = a * pow(2, 10 * (t -= 1)); // this is a fix, again, with post-increment operators - return -(postFix * sin((t * d - s) * (2 * pi) / p)) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if ((t /= d) == 1) return b + c; - float p = d * 0.3f; - float a = c; - float s = p / 4; - return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b); -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - if (t == 0) return b; - if ((t /= d / 2) == 2) return b + c; - float p = d * (0.3f * 1.5f); - float a = c; - float s = p / 4; - - if (t < 1) { - float postFix = a * pow(2, 10 * (t -= 1)); // postIncrement is evil - return -0.5f * (postFix * sin((t * d - s) * (2 * pi) / p)) + b; - } - float postFix = a * pow(2, -10 * (t -= 1)); // postIncrement is evil - return postFix * sin((t * d - s) * (2 * pi) / p) * 0.5f + c + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace elastic -/////////////////////////////////////////////////////////////////////////// -// cubic -/////////////////////////////////////////////////////////////////////////// -namespace cubic { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - t /= d; - return c * t * t * t + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - t = t / d - 1; - return c * (t * t * t + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t /= d / 2; - if (t < 1) return c / 2 * t * t * t + b; - t -= 2; - return c / 2 * (t * t * t + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace cubic -/////////////////////////////////////////////////////////////////////////// -// circ -/////////////////////////////////////////////////////////////////////////// -namespace circ { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - t /= d; - return -c * (sqrt(1 - t * t) - 1) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - t = t / d - 1; - return c * sqrt(1 - t * t) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - t /= d / 2; - if (t < 1) { - return -c / 2 * (sqrt(1 - t * t) - 1) + b; - } - t -= 2; - return c / 2 * (sqrt(1 - t * t) + 1) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace circ -/////////////////////////////////////////////////////////////////////////// -// bounce -/////////////////////////////////////////////////////////////////////////// -namespace bounce { -static real_t out(real_t t, real_t b, real_t c, real_t d); - -static real_t in(real_t t, real_t b, real_t c, real_t d) { - return c - out(d - t, 0, c, d) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - if ((t /= d) < (1 / 2.75f)) { - return c * (7.5625f * t * t) + b; - } else if (t < (2 / 2.75f)) { - float postFix = t -= (1.5f / 2.75f); - return c * (7.5625f * (postFix)*t + .75f) + b; - } else if (t < (2.5 / 2.75)) { - float postFix = t -= (2.25f / 2.75f); - return c * (7.5625f * (postFix)*t + .9375f) + b; - } else { - float postFix = t -= (2.625f / 2.75f); - return c * (7.5625f * (postFix)*t + .984375f) + b; - } -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? in(t * 2, b, c / 2, d) : out((t * 2) - d, b + c / 2, c / 2, d); -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace bounce -/////////////////////////////////////////////////////////////////////////// -// back -/////////////////////////////////////////////////////////////////////////// -namespace back { -static real_t in(real_t t, real_t b, real_t c, real_t d) { - float s = 1.70158f; - float postFix = t /= d; - return c * (postFix)*t * ((s + 1) * t - s) + b; -} - -static real_t out(real_t t, real_t b, real_t c, real_t d) { - float s = 1.70158f; - t = t / d - 1; - return c * (t * t * ((s + 1) * t + s) + 1) + b; -} - -static real_t in_out(real_t t, real_t b, real_t c, real_t d) { - float s = 1.70158f * 1.525f; - t /= d / 2; - if (t < 1) return c / 2 * (t * t * ((s + 1) * t - s)) + b; - t -= 2; - return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b; -} - -static real_t out_in(real_t t, real_t b, real_t c, real_t d) { - return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); -} -}; // namespace back - -Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = { - { &linear::in, &linear::out, &linear::in_out, &linear::out_in }, - { &sine::in, &sine::out, &sine::in_out, &sine::out_in }, - { &quint::in, &quint::out, &quint::in_out, &quint::out_in }, - { &quart::in, &quart::out, &quart::in_out, &quart::out_in }, - { &quad::in, &quad::out, &quad::in_out, &quad::out_in }, - { &expo::in, &expo::out, &expo::in_out, &expo::out_in }, - { &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in }, - { &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in }, - { &circ::in, &circ::out, &circ::in_out, &circ::out_in }, - { &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in }, - { &back::in, &back::out, &back::in_out, &back::out_in }, -}; - -real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) { - - interpolater cb = interpolaters[p_trans_type][p_ease_type]; - ERR_FAIL_COND_V(cb == NULL, b); - return cb(t, b, c, d); -} |