Commit Graph

48185 Commits

Author SHA1 Message Date
Ignacio Roldán Etcheverry 282bd37e5c C#: Remove need for reflection to invoking callable delegates
We aim to make the C# API reflection-free, mainly for concerns about
performance, and to be able to target NativeAOT in refletion-free mode,
which reduces the binary size.

One of the main usages of reflection still left was the dynamic
invokation of callable delegates, and for some time I wasn't sure
I would find an alternative solution that I'd be happy with.

The new solution uses trampoline functions to invoke the delegates:

```
static void Trampoline(object delegateObj, NativeVariantPtrArgs args, out godot_variant ret)
{
    if (args.Count != 1)
        throw new ArgumentException($"Callable expected 1 arguments but received {args.Count}.");

    string res = ((Func<int, string>)delegateObj)(
        VariantConversionCallbacks.GetToManagedCallback<int>()(args[0])
    );

    ret = VariantConversionCallbacks.GetToVariantCallback<string>()(res);
}

Callable.CreateWithUnsafeTrampoline((int num) => "Foo" + num, &Trampoline);
```

Of course, this is too much boilerplate for user code. To improve this,
the `Callable.From` methods were added. These are overloads that take
`Action` and `Func` delegates, which covers the most common use cases:
lambdas and method groups:

```
// Lambda
Callable.From((int num) => "Foo" + num);

// Method group
string AppendNum(int num) => "Foo" + num;
Callable.From(AppendNum);
```

Unfortunately, due to limitations in the C# language, implicit
conversions from delegates to `Callable` are not supported.

`Callable.From` does not support custom delegates. These should be
uncommon, but the Godot C# API actually uses them for event signals.
As such, the bindings generator was updated to generate trampoline
functions for event signals. It was also optimized to use `Action`
instead of a custom delegate for parameterless signals, which removes
the need for the trampoline functions for those signals.

The change to reflection-free invokation removes one of the last needs
for `ConvertVariantToManagedObjectOfType`. The only remaining usage is
from calling script constructors with parameters from the engine
(`CreateManagedForGodotObjectScriptInstance`). Once that one is made
reflection-free, `ConvertVariantToManagedObjectOfType` can be removed.
2022-10-30 01:24:15 +02:00
Max Hilbrunner f013315980
Merge pull request #67754 from kleonc/tilemap-fix-collision-shapes-debug-draw
Fix `TileMap` collision shapes debug draw
2022-10-30 00:15:42 +02:00
Max Hilbrunner 6ac7afe7a7
Merge pull request #67836 from stevecotton/particles_demo_link
doc: link GPUParticles2D to a more appropriate demo
2022-10-30 00:10:56 +02:00
Max Hilbrunner a889c1d7a2
Merge pull request #67909 from Calinou/doc-enetpacketpeer
Document the ENetPacketPeer class
2022-10-30 00:09:24 +02:00
Max Hilbrunner f3e2f78b21
Merge pull request #67923 from Calinou/doc-displayserver
Document the DisplayServer class
2022-10-30 00:08:50 +02:00
Max Hilbrunner 11d74d606a
Merge pull request #67980 from DeeJayLSP/webpcase
Change all WEBP strings and comments to WebP
2022-10-29 19:28:47 +02:00
Yuri Rubinsky 11e1bac768
Merge pull request #67112 from Chaosus/fix_boolean_uniform_instances 2022-10-28 23:17:23 +03:00
Clay John 3fa339cfc4
Merge pull request #67849 from kdada/fix-built-in-script-crash
Fix built-in script path of GDScript to prevent crash
2022-10-28 13:04:36 -07:00
Clay John 04ac91f786
Merge pull request #67790 from kdada/fix-flash-window
Make creating window do not flicker when specify custom position
2022-10-28 13:02:58 -07:00
Clay John 282e50ac88
Merge pull request #67903 from Sauermann/fix-startup-windows-mouse-exit-event
Fix differences between Windows and linuxbsd Display Server
2022-10-28 11:20:36 -07:00
DeeJayLSP dd64ceab47 Change all WEBP strings and comments to WebP 2022-10-28 15:17:49 -03:00
Clay John c2caaff96a
Merge pull request #67978 from DeeJayLSP/rename-layered-modes
ResourceImporterLayeredTexture: rename compress modes to match enum
2022-10-28 10:58:37 -07:00
Clay John ada2661a2c
Merge pull request #67956 from RedMser/safe-velocity-type
Fix type of `safe_velocity` parameter
2022-10-28 10:57:46 -07:00
Clay John e3b66ff9e3
Merge pull request #67621 from groud/resource_saver_expose_recognize_path
Expose the logic to recognize a save path in ResourceSaver
2022-10-28 10:56:32 -07:00
DeeJayLSP 0619bd44da ResourceImporterLayeredTexture: rename compress modes to match enum 2022-10-28 14:24:32 -03:00
Yuri Rubinsky 999df8cdbf
Merge pull request #67974 from Mickeon/spaaaaaaace 2022-10-28 17:40:11 +03:00
Micky 0e0a233859 Fix spacing of few PROPERTY_HINT_ENUM hint_strings 2022-10-28 14:51:26 +02:00
Max Hilbrunner 028db9f2b5
Merge pull request #67914 from Calinou/displayserverx11-no-native-icon
Fix `DisplayServer.has_feature()` claiming X11 has native icon support
2022-10-28 12:46:57 +02:00
Gilles Roudière e23f82f3c1 Expose the logic to recognize a save path in ResourceSaver 2022-10-28 11:15:25 +02:00
Markus Sauermann 4bd601d82a Fix differences between Windows and linuxbsd Display Server
Fix that Windows receive WINDOW_EVENT_MOUSE_EXIT on startup.

When moving the mouse cursor from one window to a different one, make sure that the first window receives the WINDOW_EVENT_MOUSE_EXIT event before the second window receives the WINDOW_EVENT_MOUSE_ENTER event.

Send Mouse-Move events also for Windows, that are currently not focused.

For determining the currently hovered window, consider not just the currently focused window, but also other windows.

Send mouse move events to focused window instead of hovered window.
2022-10-28 09:32:25 +02:00
Yuri Rubinsky 468762b3b7
Merge pull request #67498 from Chaosus/fix_shader_crash 2022-10-28 09:25:07 +03:00
Max Hilbrunner 9ff3a43a32
Merge pull request #67957 from zCubed3/fix_headless_crash
Fix `OS.get_video_adapter_driver_info` crash on headless godot
2022-10-28 03:32:59 +02:00
Bastiaan Olij 6a61d22ce7
Merge pull request #67960 from clayjohn/RD-SSIL
Fix ss_effects_flags uniform in clustered forward renderer
2022-10-28 12:31:39 +11:00
Clay John 0486810697
Merge pull request #67644 from alfredbaudisch/add-selection-next-occurrence
Add Selection and Caret for Next Occurrence of Selection
2022-10-27 17:21:49 -07:00
Clay John bc7e0f0616
Merge pull request #67946 from BastiaanOlij/openxr_default_aimpose
Change default OpenXR pose to aim pose
2022-10-27 17:17:07 -07:00
zCubed3 e7091d07cd
Fix OS.get_video_adapter_driver_info crash 2022-10-27 15:45:21 -07:00
clayjohn 31c1a06ab5 Fix ss_effects_flags uniform in clustered forward renderer
This comes from an uncaught merge conflict resulting from the split of scene_data into
scene_data and implementation_data
2022-10-27 15:37:38 -07:00
RedMser b9c3a5534b Fix type of safe_velocity parameter 2022-10-27 22:45:24 +02:00
Clay John 4dc2c8ae6f
Merge pull request #67939 from sambriels/emit-signal-after-target-reached
[NavigationAgent2D/3D]: target_reached signal is emitted before internal state is updated
2022-10-27 12:52:13 -07:00
Clay John 24e788e9be
Merge pull request #67874 from Calinou/doc-vector3-vector4i
Document the Vector3 and Vector4i classes
2022-10-27 12:48:34 -07:00
Clay John aa989cb26f
Merge pull request #64382 from peastman/support
Optimized support function for large meshes
2022-10-27 12:40:39 -07:00
Clay John 9ffa86357d
Merge pull request #67421 from Sauermann/fix-failure-exit-code
Fix Godot exiting with unexpected failure code
2022-10-27 11:58:50 -07:00
Clay John 0d711cad30
Merge pull request #66107 from devloglogan/ambient-light-disabled-fix
Fix ambient_light_disabled render mode flag
2022-10-27 10:08:29 -07:00
Clay John 8fd92ed867
Merge pull request #64710 from MinusKube/window-size-crash
Prevent windows from having a size greater than device limit
2022-10-27 10:02:44 -07:00
Clay John e1caa8797b
Merge pull request #67043 from clayjohn/clip_children
Improve behaviour of clip_children by clipping to parent alpha value but still retaining parent color
2022-10-27 09:59:27 -07:00
Clay John 2f2c138b44
Merge pull request #67926 from Rindbee/fix_call_shortcut_input
Fix calling `_call_shortcut_input` on a node that has been removed
2022-10-27 09:56:55 -07:00
Clay John 5f575bf1fa
Merge pull request #67861 from IanGaither/textfile-alignment-documentation
TextLine - Added description for alignment member
2022-10-27 09:51:19 -07:00
Clay John 8a5e0b8caf
Merge pull request #67834 from Klowner/collada-closed-curves-16658
Handle closed splines in Collada importer
2022-10-27 09:48:21 -07:00
Clay John d1cc93af89
Merge pull request #67832 from Sauermann/fix-remove-unnecessary-casts
Remove unnecessary casts
2022-10-27 09:47:34 -07:00
Steve Cotton 6db9752f23 doc: link GPUParticles2D to the 2D Particles demo
Add a comment in the link to the Dodge The Creeps demo too. That demo only uses
particles for one thing (to leave a trail when the player moves), they're not
interacting with anything else in the demo; it took me a bit of searching to
find where they were used.
2022-10-27 18:46:56 +02:00
Clay John 682156e1f0
Merge pull request #66383 from aaronfranke/basis-from-euler
Clean up Basis from Euler code
2022-10-27 09:44:21 -07:00
Fabio Alessandrelli 7904f70dc4
Merge pull request #67094 from Faless/mp/4.x_server_relay_unify
[MP] Move packet relay and peer signaling code to SceneMultiplayer.
2022-10-27 18:34:29 +02:00
Hugo Locurcio 0fce78355d
Document the DisplayServer class
This also adds a link to the Command line tutorial on pages
that reference command line arguments, as the page covers some
general usage tips for CLI arguments (especially on macOS).
2022-10-27 18:24:55 +02:00
Fabio Alessandrelli 7536d15fe3 [MP] Let MultiplayerAPI handle packet relaying and peer signaling.
MultiplayerPeer changes:

- Adds is_server_relay_supported virtual method

Informs the upper MultiplayerAPI layer if it can signal peers connected
to the server to other clients, and perform packet relaying among them.

- Adds get_packet_channel and get_packet_mode virtual methods

Allows the MultiplayerAPI to retrieve the channel and transfer modes to
use when relaying the last received packet.

SceneMultiplayerPeer changes:

- Implement peer signaling and packet relaying when the MultiplayerPeer
  advertise they are supported.

ENet, WebRTC, WebSocket changes:

- Removed custom code for relaying from WebSocket and ENet, and let it
  be handled by the upper layer.
- Update WebRTC to split create_client, create_server, and create_mesh,
  with the latter behaving like the old initialize with
  "server_compatibility = false", and the first two supporting the upper
  layer relaying protocol.
2022-10-27 18:08:58 +02:00
Bastiaan Olij 91945c3077 Change default OpenXR pose to aim pose 2022-10-28 01:56:06 +11:00
Sam Briels 815231943b Emit target_reached signal after state is updated 2022-10-27 14:05:43 +02:00
Clay John 03e5de37ae
Merge pull request #67912 from RevoluPowered/fix-exeception-bad-access
Fix EXE_BAD_ACCESS caused by optional argument
2022-10-26 23:06:22 -07:00
Rindbee c77349ecb7 Fix calling `_call_shortcut_input` on a node that has been removed
Nodes may have been deleted by shortcuts. For example, when switching
scenes with `Ctrl` + `Tab` / `Ctrl` + `Shift` + `Tab`, some controls
will be deleted and recreated.
2022-10-27 14:05:51 +08:00
Hugo Locurcio 7d7b4210f6
Document the Vector3 and Vector4i classes 2022-10-27 02:50:37 +02:00
Clay John 06cad89060
Merge pull request #67905 from alfredbaudisch/vs-operand-aliases-dev
Add math operators to Visual Shader node names for easier and simpler searching
2022-10-26 12:18:43 -07:00