Commit graph

194 commits

Author SHA1 Message Date
ARez
23827d4303 Add Unit test for InputEventMouse 2023-01-29 14:09:53 +01:00
Aaron Franke
5f3d3722b2
Add support for interpolating skewed transforms 2023-01-28 18:28:42 -06:00
Adam Scott
37248d7c87 Add @GlobalScope is_same(a, b) and Variant::identity_compare() 2023-01-25 10:46:21 -05:00
Jan Haller
83026126d4 Add tests to ensure bound methods and signals are valid identifiers 2023-01-23 21:19:57 +01:00
bruvzg
daad4aed62
Cleanup and unify keyboard input.
- Unify keycode values (secondary label printed on a key), remove unused hardcoded Latin-1 codes.
- Unify IME behaviour, add inline composition string display on Windows and X11.
- Add key_label (localized label printed on a key) value to the key events, and allow mapping actions to the unshifted Unicode events.
- Add support for physical keyboard (Bluetooth or Sidecar) handling on iOS.
- Add support for media key handling on macOS.

Co-authored-by: Raul Santos <raulsntos@gmail.com>
2023-01-23 15:08:12 +02:00
Rémi Verschelde
5b1df48c6c
Convert en_GB spelling to en_US with codespell 2023-01-23 11:02:20 +01:00
bruvzg
db7d8c2d87
[GDExtension] Expose some low level functions and String operators. 2023-01-19 12:50:49 +02:00
Raul Santos
7560340ef6
Rename center method to get_center in Plane. 2023-01-15 17:18:50 +01:00
Rémi Verschelde
d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Rémi Verschelde
565ae3b767
Merge pull request #67694 from aaronfranke/its-time
Remove duplicate Month and Weekday enums
2023-01-03 23:21:19 +01:00
Marius Hanl
b9be3ce75e Add tests for signals
- Adding signals
- Emitting signals
2022-12-29 16:07:45 +01:00
Aaron Franke
8d7d1b0bb2
Remove duplicate Month and Weekday enums
Well, they were duplicately-exposed, but triplicately-defined.
2022-12-26 15:16:25 -06:00
Marius Hanl
5aa243f9da Added the possibility to define a default value in ProjectSettings.get_setting(), which is used when no setting is set.
Also added tests for the project settings.

Co-authored-by: Yuri Sizov <11782833+YuriSizov@users.noreply.github.com>
2022-12-21 19:49:57 +01:00
Rémi Verschelde
907298d673
Merge pull request #68747 from rune-scape/rune-stringname-unification
GDScript: Unify StringName and String
2022-12-09 18:06:48 +01:00
rune-scape
e79be6ce07 Unify String and StringName 2022-12-05 21:46:47 -05:00
Gilles Roudière
fa4143cdeb Allow specifying a prefix to automatically detect library files for gdextension exports 2022-12-01 18:20:40 +01:00
Rémi Verschelde
4a8b725bc9
Merge pull request #68386 from MewPurPur/snappedi-snappedf
Implement snappedi, snappedf, and Vector[2/3/4]i.snapped
2022-11-24 18:54:49 +01:00
Bastiaan Olij
a479f5af22 Improve logic for detecting and tracking extensions 2022-11-24 21:48:16 +11:00
Micky
e791f4fce2 Double precision of String.split_floats 2022-11-20 12:29:50 +01:00
VolTer
e26f0906f2 Implement snappedi, snappedf, and Vector[2/3/4]i.snapped 2022-11-19 06:18:55 +01:00
Hendrik Brucker
1f36dbdf23 Generic math function tests: Test float and double variants 2022-11-09 01:51:55 +01:00
Rémi Verschelde
44a0b86f93
Merge pull request #68275 from Geometror/doctest-approx
[Tests] Replace Math::is_equal_approx with == and doctest::Approx
2022-11-06 15:58:00 +01:00
Hendrik Brucker
f906ff8f89 [Tests] Replace Math::is_equal_approx with == and doctest::Approx 2022-11-05 02:28:00 +01:00
kobewi
8a47a12207 Add support for empty delimiter in String.split 2022-11-04 15:09:12 +01:00
Hendrik Brucker
e62955b45b Add a test suite for Math:: namespace functions
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2022-11-04 03:08:08 +01:00
Aaron Franke
9e952c8386
Allow getting Quaternion rotation in different Euler orders 2022-11-02 19:20:10 -05:00
Rémi Verschelde
08d56ac2f1
Merge pull request #66747 from aaronfranke/move-euler-order
Move EulerOrder enum to math_defs.h and global scope
2022-11-02 22:37:12 +01:00
Rémi Verschelde
9ec7aadc06
Merge pull request #66017 from Mickeon/rename-image-copy-rect
Rename Image's `get_rect` to `get_region`
2022-11-02 22:36:57 +01:00
Aaron Franke
8556fdd4bc
Move EulerOrder enum to math_defs.h and global scope 2022-11-02 13:44:13 -05:00
Rémi Verschelde
f7c611ab71
Style: Misc docs and comment style and language fixes
- Removed empty paragraphs in XML.
- Consistently use bold style for "Example:", on a new line.
- Fix usage of `[code]` when hyperlinks could be used (`[member]`, `[constant]`).
- Fix invalid usage of backticks for inline code in BBCode.
- Fix some American/British English spelling inconsistencies.
- Other minor fixes spotted along the way, including typo fixes with codespell.
- Don't specify `@GlobalScope` for `enum` and `constant`.
2022-11-02 19:01:18 +01:00
Micky
ebf86c96e9 Rename Image's get_rect to get_region
Also renames its parameter to from "rect" to "region".
2022-11-01 23:35:48 +01:00
Aaron Franke
83634119d4
Replace Quaternion Euler constructor with from_euler method 2022-11-01 09:28:12 -05:00
Rémi Verschelde
f0dcefe5f8
Merge pull request #66380 from aaronfranke/basis-euler-test
Simplify Euler order test code in test_basis.h
2022-10-31 10:55:37 +01:00
DeeJayLSP
dd64ceab47 Change all WEBP strings and comments to WebP 2022-10-28 15:17:49 -03:00
Aaron Franke
fae4ed5a98
Simplify Euler order test code in test_basis.h 2022-10-27 12:10:57 -05:00
Aaron Franke
7f9a8c99c9
Clean up Basis from Euler code 2022-10-21 17:54:49 -05:00
Aaron Franke
c60ac64e8f
Fix big negative numbers printing incorrect decimals in num_real 2022-10-15 17:57:54 -05:00
Gilles Roudière
bf1a40c168 Make String.simplify_path keep the protocol identifier for urls 2022-10-13 12:23:49 +02:00
Haoyu Qiu
5da515773d Add is_finite method for checking built-in types 2022-10-08 13:25:08 +08:00
Rémi Verschelde
54418ea659 Remove NO_THREADS fallback code, Godot 4 requires thread support
This also removes `OS::can_use_threads` from the public API since it's always
true.
2022-10-03 11:23:26 +02:00
Rémi Verschelde
d9a3888cea Merge pull request #66133 from aaronfranke/set-all
Delete `set_all`, `set_axis`, and `get_axis` methods from Vector2/3/3i/4/4i
2022-10-03 09:23:46 +02:00
Rémi Verschelde
cf6978f286 Merge pull request #64833 from MarcusElg/naninfprinting
Improve string formatting (%f and %v) for inf and nan
2022-10-03 09:23:12 +02:00
Rémi Verschelde
166df0896c Fix typos with codespell
Using codespell 2.3-dev from current git.

And fix typo in `methods.py` for `vsproj=yes` option (still won't work
though).
2022-09-30 14:23:36 +02:00
bruvzg
8f5d56e04a
[GDExtension] Use function names with underscore for TextServer extension, add macros to generate wrappers for module functions. 2022-09-28 10:04:11 +03:00
Micky
ef8fbae929
Add more tests for Vector* types 2022-09-25 22:58:58 -05:00
Aaron Franke
fd8bd27657
Remove set_axis and get_axis methods from Vector2/2i/3/3i/4/4i 2022-09-19 15:08:50 -05:00
fabriceci
9f1a57d48b Test, refactor and fix a bug in Basis.get_axis_angle 2022-09-14 12:05:22 +02:00
Haoyu Qiu
f5760ed65d Fix parsing of XML CDATA and add test cases 2022-09-09 09:42:24 +08:00
bruvzg
6f4d233062
Fix key mapping changes when moving from macOS to other platform
Removes separate `Command` key (use `Meta` instead).
Adds an event flag to automatically remap `Command` <-> `Control` (cannot be set alongside `Control` or `Meta`).
2022-09-07 18:45:35 +02:00
Aaron Franke
995b9f94e8
Replace Rect2(i) has_no_area with has_area 2022-09-04 23:03:36 -05:00
Aaron Franke
817ae95667
Replace AABB has_no_volume with has_volume
Also replace has_no_surface with has_surface
2022-09-04 23:03:36 -05:00
Rémi Verschelde
f02134a8c0
Merge pull request #55617 from madmiraal/fix-55384 2022-09-01 18:20:01 +02:00
Rémi Verschelde
41156a1e83
Merge pull request #63968 from KoBeWi/finding_stuff_in_a_dictionary 2022-09-01 17:38:39 +02:00
Marcel Admiraal
0046d320bb Fix Geometry3D::get_closest_points_between_segments() returns NaN
Also fix:
- Geometry3D::get_closest_distance_between_segments() returning
  incorrect values.
- Test for Geometry3D::get_closest_distance_between_segments() testing for
  an incorrect value.
2022-08-30 12:13:11 +01:00
Danil Alexeev
d4555ef5fb
Add String.to_{camel,pascal,snake}_case methods 2022-08-30 12:36:24 +03:00
Aaron Franke
10a56981dc
Rename String plus_file to path_join 2022-08-29 19:38:13 -05:00
Micky
59e11934d8 Rename str2var to str_to_var and similar
Affects the Math class, a good chunk of the audio code, and a lot of other miscellaneous classes, too.

- `var2str` -> `var_to_str`
- `str2var` -> `str_to_var`
- `bytes2var` -> `bytes_to_var`
- `bytes2var_with_objects` -> `bytes_to_var_with_objects`
- `var2bytes` -> `var_to_bytes`
- `var2bytes_with_objects` -> `var_to_bytes_with_objects`
- `linear2db` -> `linear_to_db`
- `db2linear` -> `db_to_linear`
- `deg2rad` -> `deg_to_rad`
- `rad2deg` -> `rad_to_deg`

- `dict2inst` -> `dict_to_inst`
- `inst2dict` -> `inst_to_dict`
2022-08-26 14:58:22 +02:00
Marcus Elg
b21460981d Improve string formatting for %f and %v for inf and nan 2022-08-25 07:41:21 +02:00
Marcus Elg
acd9736fc9 Formatting changes to string test comments 2022-08-24 16:23:53 +02:00
Marcus Elg
dbc165715b Add %v for formatting vectors 2022-08-23 17:26:06 +02:00
Yuri Sizov
980f5f32f4 Make property_*_revert methods multilevel and expose them for scripting 2022-08-18 00:03:53 +03:00
kobewi
cc424bcb18 Add Dictionary.find_key() 2022-08-16 13:48:59 +02:00
antonWetzel
40a1d6d100 vector4 distance_squared_to and update csharp 2022-08-09 01:59:17 +02:00
Yuri Sizov
1362bc22bd Add tests for empty/unnamed arguments to ClassDB, Variant, GDScript 2022-08-08 16:36:01 +03:00
Hendrik Brucker
36061c5dca Vector4/Vector4i: Add missing methods, tests and fix change of sign operator 2022-08-07 12:25:05 +02:00
Rémi Verschelde
62423b691e Tests: Silence some intentional errors
Also fix printing messages in ClassDB test.
2022-08-04 22:03:44 +02:00
codepatzer
d0cb0ff248 Add tests file for Quaternion unit tests, with initial UTs
- Test constructors and quaternion product.
- Add test case for Axis-Angle construction about Y-axis.
- Add test case for xform of i-, j-, & k-unit vectors.
- Add test case for construction from Basis.
- Add test case for xform of arbitrary vector.
- Add stress test case: many Quaternions xform many vectors.
- Make comments consistent with style guide.
2022-08-04 13:56:04 +02:00
Timon Bestebreur
997f18f686 Add Unit Tests for InputEventKey 2022-08-04 12:59:13 +02:00
Rémi Verschelde
255e0770c4
Merge pull request #54325 from skimmedsquare/test-add-rid 2022-08-04 12:51:53 +02:00
Timon Bestebreur
92b392e3db Add unit tests for Shortcut
Next to that, add entry for the test file in test_main.cpp.

These test cases test the basic functionality of the shortcut module.
2022-08-04 12:18:36 +02:00
Sean Kim
4706b975b6 Add unit tests for RID class. 2022-08-04 12:05:25 +02:00
Fabian Keller
f242f9c738 Fix consistency of translated/scaled/rotated in Transform2D and Transform3D 2022-08-02 23:38:14 +02:00
Rémi Verschelde
1418f97c70 File: Re-add support to skip CR (\r) in File::get_as_text
This was removed in #63481, and we confirmed that it's better like this,
but we add back the possibility to strip CR as an option, to optionally
restore the previous behavior.

For performance this is done directly in `String::parse_utf8`.

Also fixes Android `FileAccess::get_line()` as this one _should_ strip CR.

Supersedes #63717.
2022-08-01 00:40:35 +02:00
Rémi Verschelde
5c6744ae54
Merge pull request #42069 from Calinou/test-add-os
Add a test suite for OS
2022-07-30 09:45:00 +02:00
kobewi
c3606cb5f3 Swap arguments of ResourceSaver.save() 2022-07-29 19:53:09 +02:00
Hugo Locurcio
208435fb90
Add a test suite for OS 2022-07-29 01:55:43 +02:00
Fabio Alessandrelli
ca7d572908 [Net] Modularize multiplayer, expose MultiplayerAPI to extensions.
- RPC configurations are now dictionaries.
- Script.get_rpc_methods renamed to Script.get_rpc_config.
- Node.rpc[_id] and Callable.rpc now return an Error.
- Refactor MultiplayerAPI to allow extension.
- New MultiplayerAPI.rpc method with Array argument (for scripts).
- Move the default MultiplayerAPI implementation to a module.
2022-07-26 09:31:12 +02:00
Rémi Verschelde
90019676b0 Code quality: Fix header guards consistency
Adds `header_guards.sh` bash script, used in CI to validate future
changes. Can be run locally to fix invalid header guards.
2022-07-25 11:17:40 +02:00
reduz
67a260d63f Implement a Worker ThreadPool
This PR implements a worked thread pool. It uses a fixed amount of threads in a pool and allows scheduling tasks
that can be run on threads (and then waited for). It satisfies the following use cases:

* HTML5 thread count is fixed (and similar restrictions are known in consoles) so we need to reuse threads.
* Thread spawning is slow in general, so reusing threads is faster anyway.
* This implementation supports recursive waiting for tasks, making it less prone to deadlocks if threads from the pool also run tasks.

After this is approved and merged, subsequent PRs will be needed to replace the ThreadWorkPool usage by this class.
2022-07-22 11:46:48 +02:00
FireForge
84431bd782 Use integer types in Image and ImageTexture methods
- Image.blit_rect()
- Image.blit_rect_mask()
- Image.blend_rect()
- Image.blend_rect_mask()
- Image.fill_rect()
- Image.get_used_rect()
- Image.get_rect()
- ImageTexture.set_size_override()
2022-07-18 19:43:32 -05:00
bruvzg
0c5431644d
Allows parsing of invalid UTF-16 surrogates (can be encountered in Windows filenames) and some non-standard UTF-8 variants, makes Unicode parse errors more verbose. 2022-07-07 11:07:18 +03:00
reduz
5ac42cf576 Implement a BitField hint
Allows to specify the binder that an enum must be treated as a bitfield.
2022-07-05 22:13:37 +02:00
cabinboy1031
7730001390 Implemented tests for Plane getters and setters.
Added tests for intersection and plane-point methods.
2022-07-05 12:55:05 +02:00
bruvzg
860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +03:00
Yuri Rubinsky
7da2a21425 Make AStar to use 64-bit logic 2022-06-16 16:43:41 +03:00
reduz
45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
Haoyu Qiu
3094e739f5 Create onready variables when dropping nodes and holding Ctrl 2022-05-17 11:51:22 +08:00
reduz
746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
reduz
8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Rémi Verschelde
afc49732ba
Merge pull request #59643 from kneejuicer/geometry2D-tests
Add extra unit tests for Geometry2D
2022-05-10 14:45:36 +02:00
Nicholas Huelin
8409d92282 Fix inconsistent naming in Time 2022-05-05 16:00:37 +02:00
Aaron Franke
fa7a7795f0
Rename Basis get_axis to get_column, remove redundant methods 2022-05-03 09:37:47 -05:00
Haoyu Qiu
ad1a8777bd Fix left aligned integer sign in string formatting 2022-05-01 12:42:48 +08:00
Rémi Verschelde
46ef52162e Color: Rename to_srgb/to_linear to include base color space
This helps reduce confusion around sRGB <> Linear conversions by making
both input and output color spaces explicit.
2022-04-13 11:45:52 +02:00
bruvzg
9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
Rémi Verschelde
c99a1af0fb Remove unused legacy tests
They haven't been updated for years and still use the old MainLoop
basic framework instead of the new doctest one.

They're of dubious quality and best redone from scratch using the
new framework.
2022-04-07 00:38:44 +02:00
Rémi Verschelde
f8ab79e68a Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
2022-04-04 19:49:50 +02:00
kneejuicer
113579cec8 Add extra unit tests for Geometry2D 2022-03-29 00:58:55 +02:00
Hugo Locurcio
1c343cd54d Expose Color's to_linear() and to_srgb() to scripting 2022-03-28 12:17:55 +02:00
reduz
09b951b99b Refactor Object metadata
* API kept the same (Although functions could be renamed to set_metadata/get_metadata in a later PR), so not much should change.
* Metadata now exposed as individual properties.
* Properties are editable in inspector (unless metadata name begins with _) under the metadata/ namespace.
* Added the ability to Add/Remove metadata properties to the inspector.

This is a functionality that was requested very often, that makes metadata work a bit more similar to custom properties in Blender.
2022-03-24 14:21:52 +01:00