Commit graph

3337 commits

Author SHA1 Message Date
Rémi Verschelde b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde 64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde 3d15f04668
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde 6e600cb3f0
Style: Set clang-format Standard to c++14 2021-05-04 14:45:15 +02:00
Rémi Verschelde 2660f24160
Merge pull request #48429 from kleonc/posmod-change-int-to-int64
[3.x] Make posmod use int64_t instead of int
2021-05-04 12:31:01 +02:00
Rémi Verschelde 32cc022267
Merge pull request #48314 from nekomatata/physics-2d-dynamic-bvh
[3.x] Support for Dynamic BVH as 2D Physics broadphase
2021-05-04 09:23:04 +02:00
kleonc f04a964627 Make posmod use int64_t instead of int 2021-05-03 22:03:16 +02:00
Fabio Alessandrelli 77e3514315
[Net] Implement String::parse_url for parsing URLs.
Splits the URL into (scheme, host, port, path).
Supports both literal IPv4 and IPv6.
Strip credentials when present (e.g. http://user:pass@example.com/).

Use that function in both HTTPRequest and WebSocketClient.

(cherry picked from commit 3bb40669d5)
2021-05-03 21:39:43 +02:00
MaxStgs 0bb40df4bb Check PHashTranslation generate p_from is valid 2021-05-03 19:58:40 +05:00
MaxStgs 94d0c4182b Add PackedDataContainer data pointer check for non nullable 2021-05-02 15:56:36 +05:00
PouleyKetchoupp d8f681029f Support for Dynamic BVH as 2D Physics broadphase
List of changes:
- Modified bvh class to handle 2D and 3D as a template
- Changes in Rect2, Vector2, Vector3 interface to uniformize template
calls
- New option in Project Settings to enable BVH for 2D Physics (enabled
by default like in 3D)
2021-04-30 15:53:15 -07:00
Rémi Verschelde e94161dada
SCons: Add explicit dependencies on thirdparty code in cloned env
Since we clone the environments to build thirdparty code, we don't get an
explicit dependency on the build objects produced by that environment.

So when we update thirdparty code, Godot code using it is not necessarily
rebuilt (I think it is for changed headers, but not for changed .c/.cpp files),
which can lead to an invalid compilation output (linking old Godot .o files
with a newer, potentially ABI breaking version of thirdparty code).

This was only seen as really problematic with bullet updates (leading to
crashes when rebuilding Godot after a bullet update without cleaning .o files),
but it's safer to fix it everywhere, even if it's a LOT of hacky boilerplate.

(cherry picked from commit c7b53c03ae)
2021-04-29 16:57:00 +02:00
Rémi Verschelde 70ae90e0e8
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.

Backport of #48239.
2021-04-29 12:34:11 +02:00
Pasi Nuutinmaki f8c4ffcdde
Fix area calculation of Face3
There seemed to be a bug in area calculation in Face3::get_area()-function. It returned the area of "imaginary" parallelogram instead of the triangle. Therefore the area returned was twice the real area. This manifested itself when using a hydro module for godot ( https://gitlab.com/ringtechsolutions/godot-tools/hydro/hydro ) causing the buoyancy to be two times the expected value.

"Reference": http://www.maths.usyd.edu.au/u/MOW/vectors/vectors-11/v-11-7.html

(cherry picked from commit a165eed73b)
2021-04-29 11:10:50 +02:00
Rémi Verschelde 3ded745305
Merge pull request #47887 from Pineapple/separate-set-3x
[3.x] Separate set.h from map.h
2021-04-28 16:58:09 +02:00
Rémi Verschelde 2d57df60f7
Merge pull request #48144 from Faless/crypto/3.3_encryption_stable 2021-04-27 13:46:49 +02:00
Sergey Minakov 78837f5c65
Core: add EOF check for json parser
Additionally reset parse result if error was found.

(cherry picked from commit a2676ff810)
2021-04-26 13:07:59 +02:00
Fabio Alessandrelli dcd5433b3b Implement RSA encryption/decryption. 2021-04-24 00:04:56 +02:00
Fabio Alessandrelli 09b9e65688 Implement sign and verify in crypto. 2021-04-24 00:04:56 +02:00
Fabio Alessandrelli 09af27fa39 CryptoKey supports public keys. 2021-04-24 00:04:56 +02:00
Fabio Alessandrelli ef77fb0a38 Add AESContext.
GDScript interface to CryptoCore::AESContext.
Also add CBC mode in CryptoCore::AESContext and expose it.
2021-04-24 00:04:56 +02:00
kobewi 07fb3c6aca
Make randomize() use unix time too
(cherry picked from commit 22efa850bd)
2021-04-23 21:50:34 +02:00
Rémi Verschelde 6ed82812aa
NodePath: Remove unimplemented get_parent() method
Fixes #48100.

(cherry picked from commit 12f826da7d)
2021-04-23 21:50:00 +02:00
kleonc 4d7f642fb3 Improve some argument names for core types 2021-04-23 15:34:24 +02:00
Rémi Verschelde 10e86bc017
Add type_traits include for std::is_trivially_destructible
(cherry picked from commit 3d46f28558)
2021-04-22 17:22:52 +02:00
Rémi Verschelde 1c9203ad68
Object: Make deleted object access raise errors, not warnings
Clarify doc about not decaying to `null` for `free` and `queue_free`.

Part of #45639.
2021-04-20 11:37:39 +02:00
Rémi Verschelde 701fa8a779
Revert "Fix _File::get_buffer length always set to p_length"
This reverts commit 9a7e537aac.

Fixes #47971.
2021-04-17 13:07:18 +02:00
Bartłomiej T. Listwon 011a3d69e2 Separate set.h from map.h 2021-04-14 13:06:12 +02:00
Johannes 9a7e537aac
Fix _File::get_buffer length always set to p_length
(cherry picked from commit 33d6eccdec)
2021-04-12 00:23:43 +02:00
Daniel Kříž edcb95cede
fix wrong encoding in uri_encode
(cherry picked from commit 13c999d9d7)
2021-04-12 00:23:43 +02:00
jmb462 ce4dec647c
fix crash on null class in ClassDB.get_property() and set_property()
(cherry picked from commit 400843c172)
2021-04-05 12:02:32 +02:00
lawnjelly d67975c1cd BVH - prevent self collisions
I had missed a special case check for userdata of two colliding objects being equal. In this case, collisions should not be reported. This is used in the physics to prevent self intersection in composite objects.
2021-04-04 09:13:58 +01:00
Hein-Pieter van Braam-Stewart ff3099abcf Fix thread_local, tls, ASLR, and DEP with MingW
This commit changes the way Thread::caller_id works. By moving caller_id
to the .cpp file we make sure that the TLS variable doesn't get
relocated twice causing a crash. Since we build with LTO for release
builds (and everyone should be doing that anyway) there is no extra
overhead from the non-static method. We do do an extra bool check now
there but I don't think this will add much in the way of overhead.

This check cannot be avoided if we still want to be able to cache the
thread ID hash, as we had to move the setter because of limitations of
the WinRT platform. The original workaround for this was in #46813 but
this has some unintended consequences. Specifically; threads that never
create a Thread object will always return 0 in Thread::get_caller_id()
which caused a regression. For instance the editor now freezes when
importing large textures. This PR also addresses that.

Additionally we now enable ASLR support when building with MingW, this
includes a workaround for MingW. MingW refuses to create an appropriate
relocation table if no symbols are exported. So we just export the
various main() functions in godot_windows.cpp.

While ASLR support isn't criticial for Godot, previous versions of Godot
just happened to work with a dynamic base 'by accident' and some users
run Godot this way. After the thread change the .tls section now needs
relocations to make this work. By enabling ASLR at build-time we create
these relocations and people who forced ALSR on previously will now get
a working Godot again.

This fixes #47256 and fixes #47219

This is the 3.x version of this PR. For master a different approach is
possible which I will make in the coming days.
2021-03-25 23:20:12 +01:00
Juan Linietsky 24e1ba1298
Add a "keep" import mode to keep files as-is and export them.
(cherry picked from commit 8d64f3bd76)
2021-03-23 15:44:24 +01:00
Alex Hirsch 0b541af8a1
Allow nullptr with zero length in FileAccess get_buffer
fix #47071

(cherry picked from commit c28428fe4d)
2021-03-17 15:17:02 +01:00
Fredia Huya-Kouadio 0eb220eedc
Fix bug causing project.godot to be ignored when project.binary is missing
(cherry picked from commit 862e2df1a4)
2021-03-17 15:17:02 +01:00
Haoyu Qiu 0a17e96ab2 Fix invalid memory usage when modifying locked image 2021-03-16 13:45:45 +08:00
Alex Hirsch 5a882a659a
Add parameter checkes to FileAccess get_buffer functions
fix #46540

(cherry picked from commit cdf3099c68)
2021-03-14 12:03:22 +01:00
Rémi Verschelde ba174332af
Merge pull request #46939 from abaire/relaxes_gltf_name_sanitization_3.2
Relaxes Node naming constraints in glTF documents to match the Editor.
2021-03-13 14:57:09 +01:00
abaire b032067e42 Relaxes Node naming constraints in glTF documents to match the Editor. 2021-03-12 08:35:50 -08:00
Aitor Cereceto 7e5020b2fa [46188] fix: get unix from datetime when empty dict
(cherry picked from commit 1e820b3d9d)
2021-03-12 10:17:41 +01:00
bruvzg 8feb53e509 Move caller_id init to Thread constructor to fix UWP build.
(cherry picked from commit 741e1cf672)
2021-03-12 10:12:52 +01:00
lawnjelly 20f7037edb Add GLOBAL_DEF_ALIAS and alias for rename of pixel_snap
Having to rename project settings is rare, but when it does occur it can cause user confusion. In order to make compatibility more seamless this PR introduces two new GLOBAL_DEF functions,

GLOBAL_DEF_ALIAS(new_name, old_name, default)
GLOBAL_DEF_ALIAS_RST(new_name, old_name, default)

These are the same as the existing GLOBAL_DEF functions except that if the new setting is not found, it attempts to load from the old setting name. If the old setting is found, it stores it into the new setting, and then calls the regular GLOBAL_DEF functions.
2021-03-09 15:16:24 +00:00
Ev1lbl0w bae4b0c952
Fix negative VRAM values 2021-03-09 09:51:17 +00:00
kobewi e9e0cac3f5 Allow to save override.cfg with ProjectSettings
(cherry picked from commit 156c402f2b)
2021-03-08 17:40:22 +01:00
Rémi Verschelde 118567ca28
Merge pull request #46657 from lawnjelly/revert_snapping
Revert backport of 2D transform and camera snapping options
2021-03-08 14:49:41 +01:00
bruvzg ce11f7fa3e
[3.2] Improve thread IDs to avoid collisions with threads not created by the Godot API. 2021-03-07 10:09:02 +02:00
lawnjelly bf1de6bbfa Revert backport of 2D transform and camera snapping options
More work is needed to make sure that those options actually solve users' issues, so we prefer to remove the options for 3.2.4 and revisit for a future release.
2021-03-05 14:20:31 +00:00
Pedro Rodrigues eec2731eb2 Fix crash on HTTPClient::poll method
The problem happened because `poll` assumed that when the SSL flag was
true, the `connection` would be a subclass of StreamPeerSSL. However
that invariant could be broken by calling HTTPClient::set_connection
with a `connection` that is not a subclass of StreamPeerSSL.

Fixes #46138

(cherry picked from commit a3a731ed92)
2021-03-04 11:39:51 +01:00
kleonc 5022103ee7 Make Color::from_hsv use Color::set_hsv
(cherry picked from commit b59a06da25)
2021-03-04 11:39:02 +01:00
Mateo Kuruk Miccino 04fefed904 Logger: Cache 'flush_stdout_on_print' to improve performance, and works before ProjectSettings starts.
ProjectSetting: Now 'application/run/flush_stdout_on_print' requires a restart of the Editor to take effect

(cherry picked from commit 89283b7b53)
2021-03-02 10:26:14 +01:00
lawnjelly b1e24597e7 Renaming rendering/2d project settings.
The rendering/quality/2d section of project settings is becoming considerably expanded in 3.2.4, and arguably was not the correct place for settings that were not really to do with quality.

3.2.4 is the last sensible opportunity we will have to move these settings, as the only existing one likely to break compatibility in a small way is `pixel_snap`, and given that the whole snapping area is being overhauled we can draw attention to the fact it has changed in the release notes.

Class reference is also updated and slightly improved.

`pixel_snap` is renamed to `gpu_pixel_snap` in the project settings and code to help differentiate from CPU side transform snapping.
2021-03-01 11:38:46 +00:00
Fabio Alessandrelli 9084e2e85b Fix thread_process_array when NO_THREADS.
(cherry picked from commit dfbeb5ae29)
2021-02-26 15:23:23 +01:00
Carlos Cabello d6c67d0521 Add descriptive error message when trying to access a dir fails
(cherry picked from commit edb8c11970)
2021-02-25 22:40:32 +01:00
Hugo Locurcio b2725cb4b9 Improve the OS.get_environment()/OS.set_environment() documentation
(cherry picked from commit 355803db1b)
2021-02-25 22:38:07 +01:00
Pedro J. Estébanez 5a67eefbcf Fix SafeNumeric::conditional_increment() for NO_THREADS
(cherry picked from commit b1edb69249)
2021-02-25 22:34:15 +01:00
Emmanuel Leblond 94fe2dd31e
Fix Godot returned status code on unexpected error 2021-02-25 18:39:29 +01:00
Rémi Verschelde dadba2b391
Merge pull request #46392 from YeldhamDev/here_comes_another_rc
Backport the Import Defaults Editor
2021-02-25 15:45:34 +01:00
kleonc 5d628535b9 Geometry2D::make_atlas Fail is passed invalid rect size
(cherry picked from commit 988f4cdc90)
2021-02-25 15:14:32 +01:00
andybarcia 82b31fe8e7 Fixes some inconsistent ISO-639 language codes
And also adds tmz (Central Atlas Tamazight) as a language

(cherry picked from commit 476df5e198)
2021-02-25 15:14:32 +01:00
Pedro J. Estébanez ef129acedd Prevent thread wait on itself for finish
(cherry picked from commit afc5af8dfa)
2021-02-25 14:28:16 +01:00
Bastiaan Olij e9ce9a8422 Expose set_environment to GDScript 2021-02-25 22:07:38 +11:00
Michael Alexsander 95191b9826 Backport the Import Defaults Editor 2021-02-24 17:50:42 -03:00
bruvzg 5bbacc85bd
Expose String contents to the GDScript as PoolByteArray. 2021-02-23 13:43:36 +02:00
Delf Neumärker 4f891b7060 Fix unchecked array access in build_*_planes
(cherry picked from commit f054f760e6)
2021-02-22 21:43:28 +01:00
Rémi Verschelde 0abf702d4b
Merge pull request #45957 from lupoDharkael/natural-comp
[3.2] Add natural string comparison
2021-02-22 11:07:54 +01:00
Hugo Locurcio 9f236d48e6 Don't allow negative values for OS.delay_usec()/OS.delay_msec()
This closes #46190.

(cherry picked from commit 76f1f9b3c5)
2021-02-19 15:52:54 +01:00
Pedro J. Estébanez 55b5f98402 Improve robustness of atomics
And fix increment in `CowData` not being conditional anymore after the recent changes.

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-02-19 11:48:30 +01:00
Hein-Pieter van Braam 220f24c191
Merge pull request #45618 from RandomShaper/modernize_mt_3.2
Backport of all the multi-threading modernization (3.2)
2021-02-18 20:47:24 +01:00
Rémi Verschelde 7af8da32b1
Merge pull request #45933 from nekomatata/cylinder-support-3.2
[3.2] Cylinder support in Godot Physics 3D
2021-02-18 19:36:42 +01:00
PouleyKetchoupp c6fbd55ca9 Cylinder support in Godot Physics 3D
Backport of cylinder support from Master.
2021-02-18 08:44:23 -07:00
Pedro J. Estébanez 4485b43a57 Modernize atomics
- Based on C++11's `atomic`
- Reworked `SafeRefCount` (based on the rewrite by @hpvb)
- Replaced free atomic functions by the new `SafeNumeric<T>`
- Replaced wrong cases of `volatile` by the new `SafeFlag`
- Platform-specific implementations no longer needed

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-02-18 12:23:25 +01:00
Pedro J. Estébanez 6d89f675b1 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez 8f6a636ae7 Modernize Semaphore
- Based on C++11's `mutex` and `condition_variable`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez 4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez b450036120 Modernize RWLock
- Based on C++14's `shared_time_mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:41:07 +01:00
Rémi Verschelde 7c3602dc8c
doc: Sync classref with current source 2021-02-16 14:47:29 +01:00
kobewi 5a290e0a3c
Don't save project settings when not necessary
(cherry picked from commit 4db47eb32e)
2021-02-16 14:27:38 +01:00
Hugo Locurcio 6c6f4e9895
Expose a File.flush() method to scripting
This can be used to ensure a file has its contents saved
even if the project crashes or is killed by the user
(among other use cases).

See discussion in #29075.

(cherry picked from commit ab397460e9)
2021-02-16 14:27:38 +01:00
Hugo Locurcio 15d9f77f97
Add a project setting to enable stdout flushing in release builds
This can be used in server builds for journalctl compatibility.

(cherry picked from commit 341b9cf15a)

Fixes crash when exiting with --verbose with leaked resources

(cherry picked from commit 25c4dacb88)
2021-02-16 14:27:38 +01:00
lawnjelly a814dda2ae BVH - fix deferred visible mesh collision check
When making items visible from the visual server, the collision check is deferred to prevent two identical collision checks when set_pairable is called shortly after.

It turns out that for some items (especially meshes), set_pairable is never called. This PR detects this occurrence and forces a collision check at the end of the routine.
2021-02-14 09:03:26 +00:00
lupoDharkael 460e1b94c3 [3.2] Add natural string comparison 2021-02-13 15:13:58 +01:00
Hugo Locurcio 28127ce224
Print suggestions when requesting a nonexistent InputMap action
Co-authored-by: Marc Gilleron <marc.gilleron@gmail.com>
2021-02-11 18:00:26 +01:00
Meriipu 347a9df0a1
GDScript: Clarified/fixed inaccuracies in the built-in function docs.
The input to smoothstep is not actually a weight, and the decscription
of smoothstep was pretty hard to understand and easy to misinterpret.

Clarified what it means to be approximately equal.

nearest_po2 does not do what the descriptions says it does. For one,
it returns the same power if the input is a power of 2. Second, it
returns 0 if the input is negative or 0, while the smallest possible
integral power of 2 actually is 1 (2^0 = 1). Due to the implementation
and how it is used in a lot of places, it does not seem wise to change
such a core function however, and I decided it is better to alter the
description of the built-in.

Added a few examples/clarifications/edge-cases.

(cherry picked from commit 7f9bfee0ac)
2021-02-11 13:12:06 +01:00
kleonc e900ca1f76
Make String::ends_with don't use String::rfind
(cherry picked from commit ad0943e3d3)
2021-02-11 13:12:06 +01:00
kobewi e7ee561ca0 Detect external modification of scenes 2021-02-11 01:08:49 +01:00
Aaron Franke f201382a85
[3.2] Use instance and first arg in Basis is_equal_approx
Discards the second argument.
2021-02-09 05:09:51 -05:00
Marcel Admiraal 3dd57a22df Add support for new SDL gamecontroller keywords. 2021-02-07 16:41:23 +00:00
Pedro J. Estébanez ae215451fc Make audio bus channels' peak volume consistent
Channels that are inactive -or when playback has not started yet- will report -200 dB as their peak value (which is also the lowest value possible during playback).

(cherry picked from commit a2b3a73e2d)
2021-02-05 09:26:09 +01:00
lawnjelly 00bd087d82 BVH add support for visibility (activation)
A major feature lacking in the octree was proper support for setting visibility / activation. This meant that invisible objects were still causing lots of processing in the tree unnecessarily.

This PR adds proper support for activation, items are temporarily removed from the tree and collision detection when inactive.
2021-01-30 13:21:40 +00:00
Rémi Verschelde 19ff78c528
Merge pull request #45530 from lawnjelly/bvh_pair_aabb_fix
BVH fix pairing AABB init and mask checks
2021-01-29 15:44:49 +01:00
Aaron Franke 226528097e
[3.2] Backport hex_to_int/bin_to_int zero check and C# changes 2021-01-28 09:24:44 -05:00
lawnjelly df18f72384 BVH fix pairing AABB init and mask checks
Fix bug whereby AABBs were reused from previous items due to use of a pool, resulting in missed collisions.
Also use full mask collision checks for all cases except generic update.
2021-01-28 14:01:03 +00:00
lawnjelly ba5e4d8baa BVH fix stale changed items, causing dangling pairs
In the octree collisions are flushed as objects are moved, whereas in the BVH they are usually flushed once per frame.

This was causing problems in the render tree in some rare situations where objects were being created (perhaps deleted and recreated using the same handle in the same frame). This PR flushes the collisions before creating objects, and set_pairable.

set_pairable may not be necessary but it is done for safety until proven not necessary.

Also a small potential for a bug is closed in remove_unordered use.
2021-01-27 16:14:32 +00:00
Hugo Locurcio eb0ca31ac1
Add an OS.get_thread_caller_id() method
This can be used to print thread IDs in logs. This can make it easier
to debug multi-threaded applications.

Co-authored-by: Khaos <khaos@khaos-coders.org>
(cherry picked from commit 35b046ddf7)
2021-01-26 22:10:30 +01:00
Vedat Günel 39cf22a9c7
Fix String.ends_with() for empty string arguments
(cherry picked from commit 1d0437c95b)
2021-01-26 17:00:17 +01:00
Rémi Verschelde 6d5daac3e4
Merge pull request #45312 from qarmin/remove_thread_lightmapper
Remove thread after use to prevent memory leak
2021-01-20 10:43:03 +01:00
Rafał Mikrut d025194602 Remove thread after use to prevent memory leak 2021-01-20 09:37:25 +01:00
lawnjelly 4954a869bb BVH render tree new updating scheme
Change render BVH update scheme from once per update_dirty_instances to a new update_scenarios function called once per draw.

Fix lights not being properly unpaired.
Fixed bug in add_changed_item where AABBs were not being updated due to more than one update per tick.
2021-01-19 14:24:32 +00:00
lawnjelly a241aeb289 Fix BVH set_pairable and masks.
Calling set_pairable now will update collisions (rather than waiting for the next item_move).

Mask behaviour used for pairing now (hopefully) matches octree.
2021-01-17 15:00:49 +00:00