Commit graph

1667 commits

Author SHA1 Message Date
Silc Renew
b217c41d36 Refactor interpolating functions in some classes to use Math class 2022-11-24 20:31:43 +09:00
Rémi Verschelde
124594593f
Merge pull request #68580 from rhofour/fix-source-generation
First attempt at fully qualifying the default values of C# properties.
2022-11-23 17:19:26 +01:00
R. Alex Hofer
6ab93bd919 Fully qualify C# default values in exported fields.
This avoids issues when the default values rely on using
namespaces.
2022-11-22 18:10:34 -05:00
Rémi Verschelde
52c51563fd
Merge pull request #68866 from raulsntos/dotnet/godot-enums
C#: Synchronize Godot enums with core
2022-11-19 09:40:05 +01:00
Raul Santos
792e618749
C#: Synchronize Godot enums with core 2022-11-19 01:54:23 +01:00
Rémi Verschelde
c3132b42cb
Merge pull request #66816 from raulsntos/dotnet/readonly
Add `readonly` to C# methods and types that don't mutate
2022-11-18 16:20:29 +01:00
Raul Santos
ac8ea5c821
C#: Remove "?" from CEscape and CUnescape 2022-11-15 01:40:12 +01:00
Raul Santos
71df6d66ae
Add readonly to C# methods and types that don't mutate
Also removes a few unnecessary temp variables
2022-11-14 20:32:20 +01:00
Ignacio Roldán Etcheverry
ec521a405a
Merge pull request #68253 from dzil123/fix_array_shuffle
Fix c# Array.Shuffle incorrect mono bindings
2022-11-04 23:54:53 +01:00
dzil123
2fd2a16d92 Fix c# Array.Shuffle incorrect mono bindings 2022-11-04 06:25:31 -07:00
Ignacio Roldán Etcheverry
c0de8d32d5
Merge pull request #68092 from raulsntos/dotnet/variant-from-array
C#: Add implicit conversion from arrays to Variant
2022-11-03 14:46:26 +01:00
Aaron Franke
9e952c8386
Allow getting Quaternion rotation in different Euler orders 2022-11-02 19:20:10 -05:00
Raul Santos
99260d972f
C#: Add implicit conversion from arrays to Variant
Adds an implicit conversion from supported array types (the ones that
are equivalent to `Packed*Array` types in Godot) to Variant.
2022-11-02 21:46:32 +01:00
Aaron Franke
8556fdd4bc
Move EulerOrder enum to math_defs.h and global scope 2022-11-02 13:44:13 -05:00
Rémi Verschelde
d2e1b4b9f0
Merge pull request #68118 from aaronfranke/quat-from-euler
Replace Quaternion Euler constructor with `from_euler` method
2022-11-02 18:51:59 +01:00
Yuri Rubinsky
9487a6ea32 Add missed Quaternion constructor to C# 2022-11-02 11:41:32 +03:00
Aaron Franke
83634119d4
Replace Quaternion Euler constructor with from_euler method 2022-11-01 09:28:12 -05:00
Rémi Verschelde
5947f22be9
Merge pull request #67578 from KoBeWi/GEDITOR
Unify usage of GLOBAL/EDITOR_GET
2022-10-31 13:15:58 +01:00
Ignacio Roldán Etcheverry
f66a352c0f C#: Add Variant conversion callbacks for generic Godot collections
This allows using generic Godot collections as type arguments for other
generic Godot collections. This also allows generic Godot collections
as parameter or return type in dynamic Callable invocations.
2022-10-30 01:24:15 +02:00
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
Raul Santos
687633e5bd
Use .generated suffix for generated C# code
Use the `.generated` suffix instead of `_Generated` so .NET marks C#
file generated by Godot source generators as generated code.
2022-10-22 23:13:52 +02:00
kobewi
e48c5daddf Unify usage of GLOBAL/EDITOR_GET 2022-10-18 19:01:48 +02:00
Ignacio Roldán Etcheverry
9afc8337bd
Merge pull request #67440 from raulsntos/dotnet/bindings-conflicts
Guard against more potential conflicts in C# bindings generator
2022-10-17 00:28:07 +02:00
Yuri Rubinsky
04f7207009 Add a Plane(Vector3, Vector3) constructor for C# 2022-10-16 14:10:58 +03:00
Raul Santos
333f88dc49
Guard against more potential conflicts in C# bindings generator 2022-10-15 12:47:10 +02:00
Rémi Verschelde
b9e924c806 Merge pull request #67216 from dotlogix/Bugfix/FixErrorWhenSerializingSignals
Fix crash when serializing empty delegates in C#
2022-10-13 09:05:22 +02:00
Alexander Schill
5f47873f10 Adding null check to prevent null reference exception when serializing delegates in C# 2022-10-13 00:19:46 +02:00
Rémi Verschelde
f2248969db
Merge pull request #66952 from bruvzg/macos_net_export
Fix macOS .NET export.
2022-10-12 22:52:59 +02:00
Micky
fe56c1ff75 Use JSON::stringify where possible 2022-10-11 00:27:23 +02:00
Raul Santos
fbea89d4f1
C#: Generate symbols packages 2022-10-08 13:59:06 +02:00
bruvzg
6daf4c6593
[.NET Export] Improve .NET export process.
[macOS export] Fix incorrect file placement, search paths and architecture detection.
[macOS export] Automatically detect executable files and set +x flag.
[macOS export] Automatically apply "Disable Library Validation" entitlements when required.
[macOS export] Remove old Mono export code.
Fix folder tree creation for shared objects export.
Add arch suffix to the exported .NET "data" folder name.
Remove old Mono code from .NET "data" folder lookup.
2022-10-07 13:33:06 +03:00
Rémi Verschelde
340f62d1ec .NET: Generate SdkPackageVersions.props from version.py
Ensures that the versions always match the Godot version, albeit following
SemVer 2.0 so inserting a dot between "beta" and the build number.

For "stable" status, we omit the suffix as this would be interpreted as a
pre-release build too.

So we have:

| Godot version  | Nupkg version  |
| -------------- | -------------- |
| 4.0.0-beta     | 4.0.0-beta     |
| 4.0.0-beta2    | 4.0.0-beta.2   |
| 4.0.0-rc1      | 4.0.0-rc.1     |
| 4.0.0-stable   | 4.0.0          |
2022-10-05 20:31:26 +02:00
Rémi Verschelde
52f5a58c38 Merge pull request #66873 from akien-mga/script-tweak-error-invalid-script-type
GDScript/C#: Tweak error message for invalid script type for object
2022-10-05 08:38:52 +02:00
Aaron Franke
2cea42cc7f
Rename Projection matrix to columns 2022-10-04 12:34:19 -05:00
Rémi Verschelde
5bf95518fd GDScript/C#: Tweak error message for invalid script type for object
See #66870.
2022-10-04 12:56:49 +02:00
Rémi Verschelde
cd7f172cf8 Merge pull request #66804 from akien-mga/core-remove-NO_SAFE_CAST
Remove unsupported `NO_SAFE_CAST`/`-fno-rtti` from Android build
2022-10-04 10:22:24 +02:00
Raul Santos
67d058da30
C#: Use Span in Color to avoid string allocations 2022-10-03 12:11:37 +02:00
Rémi Verschelde
82b87d7a17 Remove unsupported NO_SAFE_CAST/-fno-rtti from Android build
Android was the last platform to still attempt to disable RTTI (for binary
size), but both the Android editor and now the ICU library used by templates
need RTTI.

There could still be the possibility to support this for non-ICU template
builds (i.e. without the TextServerAdvanced module), but since this isn't one
of the build configurations we test regularly it's pretty risky to keep this
option only for that specific use case. And our code is already littered with
`dynamic_cast`s which weren't guarded with `!defined(NO_SAFE_CAST)`.
2022-10-03 11:18:31 +02:00
Rémi Verschelde
9c2894180d Merge pull request #66387 from aaronfranke/cs-basis-euler
C#: Update Basis Euler angle code to match core
2022-10-03 09:26:16 +02:00
Patrick Dawson
161f295f52 ManagedCallable: use delegate target instead of middleman when possible
If the delegate target is an Object, the connected signal will be registered in that object instead of the middleman. So when that object is destroyed, the signal will be properly disconnected.
2022-10-01 02:09:58 +02:00
Rémi Verschelde
ef8834a642 Merge pull request #64784 from yedpodtrzitko/yed/ci-add-mypy
ci: add Python static analysis check via mypy
2022-09-30 17:44:39 +02:00
Rémi Verschelde
166df0896c Fix typos with codespell
Using codespell 2.3-dev from current git.

And fix typo in `methods.py` for `vsproj=yes` option (still won't work
though).
2022-09-30 14:23:36 +02:00
Jiri Suchan
c5bd2f9dce ci: add Python static analysis check via mypy 2022-09-30 19:03:17 +07:00
Rémi Verschelde
39facb35a0 SCons: Unify tools/target build type configuration
Implements https://github.com/godotengine/godot-proposals/issues/3371.

New `target` presets
====================

The `tools` option is removed and `target` changes to use three new presets,
which match the builds users are familiar with. These targets control the
default optimization level and enable editor-specific and debugging code:

- `editor`: Replaces `tools=yes target=release_debug`.
  * Defines: `TOOLS_ENABLED`, `DEBUG_ENABLED`, `-O2`/`/O2`
- `template_debug`: Replaces `tools=no target=release_debug`.
  * Defines: `DEBUG_ENABLED`, `-O2`/`/O2`
- `template_release`: Replaces `tools=no target=release`.
  * Defines: `-O3`/`/O2`

New `dev_build` option
======================

The previous `target=debug` is now replaced by a separate `dev_build=yes`
option, which can be used in combination with either of the three targets,
and changes the following:

- `dev_build`: Defines `DEV_ENABLED`, disables optimization (`-O0`/`/0d`),
  enables generating debug symbols, does not define `NDEBUG` so `assert()`
  works in thirdparty libraries, adds a `.dev` suffix to the binary name.

Note: Unlike previously, `dev_build` defaults to off so that users who
compile Godot from source get an optimized and small build by default.
Engine contributors should now set `dev_build=yes` in their build scripts or
IDE configuration manually.

Changed binary names
====================

The name of generated binaries and object files are changed too, to follow
this format:

`godot.<platform>.<target>[.dev][.double].<arch>[.<extra_suffix>][.<ext>]`

For example:
- `godot.linuxbsd.editor.dev.arm64`
- `godot.windows.template_release.double.x86_64.mono.exe`

Be sure to update your links/scripts/IDE config accordingly.

More flexible `optimize` and `debug_symbols` options
====================================================

The optimization level and whether to generate debug symbols can be further
specified with the `optimize` and `debug_symbols` options. So the default
values listed above for the various `target` and `dev_build` combinations
are indicative and can be replaced when compiling, e.g.:

`scons p=linuxbsd target=template_debug dev_build=yes optimize=debug`
will make a "debug" export template with dev-only code enabled, `-Og`
optimization level for GCC/Clang, and debug symbols. Perfect for debugging
complex crashes at runtime in an exported project.
2022-09-26 16:31:46 +02:00
Rémi Verschelde
49fcf4ffad Style: Cleanup header guards for consistency
Fix file names for {Static,Lightmap}RaycasterEmbree.
2022-09-26 13:51:17 +02:00
Aaron Franke
fe7135344b
C#: Update Basis Euler angle code to match core 2022-09-25 22:28:52 -05:00
Ignacio Roldán Etcheverry
62792eeb9f
Merge pull request #66253 from raulsntos/dotnet/assembly-may-be-null
C#: Guard against null assemblies
2022-09-22 18:24:31 +02:00
Raul Santos
24ac82e235
C#: Suppress EventHandler suffix diagnostic for signals
Suppress CA1711 for signal delegates because they are used in events so
the naming follows the guidelines.
2022-09-22 14:23:01 +02:00
Raul Santos
f6d60764d3
C#: Guard against null assemblies
A symbol's containing assembly will be null if the symbol is shared
across multiple assemblies.
2022-09-22 12:41:38 +02:00
Rémi Verschelde
d96b7d767a Merge pull request #66110 from Zylann/reference_get_count
get_reference_count()`
2022-09-22 08:26:29 +02:00