Commit graph

817 commits

Author SHA1 Message Date
Hugo Locurcio
59f24d8867
Define a default minimum window size to workaround rendering issues
The minimum window size can still be set to `Vector2(0, 0)` in a script
if needed.
2021-08-23 04:10:24 +02:00
Rémi Verschelde
ffc372b002
Merge pull request #42220 from RandomShaper/agile_input_3.2
[3.x] Improve responsiveness on underpowered Android devices
2021-08-12 22:46:17 +02:00
lawnjelly
3025b6d299 Delta smoothing - fix overflow for long frames
Extremely long frames caused by suspending and resuming the machine could result in an overflow in the delta smoothing because it uses 32 bit math on delta values measured in nanoseconds.

This PR puts a cap of a second as the maximum frame delta that will be processed by the smoothing, otherwise it returns the frame delta 64 bit value unaltered. It also converts internal math to explicitly use 64 bit integers.
2021-08-11 09:47:23 +01:00
Pedro J. Estébanez
31a0ca2cac Add project setting for agile input event flushing
If enabled, key/touch/joystick events will be flushed just before every idle and physics frame.

Enabling this can greatly improve the responsiveness to input, specially in devices that need to run multiple physics frames per each idle frame, because of not being powerful enough to run at the target frame rate.

This will only work for platforms using input buffering (regardless event accumulation). Currenly, only Android does so, but could be implemented for iOS in an upcoming PR.
2021-08-08 12:37:55 +02:00
Pedro J. Estébanez
7be9c26e20 Add input buffering framework
Input buffering is implicitly used by event accumulation, but this commit makes it more generic so it can be enabled for other uses.

For desktop OSs it's currently not feasible given main and UI threads are the same).
2021-08-08 12:37:55 +02:00
Pedro J. Estébanez
58a54f534e Improve input event accumulation
- API has been simplified: all events now go through `parse_input_event()`. Whether they are accumulated or not depends on the `use_accumulated_input` flag.
- Event accumulation is now thread-safe (it was not needed so far, but it prepares the ground for the following changes).
- Touch drag events now support accumulation.
2021-08-08 12:37:55 +02:00
lawnjelly
37f20e1d78 Fix Transform::xform(Plane) functions, add Transform unit tests
The Transform::xform and xform_inv are made safe for Planes when using non-uniform scaling.

Basic unit tests for Transform.

Optimization of calling sites to prevent loss of performance from the changes to xform(Plane).
2021-08-07 08:05:39 +01:00
Hugo Locurcio
21a68d1c44
Print a warning when the engine is started as root/superuser
This is a security risk (especially when hosting a game server)
and can make audio non-functional on Linux.

(cherry picked from commit 9c34db6cb4)
2021-08-03 10:20:18 +02:00
lawnjelly
98a39aade9 Profiling - fix frame_time measurement
When the `sync_after_draw` feature was on it was possible for the profiler's frame_time measurement to be incorrect. This fixes this problem by storing the raw measured time for use by the profiler.
2021-08-01 10:05:43 +01:00
EricEzaM
0e5c6e0d55 Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.

Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True

Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.

Usage:

```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)

InputMap.event_is_action(p_event, "my_action", true)

func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```

Co-authored-by: Eric M <itsjusteza@gmail.com>
2021-07-30 15:35:39 +02:00
Aaron Franke
69fb14256b
[3.x] Allow getting Input axis/vector values from multiple actions
For get_vector, use raw values and handle deadzones appropriately
2021-07-23 19:17:55 -04:00
Aaron Franke
afa89c9eea
[3.x] Add raw strength value for internal use 2021-07-23 19:09:53 -04:00
lawnjelly
93557927e4 Add option to sync frame delta after draw
Investigations have showed that a lot of the random variation in frame deltas causing glitches may be due to sampling the time at the wrong place in the game loop.

Although sampling at the start of Main::Iteration makes logical sense, the most consistent deltas may be better measured after the location likely to block at vsync - either the OpenGL draw commands or the SwapBuffers.

Here we add an experimental setting to allow syncing after the OpenGL draw section of Main::Iteration.
2021-07-22 12:04:22 +01:00
Rémi Verschelde
d3f500cf33
Merge pull request #48390 from lawnjelly/delta_smooth
Add frame delta smoothing option
2021-07-22 12:43:39 +02:00
Rémi Verschelde
801205b2c1
Merge pull request #48892 from lawnjelly/bvh_robust
BVH - thread safety option
2021-07-22 12:41:42 +02:00
Rémi Verschelde
fde7c2c5b8
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@241fed0a44.

(cherry picked from commit a98677181b)
2021-07-20 13:20:40 +02:00
Fabio Alessandrelli
6d546692fe
[HTML5] Add 2 controllers to the godot database.
Sony PlayStation DualShock 4 (054c:05c4 first gen).
Unofficial Switch controller.

(cherry picked from commit 5717118bcc)
2021-07-20 13:05:10 +02:00
Rémi Verschelde
875045adde
Use modules_enabled.gen.h to improve inter dependency checks
- Fix build with gdscript module disabled. Fixes #31011.
- Remove unused `gdscript` compile option.
- Fix build with regex module disabled.
- Fix ImageLoaderSVG to forward declare thirdparty structs.

(cherry picked from commit f3726ee994)
2021-07-14 23:36:38 +02:00
lawnjelly
eb6f98ec55 Portal occlusion culling
Adds support for occlusion culling via rooms and portals.
2021-07-14 11:43:23 +01:00
lawnjelly
6914d7c6e0 Add frame delta smoothing option
Frame deltas are currently measured by querying the OS timer each frame. This is subject to random error. Frame delta smoothing instead filters the delta read from the OS by replacing it with the refresh rate delta wherever possible.

This PR also contains code to estimate the refresh rate based on the input deltas, without reading the refresh rate from the host OS.
2021-07-14 08:44:31 +01:00
Hugo Locurcio
6d60d92b87
Tweak the physics FPS property hint to only allow reasonable values
Physics FPS above 1000 cause the whole project to slow down
and are not very practical in the first place (since no CPU currently
available can keep up).

(cherry picked from commit 8f4ac7bc4a)
2021-06-17 12:47:53 +02:00
Marcel Admiraal
5a58516231 Remove duplicate ERR_PRINTS macro 2021-06-16 11:56:25 +01:00
Marcel Admiraal
18825ad4ff Fix game controllers ignoring the last listed button 2021-06-03 15:45:05 +01:00
Henry Conklin
a28beb3048
Add support for numeric XML entities to XMLParser
* Add support for decimal numeric entities to String::xml_unescape
* Add more error checks to String::xml_unescape
* Refactor XMLParser to use String::xml_unescape instead of an internal
implementation
2021-06-03 11:44:47 +02:00
lawnjelly
14ce176f10 BVH - thread safety option
Added optional thread safe version through template argument and runtime switch, that wraps access with a mutex.
2021-05-25 10:47:32 +01:00
Rémi Verschelde
ac3417005d
Merge pull request #48533 from mortarroad/3.x-convex-hull-ported
[3.x] Port Bullet's convex hull computer to replace of QuickHull
2021-05-22 23:23:15 +02:00
Morris Tabor
ba396caefc Replace QuickHull with Bullet's convex hull computer.
The code is based on the current version of thirdparty/vhacd and modified to use Godot's types and code style.

Additional changes:
- backported and extended PagedAllocator to allow leaked objects
- applied patch from https://github.com/bulletphysics/bullet3/pull/3037
2021-05-22 08:16:43 +02:00
Will Whitty
3f606263d5 Backport HMac crypto to 3.x
Fix headers

Fix docs formatting

Changes for PR

Fix tests
2021-05-20 13:29:38 +03:00
Rémi Verschelde
330ddc37b6
Merge pull request #48075 from lyuma/varying_fragment_to_light_3.4 2021-05-18 10:53:34 +02:00
Pedro J. Estébanez
817ffc01e1
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-16 17:52:31 +02:00
Lyuma
25016bf715 Backport 6b99bda "Added support for arrays as shader struct members" to 3.4 2021-05-14 11:28:48 -07:00
Lyuma
fc6bee0750 Backport 6f16239 "Implementation of struct for shaders" to 3.4 2021-05-14 11:28:48 -07:00
Rémi Verschelde
140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde
0c8b5b5c4d
Style: Remove redundant void argument lists
Using clang-tidy's `modernize-redundant-void-arg`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html
2021-05-04 16:40:33 +02:00
Rémi Verschelde
a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
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
8ec14c917f
Merge pull request #47469 from HEAVYPOLY/ios-pen-pressure
Add iOS pen pressure
2021-04-28 17:01:05 +02:00
Rémi Verschelde
263c250067
Main: Default --doctool path to '.' if none given
(cherry picked from commit 096ef0dc91)
2021-04-26 12:20:28 +02:00
Marcel Admiraal
9170314434 Avoid creating joy_names map entries when using Map operator[] 2021-04-17 20:41:10 +01:00
Hugo Locurcio
2c06545266
Improve command line --print-fps display
- Display the frame time in addition to FPS.
  - Frame time is a more objective measurement in comparison to FPS,
    but FPS is more familiar to people less acquainted with profiling.
- Rename "Game" to "Project" for the project FPS printing line.

(cherry picked from commit 157d8e4d36)
2021-04-12 00:23:44 +02:00
Rémi Verschelde
b076150b08
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@01dce71403.

(cherry picked from commit f83486b430)
2021-04-06 22:53:20 +02:00
Vaughan Ling
f60b90d92e Add iOS Apple Pencil pressure 2021-04-03 10:30:57 -07:00
Rémi Verschelde
69e6ba1591
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@807ac1fbf9.

(cherry picked from commit cde67f0315)
2021-03-23 13:41:06 +01:00
Fabio Alessandrelli
8b904e7d66
[HTML5] Logitech Dual Action Gamepad FF/Linux
(cherry picked from commit 70d5f652a2)
2021-03-23 13:16:23 +01:00
Hugo Locurcio
79f8b5eff1
Tweak the editor splash screen color to better match the default theme
This helps achieve a visually "smoother" transition between the splash
screen and the editor.

(cherry picked from commit ff2871f9ac)
2021-03-19 10:51:39 +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
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