Commit Graph

6443 Commits

Author SHA1 Message Date
Jan Haller
c770937db5 More precise documentation for GDExtension String constructors (bytes vs. character count) 2023-09-24 20:57:58 +02:00
Jan Haller
43be9fa0c8 Fix platform-dependent hashing for char* and wchar_t*
Since char/wchar_t can be either signed or unsigned, its conversion to uint32_t leads to different values depending on platform.
In particular, the same string represented as char* (Latin-1; StringName direct construction) or uint32_t (UTF-8; constructed
via String) previously resulted in different hashes.
2023-09-24 20:57:57 +02:00
Jan Haller
ed3015e979 GDExtension: construct StringName directly from char*
So far, an indirection via String was necessary, causing at least 2 allocations and copies (String; String inside StringName).
Since StringNames often refer to string literals, this allows them to be directly constructed from C strings.

There are two formats: Latin-1 and UTF-8.

The Latin-1 constructor also provides the `p_is_static` flag: when the source has static storage duration, no copy/allocation will be needed.
However, the extension developer needs to uphold this lifetime guarantee.
2023-09-24 18:18:05 +02:00
Rémi Verschelde
59139df16e
Merge pull request #81986 from spazzylemons/master
Remove unnecessary line from Projection::get_z_far
2023-09-20 18:55:32 +02:00
Rémi Verschelde
6df12fe187
Merge pull request #80671 from fuzzybinary/gdextension-virtuals
Add functions for non-ptr style virtual calls in GDExtension
2023-09-20 18:55:05 +02:00
Matthew
9f21dfbafd
Remove unnecessary line from Projection::get_z_far
Removes a line from Projection::get_z_far that flips the normal of a plane.
While this may be required for similar code elsewhere in the file, this is
unnecessary here, as only the length of the normal is used and not the
direction. Flipping the normal does not change its magnitude and therefore is
unnecessary in this case.
2023-09-20 10:48:37 -04:00
Rémi Verschelde
54748f23dd
Merge pull request #74142 from bitsawer/mipmap_api
Expose and document `Image.get_mipmap_count()`
2023-09-20 15:18:15 +02:00
Rémi Verschelde
c36f6f87e6
Merge pull request #81917 from AThousandShips/alloc_fix
Fix allocation size overflow check in `CowData`
2023-09-20 13:09:55 +02:00
Jeff Ward
60851af4da Add functions for non-ptr style virtual calls in GDExtension
This adds two functions to `GDExtensionClassCreationInfo` that allow for developers to supply a generic virtual call function along with user data to be sent to that call.

If `get_virutal_call_data_func` is not null, extensions call this function to get user data to pass to a supplied `call_virtual_with_data_func`. Both must be provided is one is provided.

If `get_virtual_call_data_func` is null, Godot falls back to the old `get_virtual_func` logic.

Fixes #63275

Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-09-19 22:33:32 -04:00
Danil Alexeev
1621110e2d
Core: Some code style improvements to AStarGrid2D 2023-09-19 17:20:38 +03:00
A Thousand Ships
c48b189e14 Fix allocation size overflow check in CowData 2023-09-19 16:12:02 +02:00
bitsawer
16c3a19d91 Expose and document Image.get_mipmap_count() 2023-09-19 14:34:59 +03:00
Rémi Verschelde
8dfc3f1864
Merge pull request #79005 from maiself/gde-custom-callable
Allow CallableCustom objects to be created from GDExtensions (extended)
2023-09-19 09:02:49 +02:00
Rémi Verschelde
7bb80b1525
Merge pull request #81741 from KoBeWi/vectoring_to_the_MAXXX
Add `Vector2/3/4i.MAX` and `MIN`
2023-09-17 14:47:52 +02:00
Rémi Verschelde
61df1deb61
Merge pull request #80075 from Bromeon/gdextension/optimize-ptrcalls
GDExtension: `PtrToArg::convert()` uses const-reference where possible
2023-09-17 14:46:13 +02:00
kobewi
adc930baee Add Vector2/3/4i.MAX and MIN 2023-09-16 21:52:13 +02:00
kobewi
cd0aaab48c Cleanup some GLOBAL_DEFs 2023-09-15 21:32:23 +02:00
David Snopek
6554ccf86d GDExtension: Delete left-over DLL copy before making a new copy 2023-09-12 09:57:40 -05:00
Rémi Verschelde
cc61c9d63d
Merge pull request #81487 from AThousandShips/null_check_core
[Core] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
2023-09-12 12:02:02 +02:00
Rémi Verschelde
38ca83e16f
Merge pull request #81464 from AcatXIo/fix-sign-nan
Fix `SIGN(NAN)` returning 1
2023-09-12 12:01:39 +02:00
A Thousand Ships
893f889d74 [Core] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-11 19:45:49 +02:00
Rémi Verschelde
43c7e8d3b5
Merge pull request #81515 from dsnopek/gdextension-validate-property-object
Allow implementing `Object::_validate_property()` from GDExtension
2023-09-11 15:40:05 +02:00
Rémi Verschelde
5f5ca23586
Merge pull request #81170 from KoBeWi/step_input
Prevent axis-based actions from getting stuck
2023-09-11 15:37:42 +02:00
Rémi Verschelde
786dab42fd
Merge pull request #70329 from Daylily-Zeleen/daylily-zeleen/register_internal_class
Allow GDExtension to register unexposed classes.
2023-09-11 15:35:31 +02:00
David Snopek
abef8e3874 Allow implementing Object::_validate_property() from GDExtension 2023-09-10 11:17:59 -05:00
AcatXIo
7d69a5ba50 Fix sign(NAN) returning 1.
Fixes #79036. sign(NAN) now returns 0.
This should not impact performance much in any way.
Adds a test for the NAN case. Updates the documentation to clarify the new behavior.
2023-09-09 11:30:11 +02:00
Aaron Franke
6f7eccc758
Add a type conversion method to Variant Utility and expose to scripting 2023-09-08 10:12:48 -05:00
Rémi Verschelde
8de6405288
UWP: Remove platform port, needs to be redone from scratch for 4.x
The UWP platform port was never ported to the Godot 4.0+ API,
and it's now accumulating bitrot as it doesn't compile, and thus
we no longer propagate platform changes in it.

So we finally remove to acknowledge this state. There's still some
interest in reviving the UWP port eventually, especially as support
for Direct3D 12 will soon be merged, but when that happens it will
be easiest to redo it from scratch.
2023-09-07 15:01:59 +02:00
Rémi Verschelde
7663c69922
Merge pull request #81388 from YuriSizov/core-gdvirtual-but-less-confused-about-itself
Extract `ScriptInstance` into its own file to simplify includes
2023-09-07 13:53:45 +02:00
Rémi Verschelde
d013fc3f03
Merge pull request #81304 from ajreckof/Change-precedence-in-rules-to-make-location-after-proper-casing-
Change precedence in rules to make location after proper casing.
2023-09-07 13:52:08 +02:00
Rémi Verschelde
d1c94eef06
Merge pull request #81261 from dsnopek/gdextension-validate-property
Allow implementing `ScriptInstance::validate_property()` from GDExtension
2023-09-07 13:51:44 +02:00
Yuri Sizov
d8ff69d53c Extract ScriptInstance to simplify includes
This allows to include script_instance.h directly in the
generated gdvirtual.gen.inc, and remove excessive includes
from the codebase.

This should also allow Resource to use GDVIRTUAL macros,
which wasn't possible previously due to a circular dependency.
2023-09-06 22:54:38 +02:00
Rémi Verschelde
0a7f75ec7b
Merge pull request #80740 from m4gr3d/godot_android_plugin_refactor_main
Godot Android plugin re-architecture
2023-09-06 00:09:07 +02:00
ajreckof
19632eaf50 Change precedence in rules to make location after proper casing. 2023-09-05 16:16:21 +02:00
bruvzg
2b3bbde6da
[String] Fix string conversion for -0.0 float values. 2023-09-05 11:32:55 +03:00
David Snopek
3e7a6e058a Allow implementing ScriptInstance::validate_property() from GDExtension 2023-09-04 13:55:48 -05:00
kobewi
a490fad82d Prevent axis-based actions from getting stuck 2023-09-04 15:47:26 +02:00
Rémi Verschelde
75de1ca768
Merge pull request #81280 from ogapo/deterministic_pcks
Fix for non-deterministic behavior in PCKPacker
2023-09-04 09:09:23 +02:00
Rémi Verschelde
dd4fae6162
Merge pull request #74809 from Chaosus/completion_color_xyzw
Add coloring for completion of vector components
2023-09-04 09:06:57 +02:00
Daylily-Zeleen
41ffe5461f Allow GDExtension to register unexposed class. 2023-09-04 10:18:20 +08:00
Fredia Huya-Kouadio
8cc7739197 Godot Android plugin re-architecture 2023-09-03 17:04:10 -07:00
David Nikdel
067807c1cb Remove nondeterminism in pck_packer
PCK files (like other build products) should be deterministic based on their inputs. Removed calls to Math::rand() that are being used to generate padding.

Looks like these were introduced as part of adding encryption support, but the padding being random does not have any cryptographic significance. This can be trivially inferred since file blocks that happen to be aligned don't get padding anyway.

If there's a desire to indroduce something that functions as a nonce it should probably be added explicitly and only if encryption is enabled.
remove Math::rand() calls in editor_export_platform.cpp

follow up to make consistent with pck_packer
2023-09-03 18:14:30 -04:00
Rémi Verschelde
fa3428ff25
Merge pull request #81221 from dalexeev/editor-inspector-and-signal-dock-improvements
Editor: Inspector and Signal docks improvements
2023-09-03 00:21:04 +02:00
Jan Haller
4e202bcec7 GDExtension: fix bool unknown in C 2023-09-02 21:04:49 +02:00
Rémi Verschelde
c326914c49
Merge pull request #81206 from dsnopek/script-instance-extension-memory-bug2
GDExtension: Allocate `GDExtensionScriptInstanceInfo2` for compatibility on the heap to prevent crash
2023-09-02 14:30:36 +02:00
Danil Alexeev
c33ca26e17
Editor: Inspector and Signal docks improvements 2023-09-02 08:50:28 +03:00
Daylily-Zeleen
67e1401891 Set builtin varrarg ptrcalls, called without arg. 2023-09-02 00:34:16 +08:00
Rémi Verschelde
bbdd1aaa38
Merge pull request #81131 from AThousandShips/callable_fix
Fix comparison of `Callable`s with binds
2023-09-01 16:02:35 +02: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 +02:00
David Snopek
83faf84ec9 GDExtension: Allocate GDExtensionScriptInstanceInfo2 for compatibility on the heap to prevent crash 2023-08-31 15:19:31 -05:00