Commit graph

36903 commits

Author SHA1 Message Date
Rémi Verschelde ca0ce5b46e
Merge pull request #52610 from neikeq/dotnet6_wip2 2021-10-03 10:14:09 +02:00
Ignacio Roldán Etcheverry 3388d68dff CI: Setup .NET Sdk to fix CI and build C# code as well 2021-09-22 08:27:12 +02:00
Ignacio Roldán Etcheverry 50b603c7dc C#: Begin move to .NET Core
We're targeting .NET 5 for now to make development easier while
.NET 6 is not yet released.

TEMPORARY REGRESSIONS
---------------------

Assembly unloading is not implemented yet. As such, many Godot
resources are leaked at exit. This will be re-implemented later
together with assembly hot-reloading.
2021-09-22 08:27:12 +02:00
Ignacio Roldán Etcheverry f744d99179 C#: Restructure code prior move to .NET Core
The main focus here was to remove the majority of code that relied on
Mono's embedding APIs, specially the reflection APIs. The embedding
APIs we still use are the bare minimum we need for things to work.
A lot of code was moved to C#. We no longer deal with any managed
objects (`MonoObject*`, and such) in native code, and all marshaling
is done in C#.

The reason for restructuring the code and move away from embedding APIs
is that once we move to .NET Core, we will be limited by the much more
minimal .NET hosting.

PERFORMANCE REGRESSIONS
-----------------------

Some parts of the code were written with little to no concern about
performance. This includes code that calls into script methods and
accesses script fields, properties and events.
The reason for this is that all of that will be moved to source
generators, so any work prior to that would be a waste of time.

DISABLED FEATURES
-----------------

Some code was removed as it no longer makes sense (or won't make sense
in the future).
Other parts were commented out with `#if 0`s and TODO warnings because
it doesn't make much sense to work on them yet as those parts will
change heavily when we switch to .NET Core but also when we start
introducing source generators.
As such, the following features were disabled temporarily:
- Assembly-reloading (will be done with ALCs in .NET Core).
- Properties/fields exports and script method listing (will be
  handled by source generators in the future).
- Exception logging in the editor and stack info for errors.
- Exporting games.
- Building of C# projects. We no longer copy the Godot API assemblies
  to the project directory, so MSBuild won't be able to find them. The
  idea is to turn them into NuGet packages in the future, which could
  also be obtained from local NuGet sources during development.
2021-09-22 06:38:00 +02:00
Ignacio Roldán Etcheverry 3f1a620102 C#: Re-write GD and some other icalls as P/Invoke 2021-09-22 06:38:00 +02:00
Ignacio Roldán Etcheverry bbde1b1f09 C#: Re-write Array, Dictionary, NodePath, String icalls as P/Invoke 2021-09-12 19:49:39 +02:00
Ignacio Roldán Etcheverry 66a89c7925 C#: Remove DynamicGodotObject/Object.DynamicObject
We are moving in the direction of no dynamic code generation,
so this is no longer desired.

The feature can still be easily implemented by any project that
still want it.
2021-09-12 19:49:23 +02:00
Rémi Verschelde f580b1efdc
Merge pull request #48409 from neikeq/oh-im-die-ty-4ever
C#: Move marshaling logic and generated glue to C#
2021-08-20 11:32:27 +02:00
Ignacio Roldán Etcheverry 483071716e C#: Move marshaling logic and generated glue to C#
We will be progressively moving most code to C#.
The plan is to only use Mono's embedding APIs to set things at launch.
This will make it much easier to later support CoreCLR too which
doesn't have rich embedding APIs.

Additionally the code in C# is more maintainable and makes it easier
to implement new features, e.g.: runtime codegen which we could use to
avoid using reflection for marshaling everytime a field, property or
method is accessed.

SOME NOTES ON INTEROP

We make the same assumptions as GDNative about the size of the Godot
structures we use. We take it a bit further by also assuming the layout
of fields in some cases, which is riskier but let's us squeeze out some
performance by avoiding unnecessary managed to native calls.

Code that deals with native structs is less safe than before as there's
no RAII and copy constructors in C#. It's like using the GDNative C API
directly. One has to take special care to free values they own.
Perhaps we could use roslyn analyzers to check this, but I don't know
any that uses attributes to determine what's owned or borrowed.

As to why we maily use pointers for native structs instead of ref/out:
- AFAIK (and confirmed with a benchmark) ref/out are pinned
  during P/Invoke calls and that has a cost.
- Native struct fields can't be ref/out in the first place.
- A `using` local can't be passed as ref/out, only `in`. Calling a
  method or property on an `in` value makes a silent copy, so we want
  to avoid `in`.

REGARDING THE BUILD SYSTEM

There's no longer a `mono_glue=yes/no` SCons options. We no longer
need to build with `mono_glue=no`, generate the glue and then build
again with `mono_glue=yes`. We build only once and generate the glue
(which is in C# now).
However, SCons no longer builds the C# projects for us. Instead one
must run `build_assemblies.py`, e.g.:
```sh
%godot_src_root%/modules/mono/build_scripts/build_assemblies.py \
        --godot-output-dir=%godot_src_root%/bin \
        --godot-target=release_debug`
```
We could turn this into a custom build target, but I don't know how
to do that with SCons (it's possible with Meson).

OTHER NOTES

Most of the moved code doesn't follow the C# naming convention and
still has the word Mono in the names despite no longer dealing with
Mono's embedding APIs. This is just temporary while transitioning,
to make it easier to understand what was moved where.
2021-08-20 10:24:56 +02:00
Rémi Verschelde 4f640762f7
Merge pull request #51881 from KoBeWi/zz__iinnddeexx
Fix z_index applied twice for TileMap layers
2021-08-19 21:30:10 +02:00
Rémi Verschelde 5b30685976
Merge pull request #51583 from nekomatata/capsule-height-radius-setters
Fix capsule height/radius setters with linked properties
2021-08-19 20:48:54 +02:00
Rémi Verschelde fb8487e011
Merge pull request #51890 from fabriceci/crash-animation-blend-tree
Fix 51889 that cause a crash when you click on an AnimationTree that contains an invalid node
2021-08-19 20:46:33 +02:00
PouleyKetchoupp 645bc94bfc Fix capsule height/radius setters with linked properties
Capsule height and radius setters can modify each other, rather than
using clamping, to avoid cases where values are not set correctly when
loading a scene (depending on the order of properties).

Inspector undo/redo:
Added the possibility to link properties together in the editor, so
they can be undone together, for cases where a property can modify
another one.

Gizmo undo/redo:
Capsule handles pass both radius and height values so they can be undone
together.
2021-08-19 10:31:19 -07:00
Rémi Verschelde 93dac1c7db
Merge pull request #51804 from ThreeRhinosInAnElephantCostume/fixundoredo 2021-08-19 17:49:01 +02:00
JFonS 276d1e4844
Merge pull request #51335 from JFonS/fix-omni-shadow-bias
Improvements to SpotLight3D and OmniLight3D's shadows
2021-08-19 16:33:24 +02:00
Fabio Alessandrelli 4f53e8a9e8
Merge pull request #51885 from akien-mga/html5-GODOT_VERSION_STATUS
HTML5: Handle `GODOT_VERSION_STATUS` env var in `@GODOT_VERSION@`
2021-08-19 16:29:22 +02:00
fabriceci f871f13340 Avoid a crash when an node of the AnimationTree is invalid 2021-08-19 16:05:35 +02:00
ThreeRhinosInAnElephantCostume 0aa13ecd30 fixed popup_menu buttons getting triggered by lmb press instead of release. 2021-08-19 15:56:33 +02:00
Rémi Verschelde 30a5cdc093
Merge pull request #51876 from ThreeRhinosInAnElephantCostume/fixcameracurrent
Fixed Camera2d's "current" property getting reset when switching scenes
2021-08-19 15:41:46 +02:00
ThreeRhinosInAnElephantCostume 78e2d35a7e fixed camera2d's "current" property getting reset when switching scenes 2021-08-19 15:19:19 +02:00
Rémi Verschelde 16f49d4b29
HTML5: Handle GODOT_VERSION_STATUS env var in @GODOT_VERSION@
Follow-up to #51002.
2021-08-19 15:01:30 +02:00
jfons 55e7832d7b Improvements to SpotLight3D and OmniLight3D's shadows
OmniLight3D:
* Fixed lack of precision in cube map mode by scaling the projection's
  znear.
* Fixed aliasing issues by making the paraboloids use two square regions instead of two half
  squares.
* Fixed shadowmap atlas bleeding by adding padding.
* Fixed sihadow blur's inconsistent radius and unclamped sampling.

SpotLight3D:
* Fixed lack of precision by scaling the projection's znear.
* Fixed normal biasing.

Both:
* Tweaked biasing to make sure it works out of the box in most situations.
2021-08-19 13:46:51 +02:00
kobewi a7ace9fec1 Fix z_index applied twice for TileMap layers 2021-08-19 12:40:09 +02:00
Rémi Verschelde 8b6c168b3a
Merge pull request #48560 from SaracenOne/collada_semantic_fix_4_0 2021-08-19 09:02:16 +02:00
Rémi Verschelde 5ccf797c9c
Merge pull request #51703 from YeldhamDev/compal_tweaks
Minor tweaks/fixes for the Command Palette
2021-08-19 07:12:38 +02:00
Rémi Verschelde 31dfdcb69e
Merge pull request #51850 from RevoluPowered/ignore_cache_when_server_down
Fix github actions cache server being down failing builds
2021-08-18 23:06:42 +02:00
Gordon MacPherson 27da2e364e Fix github actions cache server being down failing builds 2021-08-18 21:58:54 +01:00
Rémi Verschelde c0bdea6a67
Merge pull request #51859 from nekomatata/bullet-body-motion-fixes
Fixes in Bullet body_test_motion
2021-08-18 22:46:10 +02:00
Rémi Verschelde 8376af3c31
Merge pull request #51854 from akien-mga/scons-progress-fix-open-error
SCons: Fix potential error when pruning cache on CI
2021-08-18 22:43:35 +02:00
Rémi Verschelde 825b245f0d
SCons: Fix potential error when pruning cache on CI
This could cause spurious errors on CI when trying to prune the cache,
as for some reason it tries to remove files/paths which do not exist.

That points at a bug in the `cache_progress` logic but at least this
workaround should prevent CI failures.
2021-08-18 22:19:51 +02:00
PouleyKetchoupp 45bc97b8b8 Fixes in Bullet body_test_motion
Synchronize fixes from the 3.x branch to keep Bullet code in sync for
later, even if it's disabled for now.
2021-08-18 13:18:19 -07:00
Rémi Verschelde 5aecce775e
Merge pull request #51848 from aaronfranke/float-doc
Improve the docs for the float type
2021-08-18 21:47:12 +02:00
Rémi Verschelde f6626a40e5
Merge pull request #51843 from reduz/fixes-to-mobile-renderer-3
More fixes to mobile renderer
2021-08-18 20:43:25 +02:00
Rémi Verschelde e1e01427cc
Merge pull request #50411 from Chaosus/vs_filter
Added port type content filter on port dragging in visual shader
2021-08-18 20:43:03 +02:00
Aaron Franke 70c0154cbe
Improve the docs for the float type 2021-08-18 13:27:22 -05:00
Rémi Verschelde de7b6d13eb
Merge pull request #51627 from mhilbrunner/todo-for-neikeq 2021-08-18 20:13:50 +02:00
Yuri Roubinsky f653cc13b9 Added port type content filter on port dragging in visual shader 2021-08-18 21:13:04 +03:00
Rémi Verschelde a619a92e3c
Merge pull request #51846 from m4gr3d/delegate_restart_invokation_master
Delegate handling and implementation of the restart functionality to the Godot host
2021-08-18 20:12:10 +02:00
Rémi Verschelde 1327c77848
Merge pull request #51845 from Paulb23/hide-textfiles 2021-08-18 20:09:13 +02:00
Rémi Verschelde 2fcf3057fd
Merge pull request #51792 from Chaosus/removed_restart 2021-08-18 19:59:57 +02:00
Fredia Huya-Kouadio f4222733ca Delegate handling and implementation of the restart functionality to the Godot host. 2021-08-18 10:24:42 -07:00
Paulb23 c13c738c88 Hide TextFile from the API 2021-08-18 17:56:23 +01:00
Paulb23 ac39022dbc Fix visual shader keyword colour 2021-08-18 17:56:04 +01:00
Michael Alexsander 9819be7562 Minor tweaks/fixes for the Command Palette 2021-08-18 13:12:14 -03:00
Rémi Verschelde 01675eb75a
Merge pull request #51837 from pycbouh/particles-adjust-material-bit-size 2021-08-18 17:28:04 +02:00
reduz 700f9d916d More fixes to mobile renderer
* Specify all precision qualifiers
* Makes renderer work on Adreno Vulkan
2021-08-18 12:20:19 -03:00
Yuri Sizov b88a41a161 Adjust the material key bit size for ParticlesMaterial 2021-08-18 17:53:46 +03:00
Fabio Alessandrelli 2a9c4a59df
Merge pull request #51534 from Faless/mp/4.x_replicator
[Net] MultiplayerReplicator with initial state.
2021-08-18 12:39:55 +02:00
Rémi Verschelde 919040f70d
Merge pull request #51832 from Faless/js/4.x_ci-2.0.27
[CI] Upgrade Emscripten to 2.0.27.
2021-08-18 12:31:08 +02:00
Fabio Alessandrelli 71fb2429a0 [CI] Upgrade Emscripten to 2.0.27.
Update Godot Javascript FS library to manually depend on ERRNO_CODES.
2021-08-18 10:30:50 +01:00