Commit Graph

86 Commits (master)

Author SHA1 Message Date
Mikael Hermansson 494471dda2 Fix `printraw` causing infinite recursion in `Logger._log_message` 2025-07-31 20:24:47 +07:00
Lukas Tenbrink 963c20565b Remove `OAHashMap`, in favour of `AHashMap`.
The two types had (mostly) the same decisions, but `AHashMap` is a faster implementation, and is more consistent with `HashMap`.
2025-05-31 15:50:10 +07:00
Thaddeus Crews d237e31a89
Style: Remove redundant `DEBUG_METHODS_ENABLED`
• Replaced with functionally identical and far more ubiquitous `DEBUG_ENABLED`
2025-05-15 13:09:41 +07:00
Joel Croteau 981f1e9298 Rename `VariantUtilityFunctions::join()` to `join_string()` 2025-05-12 17:51:09 +07:00
Joel Croteau 8be7ad32e7 Consolidate and simplify string joining code in `VariantUtilityFunctions`
`variant_utility.cpp` has 8 different copies of the exact same loop to join
vararg strings together. This is bad coding process and makes the codebase
needlessly cluttered. Also, the loop itself has an i == 0 check that is
unnecessary since String is auto-initialized to be empty and String::operator+=
already checks if it is empty before appending. This is a non-functional change
that only reorganizes the code to be a bit more readable.
2025-05-12 17:47:14 +07:00
Thaddeus Crews 3947cbe3b2
Merge pull request #104386 from Repiteo/core/cpp-math
Core: Replace C math headers with C++ equivalents
2025-04-27 19:21:22 +07:00
reduz d1dcb40d56 Ability to print and log script backtraces
Co-authored-by: Mikael Hermansson <mikael@hermansson.io>
2025-04-24 18:54:41 +07:00
Thaddeus Crews ad40939b6f
Core: Replace C math headers with C++ equivalents
- Minor restructuring to ensure `math_funcs.h` is the central point for math functions
2025-04-16 15:49:02 +07:00
kobewi 10f6c01b9c Remove ABS in favor of Math::abs 2025-03-19 13:52:40 +07:00
A Thousand Ships 5113022dfe
Clean up some uses of `String::substr`
Cases where the end position is either equvalent to the default or past
the end of the string.
2025-03-07 14:50:38 +07:00
lawnjelly 5c6d7bfb98 Change `VariantUtility` to prevent undef `print_verbose`
Changes the `VariantUtility` function from `print_verbose` to `_print_verbose`, eliminating the need for undefining the `print_verbose` macro, which caused compilation problems.
2025-01-30 10:29:11 +07:00
Thaddeus Crews e06d83860d
Style: Enforce `AllowShortFunctionsOnASingleLine` 2025-01-02 10:09:41 +07:00
A Thousand Ships 38f9769bc6
[Core] Improve error messages with `vformat` 2024-10-30 15:55:51 +07:00
aXu-AP 7218dd6a3a Add support for Transform2D/3D in lerp()
Implements godotengine/godot-proposals#10579
2024-09-03 16:59:15 +07:00
kobewi 413c11357d Use Core/Scene stringnames consistently 2024-05-13 23:41:07 +07:00
K. S. Ernest (iFire) Lee f9b488508c
Add PackedVector4Array Variant type
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2024-05-03 00:58:27 +07:00
Thaddeus Crews 9903e6779b
Enforce template syntax `typename` over `class` 2024-03-07 22:39:09 +07:00
Muller-Castro a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 +07:00
Danil Alexeev 0c2202c56e
GDScript: Fix incorrect error message for utility functions 2023-10-16 14:09:57 +07:00
Jakub Janšta 74c937079c Add type_string() utility 2023-10-02 17:41:20 +07:00
Rémi Verschelde e95b7e84a4
Merge pull request #80844 from dalexeev/fix-callable-expected-argc
Fix expected argument count for `Callable` call errors
2023-10-02 13:15:53 +07:00
etti 3a39de4e2f Add rotate_toward and angle_difference to GDScript and C# 2023-10-01 22:19:42 +07:00
Danil Alexeev aff767ef07
Fix expected argument count for `Callable` call errors 2023-09-29 20:00:10 +07:00
A Thousand Ships 893f889d74 [Core] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-09-11 19:45:49 +07:00
Aaron Franke 6f7eccc758
Add a type conversion method to Variant Utility and expose to scripting 2023-09-08 10:12:48 +07:00
Jcrespo 528a76486c Add inverse hyperbolic functions `asinh()`, `acosh()` & `atanh()`
GDScript has the following built-in trigonometry functions:

- `sin()`
- `cos()`
- `tan()`
- `asin()`
- `acos()`
- `atan()`
- `atan()`
- `sinh()`
- `cosh()`
- `tanh()`

However, it lacks the hyperbolic arc (also known as inverse
hyperbolic) functions:

- `asinh()`
- `acosh()`
- `atanh()`

Implement them by just exposing the C++ Math library, but clamping
its values to the closest real defined value.
For the cosine, clamp input values lower than 1 to 1.
In the case of the tangent, where the limit value is infinite,
clamp it to -inf or +inf.

References #78377
Fixes godotengine/godot-proposals#7110
2023-09-01 01:27:56 +07:00
Aaron Franke 7e9b5e59d4
Make a header for VariantUtilityFunctions 2023-06-12 11:29:42 +07:00
Juan Linietsky 273a6eeb66 Redo how the remote filesystem works
Instead of reading files over the network, the new version uses a local file cache and only updates files when it changes.

The original remote filesystem was created 14 years ago, when ethernet was faster than hard drives or even flash. Also, mobile devices have a very small amount of storage.
Nowadays, this is no longer the case so the approach is changed to using a persistent cache in the target device.

Co-authored-by: m4gr3d
2023-05-08 11:57:54 +07:00
Paweł 899da22002 Fix lerp error message 2023-04-21 10:01:59 +07:00
Ninni Pipping c8c43997c7 Fix type check for max/min 2023-03-11 15:08:34 +07:00
George Marques ed81b165eb
Make max() and min() global functions only accept numbers
The behavior for those are not well defined for non-numeric arguments.
To avoid confusion the other types are forbidden.
2023-02-24 14:06:11 +07:00
Adam Scott 37248d7c87 Add `@GlobalScope` `is_same(a, b)` and `Variant::identity_compare()` 2023-01-25 10:46:21 +07: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 +07: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 +07:00
Yaohua Xiong f9fa182abc Refactor Curve3D::_bake() method
The main change is to caculate tangent directly from bezier curve, without going
through discretized polyline, avoiding pitfalls of discretization.

Other changes are:
1. Add an bezier_derivative() method for Vector3, Vector2, and Math;
2. Add an tesselate_even_length() method to Curve3D, which tesselate bezier curve to even length segments adaptively;
3. Cache the tangent vectors in baked_tangent_vector_cache;
2022-11-24 10:52:06 +07:00
Xpertice 3e36cc7c73 Add case for Variant::INT in lerp variant switch 2022-11-22 22:37:22 +07:00
VolTer e26f0906f2 Implement snappedi, snappedf, and Vector[2/3/4]i.snapped 2022-11-19 06:18:55 +07:00
Haoyu Qiu 5da515773d Add `is_finite` method for checking built-in types 2022-10-08 13:25:08 +07:00
kobewi 52b20ce909 Use 64bit integers in utility methods 2022-09-28 02:26:37 +07:00
kobewi 7499f41264 Fix wrong floori() behavior 2022-09-27 19:09:34 +07:00
Micky b6daad8d4b Rename `range_lerp` to `remap` 2022-09-06 07:19:20 +07:00
Silc Renew 931fb4dc11 Add linear/cubic angle interpolation to Animation interpolation type 2022-08-27 07:58:22 +07: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 +07:00
Silc Renew dded7c72c1 Make `cubic_interpolate()` consider key time in animation 2022-08-19 14:48:37 +07:00
Rémi Verschelde e6e13c8251
Merge pull request #63361 from KoBeWi/floorf_lol 2022-08-06 22:25:27 +07:00
kobewi ae3d83b17b Restore old lerp() behavior and add lerpf() 2022-08-06 21:15:37 +07:00
kobewi fdf7441015 Split ceil(), floor() and round() method 2022-07-27 16:58:56 +07:00
reduz 455c06ecd4 Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.

* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.

These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.

**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-23 14:00:01 +07:00
Voylin c6291bcd8a Adding print_rich for printing with BBCode 2022-06-29 00:41:29 +07:00
Rémi Verschelde 8fd0b4d1f8
Merge pull request #62449 from Chaosus/wrap_func
Add generalized version of `wrap` function
2022-06-27 23:28:37 +07:00