summaryrefslogtreecommitdiffstats
path: root/modules/mono
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/.editorconfig4
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln11
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj2
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj2
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj2
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertiesGeneratorTests.cs9
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/AbstractGenericNode(Of T)_ScriptProperties.generated.cs49
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/AbstractGenericNode.cs7
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs6
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj2
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs3
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs1
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs3
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs14
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs5
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/GodotTools.IdeMessaging.CLI.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj14
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.sln12
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj2
-rw-r--r--modules/mono/editor/bindings_generator.cpp21
-rw-r--r--modules/mono/editor/bindings_generator.h3
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj2
-rw-r--r--modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs1
-rw-r--r--modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj26
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp.sln15
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/CustomUnsafe.cs16
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs33
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs27
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs11
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs19
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs6
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs14
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs14
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs61
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs19
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs94
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs109
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs87
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs116
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs109
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs121
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj2
-rw-r--r--modules/mono/glue/runtime_interop.cpp29
50 files changed, 995 insertions, 124 deletions
diff --git a/modules/mono/.editorconfig b/modules/mono/.editorconfig
index 1e5ae28396..fcd10461ad 100644
--- a/modules/mono/.editorconfig
+++ b/modules/mono/.editorconfig
@@ -1,3 +1,7 @@
+[*.{sln,csproj}]
+end_of_line = crlf
+charset = utf-8-bom
+
[*.sln]
indent_style = tab
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln
index 9674626183..2c78645493 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk.sln
@@ -1,5 +1,8 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34728.123
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.NET.Sdk", "Godot.NET.Sdk\Godot.NET.Sdk.csproj", "{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators", "Godot.SourceGenerators\Godot.SourceGenerators.csproj", "{32D31B23-2A45-4099-B4F5-95B4C8FF7D9F}"
@@ -37,4 +40,10 @@ Global
{AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {49831022-16BD-41E0-A5F3-EDE1279F4176}
+ EndGlobalSection
EndGlobal
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj
index b396a5b0c7..74623a60ba 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.Build.NoTargets/2.0.1">
+<Project Sdk="Microsoft.Build.NoTargets/2.0.1">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj
index d0907c1cd4..fc887313d5 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj
index e5a81c0e1c..31a255dcdf 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertiesGeneratorTests.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertiesGeneratorTests.cs
index 3cc5841097..724fb164e0 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertiesGeneratorTests.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertiesGeneratorTests.cs
@@ -57,4 +57,13 @@ public class ScriptPropertiesGeneratorTests
"ScriptBoilerplate_ScriptProperties.generated.cs", "OuterClass.NestedClass_ScriptProperties.generated.cs"
);
}
+
+ [Fact]
+ public async void AbstractGenericNode()
+ {
+ await CSharpSourceGeneratorVerifier<ScriptPropertiesGenerator>.Verify(
+ "AbstractGenericNode.cs",
+ "AbstractGenericNode(Of T)_ScriptProperties.generated.cs"
+ );
+ }
}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/AbstractGenericNode(Of T)_ScriptProperties.generated.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/AbstractGenericNode(Of T)_ScriptProperties.generated.cs
new file mode 100644
index 0000000000..a561c5fc0d
--- /dev/null
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/AbstractGenericNode(Of T)_ScriptProperties.generated.cs
@@ -0,0 +1,49 @@
+using Godot;
+using Godot.NativeInterop;
+
+partial class AbstractGenericNode<T>
+{
+#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword
+ /// <summary>
+ /// Cached StringNames for the properties and fields contained in this class, for fast lookup.
+ /// </summary>
+ public new class PropertyName : global::Godot.Node.PropertyName {
+ /// <summary>
+ /// Cached name for the 'MyArray' property.
+ /// </summary>
+ public new static readonly global::Godot.StringName MyArray = "MyArray";
+ }
+ /// <inheritdoc/>
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override bool SetGodotClassPropertyValue(in godot_string_name name, in godot_variant value)
+ {
+ if (name == PropertyName.MyArray) {
+ this.MyArray = global::Godot.NativeInterop.VariantUtils.ConvertToArray<T>(value);
+ return true;
+ }
+ return base.SetGodotClassPropertyValue(name, value);
+ }
+ /// <inheritdoc/>
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ protected override bool GetGodotClassPropertyValue(in godot_string_name name, out godot_variant value)
+ {
+ if (name == PropertyName.MyArray) {
+ value = global::Godot.NativeInterop.VariantUtils.CreateFromArray(this.MyArray);
+ return true;
+ }
+ return base.GetGodotClassPropertyValue(name, out value);
+ }
+ /// <summary>
+ /// Get the property information for all the properties declared in this class.
+ /// This method is used by Godot to register the available properties in the editor.
+ /// Do not call this method.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ internal new static global::System.Collections.Generic.List<global::Godot.Bridge.PropertyInfo> GetGodotPropertyList()
+ {
+ var properties = new global::System.Collections.Generic.List<global::Godot.Bridge.PropertyInfo>();
+ properties.Add(new(type: (global::Godot.Variant.Type)28, name: PropertyName.MyArray, hint: (global::Godot.PropertyHint)0, hintString: "", usage: (global::Godot.PropertyUsageFlags)4102, exported: true));
+ return properties;
+ }
+#pragma warning restore CS0109
+}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/AbstractGenericNode.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/AbstractGenericNode.cs
new file mode 100644
index 0000000000..cee4f67921
--- /dev/null
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/AbstractGenericNode.cs
@@ -0,0 +1,7 @@
+using Godot;
+
+public abstract partial class AbstractGenericNode<[MustBeVariant] T> : Node
+{
+ [Export] // This should be included, but without type hints.
+ public Godot.Collections.Array<T> MyArray { get; set; } = new();
+}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs
index 462da31d66..2b5eecab8a 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs
@@ -66,6 +66,12 @@ public class MustBeVariantGD0301
Method<Rid[]>();
}
+ public void MethodCallDynamic()
+ {
+ dynamic self = this;
+ self.Method<object>();
+ }
+
public void Method<[MustBeVariant] T>()
{
}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj
index fbabed50d0..1aa2979e76 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs
index 834beaa131..4cf6a9f431 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotEnums.cs
@@ -44,7 +44,8 @@ namespace Godot.SourceGenerators
PackedVector2Array = 35,
PackedVector3Array = 36,
PackedColorArray = 37,
- Max = 38
+ PackedVector4Array = 38,
+ Max = 39
}
internal enum PropertyHint
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs
index be6af117eb..bfb735e72f 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalType.cs
@@ -51,6 +51,7 @@ namespace Godot.SourceGenerators
StringArray,
Vector2Array,
Vector3Array,
+ Vector4Array,
ColorArray,
GodotObjectOrDerivedArray,
SystemArrayOfStringName,
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs
index 0258f53062..d272832950 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs
@@ -66,6 +66,7 @@ namespace Godot.SourceGenerators
MarshalType.StringArray => VariantType.PackedStringArray,
MarshalType.Vector2Array => VariantType.PackedVector2Array,
MarshalType.Vector3Array => VariantType.PackedVector3Array,
+ MarshalType.Vector4Array => VariantType.PackedVector4Array,
MarshalType.ColorArray => VariantType.PackedColorArray,
MarshalType.GodotObjectOrDerivedArray => VariantType.Array,
MarshalType.SystemArrayOfStringName => VariantType.Array,
@@ -190,6 +191,8 @@ namespace Godot.SourceGenerators
return MarshalType.Vector2Array;
case { Name: "Vector3" }:
return MarshalType.Vector3Array;
+ case { Name: "Vector4" }:
+ return MarshalType.Vector4Array;
case { Name: "Color" }:
return MarshalType.ColorArray;
case { Name: "StringName" }:
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs
index 95eaca4d3d..e894e7a86c 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs
@@ -50,8 +50,18 @@ namespace Godot.SourceGenerators
var typeSymbol = sm.GetSymbolInfo(typeSyntax).Symbol as ITypeSymbol;
Helper.ThrowIfNull(typeSymbol);
- var parentSymbol = sm.GetSymbolInfo(parentSyntax).Symbol;
- Helper.ThrowIfNull(parentSymbol);
+ var parentSymbolInfo = sm.GetSymbolInfo(parentSyntax);
+ var parentSymbol = parentSymbolInfo.Symbol;
+ if (parentSymbol == null)
+ {
+ if (parentSymbolInfo.CandidateReason == CandidateReason.LateBound)
+ {
+ // Invocations on dynamic are late bound so we can't retrieve the symbol.
+ continue;
+ }
+
+ Helper.ThrowIfNull(parentSymbol);
+ }
if (!ShouldCheckTypeArgument(context, parentSyntax, parentSymbol, typeSyntax, typeSymbol, i))
{
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
index a0e410e31a..21223654f3 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
@@ -658,7 +658,10 @@ namespace Godot.SourceGenerators
var elementType = MarshalUtils.GetArrayElementType(type);
if (elementType == null)
- return false; // Non-generic Array, so there's no hint to add
+ return false; // Non-generic Array, so there's no hint to add.
+
+ if (elementType.TypeKind == TypeKind.TypeParameter)
+ return false; // The generic is not constructed, we can't really hint anything.
var elementMarshalType = MarshalUtils.ConvertManagedTypeToMarshalType(elementType, typeCache)!.Value;
var elementVariantType = MarshalUtils.ConvertMarshalTypeToVariantType(elementMarshalType)!.Value;
diff --git a/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj b/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj
index fd836f9ad2..f807132509 100644
--- a/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{6CE9A984-37B1-4F8A-8FE9-609F05F071B3}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
index 0755484465..f692f26a8b 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{639E48BD-44E5-4091-8EDD-22D36DC0768D}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/GodotTools.IdeMessaging.CLI.csproj b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/GodotTools.IdeMessaging.CLI.csproj
index 3bf678e9f9..0174b25b3f 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/GodotTools.IdeMessaging.CLI.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/GodotTools.IdeMessaging.CLI.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{B06C2951-C8E3-4F28-80B2-717CF327EB19}</ProjectGuid>
<OutputType>Exe</OutputType>
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj
index f681228892..2ee28715bf 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{92600954-25F0-4291-8E11-1FEE9FC4BE20}</ProjectGuid>
<TargetFramework>netstandard2.0</TargetFramework>
diff --git a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj
index 09908c85a1..7360118ee4 100644
--- a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{EAFFF236-FA96-4A4D-BD23-0E51EF988277}</ProjectGuid>
<OutputType>Exe</OutputType>
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj
index 623475e11a..5547ffcf19 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
diff --git a/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj b/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj
index d60e6343ea..7c19fabaf6 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj
@@ -1,8 +1,8 @@
-<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
- <!-- Specify compile items manually to avoid including dangling generated items. -->
- <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
- </PropertyGroup>
- <Import Project="GenerateGodotNupkgsVersions.targets" />
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TargetFramework>net6.0</TargetFramework>
+ <!-- Specify compile items manually to avoid including dangling generated items. -->
+ <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
+ </PropertyGroup>
+ <Import Project="GenerateGodotNupkgsVersions.targets" />
</Project>
diff --git a/modules/mono/editor/GodotTools/GodotTools.sln b/modules/mono/editor/GodotTools/GodotTools.sln
index 564775635d..1182e2467b 100644
--- a/modules/mono/editor/GodotTools/GodotTools.sln
+++ b/modules/mono/editor/GodotTools/GodotTools.sln
@@ -1,6 +1,8 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34728.123
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotTools.ProjectEditor", "GodotTools.ProjectEditor\GodotTools.ProjectEditor.csproj", "{A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotTools", "GodotTools\GodotTools.csproj", "{27B00618-A6F2-4828-B922-05CAEB08C286}"
@@ -62,4 +64,10 @@ Global
{55666071-BEC1-4A52-8A98-9A4A7A947DBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55666071-BEC1-4A52-8A98-9A4A7A947DBF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {521EC35A-F7F0-46A9-92CE-680D2F5B02B8}
+ EndGlobalSection
EndGlobal
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index 35b3f5a710..96d2c5c75f 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{27B00618-A6F2-4828-B922-05CAEB08C286}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index e1ce41edd5..d46160127d 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -330,6 +330,8 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter
output.append("'" BINDINGS_NAMESPACE ".Vector3[]'");
} else if (tag == "PackedColorArray") {
output.append("'" BINDINGS_NAMESPACE ".Color[]'");
+ } else if (tag == "PackedVector4Array") {
+ output.append("'" BINDINGS_NAMESPACE ".Vector4[]'");
} else {
const TypeInterface *target_itype = _get_type_or_null(TypeReference(tag));
@@ -646,6 +648,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append("<see cref=\"" BINDINGS_NAMESPACE ".Vector3\"/>[]");
} else if (tag == "PackedColorArray") {
xml_output.append("<see cref=\"" BINDINGS_NAMESPACE ".Color\"/>[]");
+ } else if (tag == "PackedVector4Array") {
+ xml_output.append("<see cref=\"" BINDINGS_NAMESPACE ".Vector4\"/>[]");
} else {
const TypeInterface *target_itype = _get_type_or_null(TypeReference(tag));
@@ -3516,6 +3520,7 @@ bool BindingsGenerator::_arg_default_value_is_assignable_to_type(const Variant &
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_VECTOR4_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
case Variant::CALLABLE:
case Variant::SIGNAL:
@@ -4246,6 +4251,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_VECTOR4_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
r_iarg.default_argument = "Array.Empty<%s>()";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
@@ -4585,6 +4591,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
INSERT_ARRAY(PackedColorArray, godot_packed_color_array, Color);
INSERT_ARRAY(PackedVector2Array, godot_packed_vector2_array, Vector2);
INSERT_ARRAY(PackedVector3Array, godot_packed_vector3_array, Vector3);
+ INSERT_ARRAY(PackedVector4Array, godot_packed_vector4_array, Vector4);
#undef INSERT_ARRAY
@@ -4852,7 +4859,7 @@ static void handle_cmdline_options(String glue_dir_path) {
}
static void cleanup_and_exit_godot() {
- // Exit once done
+ // Exit once done.
Main::cleanup(true);
::exit(0);
}
@@ -4871,7 +4878,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
elem = elem->next();
} else {
ERR_PRINT(generate_all_glue_option + ": No output directory specified (expected path to '{GODOT_ROOT}/modules/mono/glue').");
- // Exit once done with invalid command line arguments
+ // Exit once done with invalid command line arguments.
cleanup_and_exit_godot();
}
@@ -4882,8 +4889,14 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
}
if (glue_dir_path.length()) {
- handle_cmdline_options(glue_dir_path);
- // Exit once done
+ if (Engine::get_singleton()->is_editor_hint() ||
+ Engine::get_singleton()->is_project_manager_hint()) {
+ handle_cmdline_options(glue_dir_path);
+ } else {
+ // Running from a project folder, which doesn't make sense and crashes.
+ ERR_PRINT(generate_all_glue_option + ": Cannot generate Mono glue while running a game project. Change current directory or enable --editor.");
+ }
+ // Exit once done.
cleanup_and_exit_godot();
}
}
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index a397dcb026..556d287af4 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -705,7 +705,7 @@ class BindingsGenerator {
StringName type_Vector4i = StaticCString::create("Vector4i");
// Object not included as it must be checked for all derived classes
- static constexpr int nullable_types_count = 18;
+ static constexpr int nullable_types_count = 19;
StringName nullable_types[nullable_types_count] = {
type_String,
type_StringName,
@@ -727,6 +727,7 @@ class BindingsGenerator {
StaticCString::create(_STR(PackedVector2Array)),
StaticCString::create(_STR(PackedVector3Array)),
StaticCString::create(_STR(PackedColorArray)),
+ StaticCString::create(_STR(PackedVector4Array)),
};
bool is_nullable_type(const StringName &p_type) const {
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj
index 4d1a5bb76c..81add0e44f 100644
--- a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs
index f3f6759e1d..08e293afcc 100644
--- a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs
+++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs
@@ -468,6 +468,7 @@ using Godot.NativeInterop;
"Godot.NativeInterop.godot_packed_string_array",
"Godot.NativeInterop.godot_packed_vector2_array",
"Godot.NativeInterop.godot_packed_vector3_array",
+ "Godot.NativeInterop.godot_packed_vector4_array",
"Godot.NativeInterop.godot_packed_color_array",
};
}
diff --git a/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj b/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj
index e58d730ee3..1e60743fb1 100644
--- a/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj
+++ b/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj
@@ -1,18 +1,18 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
- <LangVersion>10</LangVersion>
- <Nullable>enable</Nullable>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <PropertyGroup>
+ <TargetFramework>net6.0</TargetFramework>
+ <LangVersion>10</LangVersion>
+ <Nullable>enable</Nullable>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <!-- To generate the .runtimeconfig.json file-->
- <EnableDynamicLoading>true</EnableDynamicLoading>
- <RollForward>LatestMajor</RollForward>
- </PropertyGroup>
+ <!-- To generate the .runtimeconfig.json file-->
+ <EnableDynamicLoading>true</EnableDynamicLoading>
+ <RollForward>LatestMajor</RollForward>
+ </PropertyGroup>
- <ItemGroup>
- <ProjectReference Include="..\GodotSharp\GodotSharp.csproj" />
- </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\GodotSharp\GodotSharp.csproj" />
+ </ItemGroup>
</Project>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp.sln b/modules/mono/glue/GodotSharp/GodotSharp.sln
index 8db42c2d1a..81ff7d7550 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp.sln
+++ b/modules/mono/glue/GodotSharp/GodotSharp.sln
@@ -1,5 +1,8 @@
+
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34728.123
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharp", "GodotSharp\GodotSharp.csproj", "{AEBF0036-DA76-4341-B651-A3F2856AB2FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharpEditor", "GodotSharpEditor\GodotSharpEditor.csproj", "{8FBEC238-D944-4074-8548-B3B524305905}"
@@ -10,8 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.SourceGenerators.Inte
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AEBF0036-DA76-4341-B651-A3F2856AB2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -31,4 +34,10 @@ Global
{7749662B-E30C-419A-B745-13852573360A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7749662B-E30C-419A-B745-13852573360A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {371B0F03-042D-45FD-A270-F3141F2480CD}
+ EndGlobalSection
EndGlobal
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs
index feaa1d07da..ab7f8ede44 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Aabb.cs
@@ -69,7 +69,7 @@ namespace Godot
public readonly Aabb Abs()
{
Vector3 end = End;
- Vector3 topLeft = new Vector3(Mathf.Min(_position.X, end.X), Mathf.Min(_position.Y, end.Y), Mathf.Min(_position.Z, end.Z));
+ Vector3 topLeft = end.Min(_position);
return new Aabb(topLeft, _size.Abs());
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/CustomUnsafe.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/CustomUnsafe.cs
index afef20a7f2..171cf86edb 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/CustomUnsafe.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/CustomUnsafe.cs
@@ -296,6 +296,22 @@ public static class CustomUnsafe
=> ref *ReadOnlyRefAsPointer(in source);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static unsafe godot_packed_vector4_array* AsPointer(ref godot_packed_vector4_array value)
+ => value.GetUnsafeAddress();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static unsafe godot_packed_vector4_array* ReadOnlyRefAsPointer(in godot_packed_vector4_array value)
+ => value.GetUnsafeAddress();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static unsafe ref godot_packed_vector4_array AsRef(godot_packed_vector4_array* source)
+ => ref *source;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static unsafe ref godot_packed_vector4_array AsRef(in godot_packed_vector4_array source)
+ => ref *ReadOnlyRefAsPointer(in source);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe godot_packed_color_array* AsPointer(ref godot_packed_color_array value)
=> value.GetUnsafeAddress();
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs
index a019dd3513..7e5c01d0f8 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs
@@ -1134,6 +1134,39 @@ namespace Godot.NativeInterop
}
[StructLayout(LayoutKind.Sequential)]
+ // ReSharper disable once InconsistentNaming
+ public ref struct godot_packed_vector4_array
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal readonly unsafe godot_packed_vector4_array* GetUnsafeAddress()
+ => (godot_packed_vector4_array*)Unsafe.AsPointer(ref Unsafe.AsRef(in _writeProxy));
+
+ private IntPtr _writeProxy;
+ private unsafe Vector4* _ptr;
+
+ public unsafe void Dispose()
+ {
+ if (_ptr == null)
+ return;
+ NativeFuncs.godotsharp_packed_vector4_array_destroy(ref this);
+ _ptr = null;
+ }
+
+ public readonly unsafe Vector4* Buffer
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ get => _ptr;
+ }
+
+ public readonly unsafe int Size
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ // ReSharper disable once InconsistentNaming
public ref struct godot_packed_color_array
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs
index 9f7fa53e24..15b7ce7c73 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs
@@ -133,6 +133,9 @@ namespace Godot.NativeInterop
if (type == typeof(Vector3[]))
return Variant.Type.PackedVector3Array;
+ if (type == typeof(Vector4[]))
+ return Variant.Type.PackedVector4Array;
+
if (type == typeof(Color[]))
return Variant.Type.PackedColorArray;
@@ -574,6 +577,30 @@ namespace Godot.NativeInterop
return NativeFuncs.godotsharp_packed_vector3_array_new_mem_copy(src, p_array.Length);
}
+ // PackedVector4Array
+
+ public static unsafe Vector4[] ConvertNativePackedVector4ArrayToSystemArray(godot_packed_vector4_array p_array)
+ {
+ Vector4* buffer = p_array.Buffer;
+ int size = p_array.Size;
+ if (size == 0)
+ return Array.Empty<Vector4>();
+ int sizeInBytes = size * sizeof(Vector4);
+ var array = new Vector4[size];
+ fixed (Vector4* dest = array)
+ Buffer.MemoryCopy(buffer, dest, sizeInBytes, sizeInBytes);
+ return array;
+ }
+
+ public static unsafe godot_packed_vector4_array ConvertSystemArrayToNativePackedVector4Array(
+ Span<Vector4> p_array)
+ {
+ if (p_array.IsEmpty)
+ return new godot_packed_vector4_array();
+ fixed (Vector4* src = p_array)
+ return NativeFuncs.godotsharp_packed_vector4_array_new_mem_copy(src, p_array.Length);
+ }
+
// PackedColorArray
public static unsafe Color[] ConvertNativePackedColorArrayToSystemArray(godot_packed_color_array p_array)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
index fef21fae46..c4fd639cce 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs
@@ -144,6 +144,9 @@ namespace Godot.NativeInterop
public static partial godot_packed_vector3_array godotsharp_packed_vector3_array_new_mem_copy(Vector3* p_src,
int p_length);
+ public static partial godot_packed_vector4_array godotsharp_packed_vector4_array_new_mem_copy(Vector4* p_src,
+ int p_length);
+
public static partial godot_packed_color_array godotsharp_packed_color_array_new_mem_copy(Color* p_src,
int p_length);
@@ -224,6 +227,9 @@ namespace Godot.NativeInterop
public static partial void godotsharp_variant_new_packed_vector3_array(out godot_variant r_dest,
in godot_packed_vector3_array p_pv3a);
+ public static partial void godotsharp_variant_new_packed_vector4_array(out godot_variant r_dest,
+ in godot_packed_vector4_array p_pv4a);
+
public static partial void godotsharp_variant_new_packed_color_array(out godot_variant r_dest,
in godot_packed_color_array p_pca);
@@ -302,6 +308,9 @@ namespace Godot.NativeInterop
public static partial godot_packed_vector3_array godotsharp_variant_as_packed_vector3_array(
in godot_variant p_self);
+ public static partial godot_packed_vector4_array godotsharp_variant_as_packed_vector4_array(
+ in godot_variant p_self);
+
public static partial godot_packed_color_array godotsharp_variant_as_packed_color_array(in godot_variant p_self);
public static partial godot_bool godotsharp_variant_equals(in godot_variant p_a, in godot_variant p_b);
@@ -352,6 +361,8 @@ namespace Godot.NativeInterop
public static partial void godotsharp_packed_vector3_array_destroy(ref godot_packed_vector3_array p_self);
+ public static partial void godotsharp_packed_vector4_array_destroy(ref godot_packed_vector4_array p_self);
+
public static partial void godotsharp_packed_color_array_destroy(ref godot_packed_color_array p_self);
public static partial void godotsharp_variant_destroy(ref godot_variant p_self);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
index 94609984ac..dc151e2c3e 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
@@ -165,6 +165,12 @@ namespace Godot.NativeInterop
return ret;
}
+ public static godot_variant CreateFromPackedVector4Array(in godot_packed_vector4_array from)
+ {
+ NativeFuncs.godotsharp_variant_new_packed_vector4_array(out godot_variant ret, from);
+ return ret;
+ }
+
public static godot_variant CreateFromPackedColorArray(in godot_packed_color_array from)
{
NativeFuncs.godotsharp_variant_new_packed_color_array(out godot_variant ret, from);
@@ -228,6 +234,13 @@ namespace Godot.NativeInterop
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static godot_variant CreateFromPackedVector4Array(Span<Vector4> from)
+ {
+ using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedVector4Array(from);
+ return CreateFromPackedVector4Array(nativePackedArray);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static godot_variant CreateFromPackedColorArray(Span<Color> from)
{
using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedColorArray(from);
@@ -605,6 +618,12 @@ namespace Godot.NativeInterop
return Marshaling.ConvertNativePackedVector3ArrayToSystemArray(packedArray);
}
+ public static Vector4[] ConvertAsPackedVector4ArrayToSystemArray(in godot_variant p_var)
+ {
+ using var packedArray = NativeFuncs.godotsharp_variant_as_packed_vector4_array(p_var);
+ return Marshaling.ConvertNativePackedVector4ArrayToSystemArray(packedArray);
+ }
+
public static Color[] ConvertAsPackedColorArrayToSystemArray(in godot_variant p_var)
{
using var packedArray = NativeFuncs.godotsharp_variant_as_packed_color_array(p_var);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs
index d8f7214c2f..2897cc4199 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs
@@ -155,6 +155,9 @@ public partial class VariantUtils
if (typeof(T) == typeof(Vector3[]))
return CreateFromPackedVector3Array(UnsafeAs<Vector3[]>(from));
+ if (typeof(T) == typeof(Vector4[]))
+ return CreateFromPackedVector4Array(UnsafeAs<Vector4[]>(from));
+
if (typeof(T) == typeof(Color[]))
return CreateFromPackedColorArray(UnsafeAs<Color[]>(from));
@@ -343,6 +346,9 @@ public partial class VariantUtils
if (typeof(T) == typeof(Vector3[]))
return UnsafeAsT(ConvertAsPackedVector3ArrayToSystemArray(variant));
+ if (typeof(T) == typeof(Vector4[]))
+ return UnsafeAsT(ConvertAsPackedVector4ArrayToSystemArray(variant));
+
if (typeof(T) == typeof(Color[]))
return UnsafeAsT(ConvertAsPackedColorArrayToSystemArray(variant));
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
index 9d9065911e..19721b6cca 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
@@ -69,7 +69,7 @@ namespace Godot
public readonly Rect2 Abs()
{
Vector2 end = End;
- Vector2 topLeft = new Vector2(Mathf.Min(_position.X, end.X), Mathf.Min(_position.Y, end.Y));
+ Vector2 topLeft = end.Min(_position);
return new Rect2(topLeft, _size.Abs());
}
@@ -91,14 +91,12 @@ namespace Godot
return new Rect2();
}
- newRect._position.X = Mathf.Max(b._position.X, _position.X);
- newRect._position.Y = Mathf.Max(b._position.Y, _position.Y);
+ newRect._position = b._position.Max(_position);
Vector2 bEnd = b._position + b._size;
Vector2 end = _position + _size;
- newRect._size.X = Mathf.Min(bEnd.X, end.X) - newRect._position.X;
- newRect._size.Y = Mathf.Min(bEnd.Y, end.Y) - newRect._position.Y;
+ newRect._size = bEnd.Min(end) - newRect._position;
return newRect;
}
@@ -338,11 +336,9 @@ namespace Godot
{
Rect2 newRect;
- newRect._position.X = Mathf.Min(b._position.X, _position.X);
- newRect._position.Y = Mathf.Min(b._position.Y, _position.Y);
+ newRect._position = b._position.Min(_position);
- newRect._size.X = Mathf.Max(b._position.X + b._size.X, _position.X + _size.X);
- newRect._size.Y = Mathf.Max(b._position.Y + b._size.Y, _position.Y + _size.Y);
+ newRect._size = (b._position + b._size).Max(_position + _size);
newRect._size -= newRect._position; // Make relative again
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs
index 65704b3da7..7ee9ff8552 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2I.cs
@@ -69,7 +69,7 @@ namespace Godot
public readonly Rect2I Abs()
{
Vector2I end = End;
- Vector2I topLeft = new Vector2I(Mathf.Min(_position.X, end.X), Mathf.Min(_position.Y, end.Y));
+ Vector2I topLeft = end.Min(_position);
return new Rect2I(topLeft, _size.Abs());
}
@@ -91,14 +91,12 @@ namespace Godot
return new Rect2I();
}
- newRect._position.X = Mathf.Max(b._position.X, _position.X);
- newRect._position.Y = Mathf.Max(b._position.Y, _position.Y);
+ newRect._position = b._position.Max(_position);
Vector2I bEnd = b._position + b._size;
Vector2I end = _position + _size;
- newRect._size.X = Mathf.Min(bEnd.X, end.X) - newRect._position.X;
- newRect._size.Y = Mathf.Min(bEnd.Y, end.Y) - newRect._position.Y;
+ newRect._size = bEnd.Min(end) - newRect._position;
return newRect;
}
@@ -295,11 +293,9 @@ namespace Godot
{
Rect2I newRect;
- newRect._position.X = Mathf.Min(b._position.X, _position.X);
- newRect._position.Y = Mathf.Min(b._position.Y, _position.Y);
+ newRect._position = b._position.Min(_position);
- newRect._size.X = Mathf.Max(b._position.X + b._size.X, _position.X + _size.X);
- newRect._size.Y = Mathf.Max(b._position.Y + b._size.Y, _position.Y + _size.Y);
+ newRect._size = (b._position + b._size).Max(_position + _size);
newRect._size -= newRect._position; // Make relative again
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
index 37f319b697..d8a3e91699 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
@@ -417,76 +417,31 @@ namespace Godot
}
/// <summary>
- /// Performs a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
+ /// Performs a case-sensitive comparison to another string and returns an integer that indicates their relative position in the sort order.
/// </summary>
/// <seealso cref="NocasecmpTo(string, string)"/>
/// <seealso cref="CompareTo(string, string, bool)"/>
/// <param name="instance">The string to compare.</param>
/// <param name="to">The other string to compare.</param>
- /// <returns>-1 if less, 0 if equal and +1 if greater.</returns>
+ /// <returns>An integer that indicates the lexical relationship between the two comparands.</returns>
public static int CasecmpTo(this string instance, string to)
{
return instance.CompareTo(to, caseSensitive: true);
}
/// <summary>
- /// Performs a comparison to another string, return -1 if less, 0 if equal and +1 if greater.
+ /// Performs a comparison to another string and returns an integer that indicates their relative position in the sort order.
/// </summary>
/// <param name="instance">The string to compare.</param>
/// <param name="to">The other string to compare.</param>
/// <param name="caseSensitive">
/// If <see langword="true"/>, the comparison will be case sensitive.
/// </param>
- /// <returns>-1 if less, 0 if equal and +1 if greater.</returns>
+ /// <returns>An integer that indicates the lexical relationship between the two comparands.</returns>
+ [Obsolete("Use string.Compare instead.")]
public static int CompareTo(this string instance, string to, bool caseSensitive = true)
{
- if (string.IsNullOrEmpty(instance))
- return string.IsNullOrEmpty(to) ? 0 : -1;
-
- if (string.IsNullOrEmpty(to))
- return 1;
-
- int instanceIndex = 0;
- int toIndex = 0;
-
- if (caseSensitive) // Outside while loop to avoid checking multiple times, despite some code duplication.
- {
- while (true)
- {
- if (to[toIndex] == 0 && instance[instanceIndex] == 0)
- return 0; // We're equal
- if (instance[instanceIndex] == 0)
- return -1; // If this is empty, and the other one is not, then we're less... I think?
- if (to[toIndex] == 0)
- return 1; // Otherwise the other one is smaller...
- if (instance[instanceIndex] < to[toIndex]) // More than
- return -1;
- if (instance[instanceIndex] > to[toIndex]) // Less than
- return 1;
-
- instanceIndex++;
- toIndex++;
- }
- }
- else
- {
- while (true)
- {
- if (to[toIndex] == 0 && instance[instanceIndex] == 0)
- return 0; // We're equal
- if (instance[instanceIndex] == 0)
- return -1; // If this is empty, and the other one is not, then we're less... I think?
- if (to[toIndex] == 0)
- return 1; // Otherwise the other one is smaller..
- if (char.ToUpperInvariant(instance[instanceIndex]) < char.ToUpperInvariant(to[toIndex])) // More than
- return -1;
- if (char.ToUpperInvariant(instance[instanceIndex]) > char.ToUpperInvariant(to[toIndex])) // Less than
- return 1;
-
- instanceIndex++;
- toIndex++;
- }
- }
+ return string.Compare(instance, to, !caseSensitive);
}
/// <summary>
@@ -1297,13 +1252,13 @@ namespace Godot
}
/// <summary>
- /// Perform a case-insensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
+ /// Performs a case-insensitive comparison to another string and returns an integer that indicates their relative position in the sort order.
/// </summary>
/// <seealso cref="CasecmpTo(string, string)"/>
/// <seealso cref="CompareTo(string, string, bool)"/>
/// <param name="instance">The string to compare.</param>
/// <param name="to">The other string to compare.</param>
- /// <returns>-1 if less, 0 if equal and +1 if greater.</returns>
+ /// <returns>An integer that indicates the lexical relationship between the two comparands.</returns>
public static int NocasecmpTo(this string instance, string to)
{
return instance.CompareTo(to, caseSensitive: false);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
index c2d3050adc..b40f524859 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
@@ -149,6 +149,7 @@ public partial struct Variant : IDisposable
Type.PackedStringArray => AsStringArray(),
Type.PackedVector2Array => AsVector2Array(),
Type.PackedVector3Array => AsVector3Array(),
+ Type.PackedVector4Array => AsVector4Array(),
Type.PackedColorArray => AsColorArray(),
Type.Nil => null,
Type.Max or _ =>
@@ -320,6 +321,10 @@ public partial struct Variant : IDisposable
VariantUtils.ConvertAsPackedVector3ArrayToSystemArray((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Vector4[] AsVector4Array() =>
+ VariantUtils.ConvertAsPackedVector4ArrayToSystemArray((godot_variant)NativeVar);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Color[] AsColorArray() =>
VariantUtils.ConvertAsPackedColorArrayToSystemArray((godot_variant)NativeVar);
@@ -492,6 +497,9 @@ public partial struct Variant : IDisposable
public static explicit operator Vector3[](Variant from) => from.AsVector3Array();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static explicit operator Vector4[](Variant from) => from.AsVector4Array();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static explicit operator Color[](Variant from) => from.AsColorArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -642,6 +650,9 @@ public partial struct Variant : IDisposable
public static Variant CreateFrom(Span<Vector3> from) => from;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Variant CreateFrom(Span<Vector4> from) => from;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Variant CreateFrom(Span<Color> from) => from;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -841,6 +852,10 @@ public partial struct Variant : IDisposable
(Variant)from.AsSpan();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(Vector4[] from) =>
+ (Variant)from.AsSpan();
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Variant(Color[] from) =>
(Variant)from.AsSpan();
@@ -893,6 +908,10 @@ public partial struct Variant : IDisposable
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromPackedVector3Array(from));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static implicit operator Variant(Span<Vector4> from) =>
+ CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromPackedVector4Array(from));
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Variant(Span<Color> from) =>
CreateTakingOwnershipOfDisposableValue(VariantUtils.CreateFromPackedColorArray(from));
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index 856fd54352..50bf56d832 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -192,6 +192,23 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with all components clamped between the
+ /// <paramref name="min"/> and <paramref name="max"/> using
+ /// <see cref="Mathf.Clamp(real_t, real_t, real_t)"/>.
+ /// </summary>
+ /// <param name="min">The minimum allowed value.</param>
+ /// <param name="max">The maximum allowed value.</param>
+ /// <returns>The vector with all components clamped.</returns>
+ public readonly Vector2 Clamp(real_t min, real_t max)
+ {
+ return new Vector2
+ (
+ Mathf.Clamp(X, min, max),
+ Mathf.Clamp(Y, min, max)
+ );
+ }
+
+ /// <summary>
/// Returns the cross product of this vector and <paramref name="with"/>.
/// </summary>
/// <param name="with">The other vector.</param>
@@ -413,6 +430,70 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2 Max(Vector2 with)
+ {
+ return new Vector2
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Max(X, with), Mathf.Max(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2 Max(real_t with)
+ {
+ return new Vector2
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2 Min(Vector2 with)
+ {
+ return new Vector2
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2(Mathf.Min(X, with), Mathf.Min(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2 Min(real_t with)
+ {
+ return new Vector2
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If both components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
@@ -600,7 +681,7 @@ namespace Godot
}
/// <summary>
- /// Returns this vector with each component snapped to the nearest multiple of <paramref name="step"/>.
+ /// Returns a new vector with each component snapped to the nearest multiple of the corresponding component in <paramref name="step"/>.
/// This can also be used to round to an arbitrary number of decimals.
/// </summary>
/// <param name="step">A vector value representing the step size to snap to.</param>
@@ -611,6 +692,17 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with each component snapped to the nearest multiple of <paramref name="step"/>.
+ /// This can also be used to round to an arbitrary number of decimals.
+ /// </summary>
+ /// <param name="step">The step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector2 Snapped(real_t step)
+ {
+ return new Vector2(Mathf.Snapped(X, step), Mathf.Snapped(Y, step));
+ }
+
+ /// <summary>
/// Returns a perpendicular vector rotated 90 degrees counter-clockwise
/// compared to the original, with the same length.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
index 511cc7971c..9442db4d86 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs
@@ -125,6 +125,23 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with all components clamped between the
+ /// <paramref name="min"/> and <paramref name="max"/> using
+ /// <see cref="Mathf.Clamp(int, int, int)"/>.
+ /// </summary>
+ /// <param name="min">The minimum allowed value.</param>
+ /// <param name="max">The maximum allowed value.</param>
+ /// <returns>The vector with all components clamped.</returns>
+ public readonly Vector2I Clamp(int min, int max)
+ {
+ return new Vector2I
+ (
+ Mathf.Clamp(X, min, max),
+ Mathf.Clamp(Y, min, max)
+ );
+ }
+
+ /// <summary>
/// Returns the squared distance between this vector and <paramref name="to"/>.
/// This method runs faster than <see cref="DistanceTo"/>, so prefer it if
/// you need to compare vectors or need the squared distance for some formula.
@@ -175,6 +192,70 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2I Max(Vector2I with)
+ {
+ return new Vector2I
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Max(X, with), Mathf.Max(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector2I Max(int with)
+ {
+ return new Vector2I
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2I Min(Vector2I with)
+ {
+ return new Vector2I
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector2I(Mathf.Min(X, with), Mathf.Min(Y, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector2I Min(int with)
+ {
+ return new Vector2I
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If both components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
@@ -208,6 +289,34 @@ namespace Godot
return v;
}
+ /// <summary>
+ /// Returns a new vector with each component snapped to the closest multiple of the corresponding component in <paramref name="step"/>.
+ /// </summary>
+ /// <param name="step">A vector value representing the step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector2I Snapped(Vector2I step)
+ {
+ return new Vector2I
+ (
+ (int)Mathf.Snapped((double)X, (double)step.X),
+ (int)Mathf.Snapped((double)Y, (double)step.Y)
+ );
+ }
+
+ /// <summary>
+ /// Returns a new vector with each component snapped to the closest multiple of <paramref name="step"/>.
+ /// </summary>
+ /// <param name="step">The step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector2I Snapped(int step)
+ {
+ return new Vector2I
+ (
+ (int)Mathf.Snapped((double)X, (double)step),
+ (int)Mathf.Snapped((double)Y, (double)step)
+ );
+ }
+
// Constants
private static readonly Vector2I _minValue = new Vector2I(int.MinValue, int.MinValue);
private static readonly Vector2I _maxValue = new Vector2I(int.MaxValue, int.MaxValue);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index 6300705107..27f2713efa 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -179,6 +179,24 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with all components clamped between the
+ /// <paramref name="min"/> and <paramref name="max"/> using
+ /// <see cref="Mathf.Clamp(real_t, real_t, real_t)"/>.
+ /// </summary>
+ /// <param name="min">The minimum allowed value.</param>
+ /// <param name="max">The maximum allowed value.</param>
+ /// <returns>The vector with all components clamped.</returns>
+ public readonly Vector3 Clamp(real_t min, real_t max)
+ {
+ return new Vector3
+ (
+ Mathf.Clamp(X, min, max),
+ Mathf.Clamp(Y, min, max),
+ Mathf.Clamp(Z, min, max)
+ );
+ }
+
+ /// <summary>
/// Returns the cross product of this vector and <paramref name="with"/>.
/// </summary>
/// <param name="with">The other vector.</param>
@@ -419,6 +437,57 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3 Max(Vector3 with)
+ {
+ return new Vector3
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3 Max(real_t with)
+ {
+ return new Vector3
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector3 Min(Vector3 with)
+ {
+ return new Vector3
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
@@ -643,7 +712,7 @@ namespace Godot
}
/// <summary>
- /// Returns this vector with each component snapped to the nearest multiple of <paramref name="step"/>.
+ /// Returns a new vector with each component snapped to the nearest multiple of the corresponding component in <paramref name="step"/>.
/// This can also be used to round to an arbitrary number of decimals.
/// </summary>
/// <param name="step">A vector value representing the step size to snap to.</param>
@@ -658,6 +727,22 @@ namespace Godot
);
}
+ /// <summary>
+ /// Returns a new vector with each component snapped to the nearest multiple of <paramref name="step"/>.
+ /// This can also be used to round to an arbitrary number of decimals.
+ /// </summary>
+ /// <param name="step">The step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector3 Snapped(real_t step)
+ {
+ return new Vector3
+ (
+ Mathf.Snapped(X, step),
+ Mathf.Snapped(Y, step),
+ Mathf.Snapped(Z, step)
+ );
+ }
+
// Constants
private static readonly Vector3 _zero = new Vector3(0, 0, 0);
private static readonly Vector3 _one = new Vector3(1, 1, 1);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
index aea46efc5b..8312e2c231 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs
@@ -133,6 +133,24 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with all components clamped between the
+ /// <paramref name="min"/> and <paramref name="max"/> using
+ /// <see cref="Mathf.Clamp(int, int, int)"/>.
+ /// </summary>
+ /// <param name="min">The minimum allowed value.</param>
+ /// <param name="max">The maximum allowed value.</param>
+ /// <returns>The vector with all components clamped.</returns>
+ public readonly Vector3I Clamp(int min, int max)
+ {
+ return new Vector3I
+ (
+ Mathf.Clamp(X, min, max),
+ Mathf.Clamp(Y, min, max),
+ Mathf.Clamp(Z, min, max)
+ );
+ }
+
+ /// <summary>
/// Returns the squared distance between this vector and <paramref name="to"/>.
/// This method runs faster than <see cref="DistanceTo"/>, so prefer it if
/// you need to compare vectors or need the squared distance for some formula.
@@ -185,6 +203,74 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3I Max(Vector3I with)
+ {
+ return new Vector3I
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector3I Max(int with)
+ {
+ return new Vector3I
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector3I Min(Vector3I with)
+ {
+ return new Vector3I
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector3I(Mathf.Min(X, with), Mathf.Min(Y, with), Mathf.Min(Z, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector3I Min(int with)
+ {
+ return new Vector3I
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with),
+ Mathf.Min(Z, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
@@ -219,6 +305,36 @@ namespace Godot
return v;
}
+ /// <summary>
+ /// Returns a new vector with each component snapped to the closest multiple of the corresponding component in <paramref name="step"/>.
+ /// </summary>
+ /// <param name="step">A vector value representing the step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector3I Snapped(Vector3I step)
+ {
+ return new Vector3I
+ (
+ (int)Mathf.Snapped((double)X, (double)step.X),
+ (int)Mathf.Snapped((double)Y, (double)step.Y),
+ (int)Mathf.Snapped((double)Z, (double)step.Z)
+ );
+ }
+
+ /// <summary>
+ /// Returns a new vector with each component snapped to the closest multiple of <paramref name="step"/>.
+ /// </summary>
+ /// <param name="step">The step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector3I Snapped(int step)
+ {
+ return new Vector3I
+ (
+ (int)Mathf.Snapped((double)X, (double)step),
+ (int)Mathf.Snapped((double)Y, (double)step),
+ (int)Mathf.Snapped((double)Z, (double)step)
+ );
+ }
+
// Constants
private static readonly Vector3I _minValue = new Vector3I(int.MinValue, int.MinValue, int.MinValue);
private static readonly Vector3I _maxValue = new Vector3I(int.MaxValue, int.MaxValue, int.MaxValue);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs
index 7c4832943c..ec59197fa3 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4.cs
@@ -177,6 +177,25 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with all components clamped between the
+ /// <paramref name="min"/> and <paramref name="max"/> using
+ /// <see cref="Mathf.Clamp(real_t, real_t, real_t)"/>.
+ /// </summary>
+ /// <param name="min">The minimum allowed value.</param>
+ /// <param name="max">The maximum allowed value.</param>
+ /// <returns>The vector with all components clamped.</returns>
+ public readonly Vector4 Clamp(real_t min, real_t max)
+ {
+ return new Vector4
+ (
+ Mathf.Clamp(X, min, max),
+ Mathf.Clamp(Y, min, max),
+ Mathf.Clamp(Z, min, max),
+ Mathf.Clamp(W, min, max)
+ );
+ }
+
+ /// <summary>
/// Performs a cubic interpolation between vectors <paramref name="preA"/>, this vector,
/// <paramref name="b"/>, and <paramref name="postB"/>, by the given amount <paramref name="weight"/>.
/// </summary>
@@ -352,6 +371,78 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z), Mathf.Max(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4 Max(Vector4 with)
+ {
+ return new Vector4
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z),
+ Mathf.Max(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with), Mathf.Max(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4 Max(real_t with)
+ {
+ return new Vector4
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with),
+ Mathf.Max(W, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z), Mathf.Min(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4 Min(Vector4 with)
+ {
+ return new Vector4
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z),
+ Mathf.Min(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4(Mathf.Min(X, with), Mathf.Min(Y, with), Mathf.Min(Z, with), Mathf.Min(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4 Min(real_t with)
+ {
+ return new Vector4
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with),
+ Mathf.Min(Z, with),
+ Mathf.Min(W, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
@@ -465,7 +556,7 @@ namespace Godot
}
/// <summary>
- /// Returns this vector with each component snapped to the nearest multiple of <paramref name="step"/>.
+ /// Returns a new vector with each component snapped to the nearest multiple of the corresponding component in <paramref name="step"/>.
/// This can also be used to round to an arbitrary number of decimals.
/// </summary>
/// <param name="step">A vector value representing the step size to snap to.</param>
@@ -480,6 +571,22 @@ namespace Godot
);
}
+ /// <summary>
+ /// Returns a new vector with each component snapped to the nearest multiple of <paramref name="step"/>.
+ /// This can also be used to round to an arbitrary number of decimals.
+ /// </summary>
+ /// <param name="step">The step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector4 Snapped(real_t step)
+ {
+ return new Vector4(
+ Mathf.Snapped(X, step),
+ Mathf.Snapped(Y, step),
+ Mathf.Snapped(Z, step),
+ Mathf.Snapped(W, step)
+ );
+ }
+
// Constants
private static readonly Vector4 _zero = new Vector4(0, 0, 0, 0);
private static readonly Vector4 _one = new Vector4(1, 1, 1, 1);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
index 27aa86b7e4..ba8e54b88b 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs
@@ -150,6 +150,25 @@ namespace Godot
}
/// <summary>
+ /// Returns a new vector with all components clamped between
+ /// <paramref name="min"/> and <paramref name="max"/> using
+ /// <see cref="Mathf.Clamp(int, int, int)"/>.
+ /// </summary>
+ /// <param name="min">The minimum allowed value.</param>
+ /// <param name="max">The maximum allowed value.</param>
+ /// <returns>The vector with all components clamped.</returns>
+ public readonly Vector4I Clamp(int min, int max)
+ {
+ return new Vector4I
+ (
+ Mathf.Clamp(X, min, max),
+ Mathf.Clamp(Y, min, max),
+ Mathf.Clamp(Z, min, max),
+ Mathf.Clamp(W, min, max)
+ );
+ }
+
+ /// <summary>
/// Returns the squared distance between this vector and <paramref name="to"/>.
/// This method runs faster than <see cref="DistanceTo"/>, so prefer it if
/// you need to compare vectors or need the squared distance for some formula.
@@ -204,6 +223,78 @@ namespace Godot
}
/// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Max(X, with.X), Mathf.Max(Y, with.Y), Mathf.Max(Z, with.Z), Mathf.Max(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4I Max(Vector4I with)
+ {
+ return new Vector4I
+ (
+ Mathf.Max(X, with.X),
+ Mathf.Max(Y, with.Y),
+ Mathf.Max(Z, with.Z),
+ Mathf.Max(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise maximum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Max(X, with), Mathf.Max(Y, with), Mathf.Max(Z, with), Mathf.Max(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting maximum vector.</returns>
+ public readonly Vector4I Max(int with)
+ {
+ return new Vector4I
+ (
+ Mathf.Max(X, with),
+ Mathf.Max(Y, with),
+ Mathf.Max(Z, with),
+ Mathf.Max(W, with)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Min(X, with.X), Mathf.Min(Y, with.Y), Mathf.Min(Z, with.Z), Mathf.Min(W, with.W))</c>.
+ /// </summary>
+ /// <param name="with">The other vector to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4I Min(Vector4I with)
+ {
+ return new Vector4I
+ (
+ Mathf.Min(X, with.X),
+ Mathf.Min(Y, with.Y),
+ Mathf.Min(Z, with.Z),
+ Mathf.Min(W, with.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns the result of the component-wise minimum between
+ /// this vector and <paramref name="with"/>.
+ /// Equivalent to <c>new Vector4I(Mathf.Min(X, with), Mathf.Min(Y, with), Mathf.Min(Z, with), Mathf.Min(W, with))</c>.
+ /// </summary>
+ /// <param name="with">The other value to use.</param>
+ /// <returns>The resulting minimum vector.</returns>
+ public readonly Vector4I Min(int with)
+ {
+ return new Vector4I
+ (
+ Mathf.Min(X, with),
+ Mathf.Min(Y, with),
+ Mathf.Min(Z, with),
+ Mathf.Min(W, with)
+ );
+ }
+
+ /// <summary>
/// Returns the axis of the vector's highest value. See <see cref="Axis"/>.
/// If all components are equal, this method returns <see cref="Axis.X"/>.
/// </summary>
@@ -254,6 +345,36 @@ namespace Godot
return new Vector4I(Mathf.Sign(X), Mathf.Sign(Y), Mathf.Sign(Z), Mathf.Sign(W));
}
+ /// <summary>
+ /// Returns a new vector with each component snapped to the closest multiple of the corresponding component in <paramref name="step"/>.
+ /// </summary>
+ /// <param name="step">A vector value representing the step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector4I Snapped(Vector4I step)
+ {
+ return new Vector4I(
+ (int)Mathf.Snapped((double)X, (double)step.X),
+ (int)Mathf.Snapped((double)Y, (double)step.Y),
+ (int)Mathf.Snapped((double)Z, (double)step.Z),
+ (int)Mathf.Snapped((double)W, (double)step.W)
+ );
+ }
+
+ /// <summary>
+ /// Returns a new vector with each component snapped to the closest multiple of <paramref name="step"/>.
+ /// </summary>
+ /// <param name="step">The step size to snap to.</param>
+ /// <returns>The snapped vector.</returns>
+ public readonly Vector4I Snapped(int step)
+ {
+ return new Vector4I(
+ (int)Mathf.Snapped((double)X, (double)step),
+ (int)Mathf.Snapped((double)Y, (double)step),
+ (int)Mathf.Snapped((double)Z, (double)step),
+ (int)Mathf.Snapped((double)W, (double)step)
+ );
+ }
+
// Constants
private static readonly Vector4I _minValue = new Vector4I(int.MinValue, int.MinValue, int.MinValue, int.MinValue);
private static readonly Vector4I _maxValue = new Vector4I(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
index 67282416ed..6b25087c93 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
+++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{AEBF0036-DA76-4341-B651-A3F2856AB2FA}</ProjectGuid>
<OutputPath>bin/$(Configuration)</OutputPath>
diff --git a/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj b/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj
index 8373edb9bf..4561fdaf2b 100644
--- a/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj
+++ b/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{8FBEC238-D944-4074-8548-B3B524305905}</ProjectGuid>
<OutputPath>bin/$(Configuration)</OutputPath>
diff --git a/modules/mono/glue/runtime_interop.cpp b/modules/mono/glue/runtime_interop.cpp
index 4bb324c0ee..1af462dafd 100644
--- a/modules/mono/glue/runtime_interop.cpp
+++ b/modules/mono/glue/runtime_interop.cpp
@@ -461,6 +461,16 @@ godot_packed_array godotsharp_packed_vector3_array_new_mem_copy(const Vector3 *p
return ret;
}
+godot_packed_array godotsharp_packed_vector4_array_new_mem_copy(const Vector4 *p_src, int32_t p_length) {
+ godot_packed_array ret;
+ memnew_placement(&ret, PackedVector4Array);
+ PackedVector4Array *array = reinterpret_cast<PackedVector4Array *>(&ret);
+ array->resize(p_length);
+ Vector4 *dst = array->ptrw();
+ memcpy(dst, p_src, p_length * sizeof(Vector4));
+ return ret;
+}
+
godot_packed_array godotsharp_packed_color_array_new_mem_copy(const Color *p_src, int32_t p_length) {
godot_packed_array ret;
memnew_placement(&ret, PackedColorArray);
@@ -646,6 +656,10 @@ void godotsharp_variant_new_packed_vector3_array(godot_variant *r_dest, const Pa
memnew_placement(r_dest, Variant(*p_pv3a));
}
+void godotsharp_variant_new_packed_vector4_array(godot_variant *r_dest, const PackedVector4Array *p_pv4a) {
+ memnew_placement(r_dest, Variant(*p_pv4a));
+}
+
void godotsharp_variant_new_packed_color_array(godot_variant *r_dest, const PackedColorArray *p_pca) {
memnew_placement(r_dest, Variant(*p_pca));
}
@@ -886,6 +900,13 @@ godot_packed_array godotsharp_variant_as_packed_vector3_array(const Variant *p_s
return raw_dest;
}
+godot_packed_array godotsharp_variant_as_packed_vector4_array(const Variant *p_self) {
+ godot_packed_array raw_dest;
+ PackedVector4Array *dest = (PackedVector4Array *)&raw_dest;
+ memnew_placement(dest, PackedVector4Array(p_self->operator PackedVector4Array()));
+ return raw_dest;
+}
+
godot_packed_array godotsharp_variant_as_packed_color_array(const Variant *p_self) {
godot_packed_array raw_dest;
PackedColorArray *dest = (PackedColorArray *)&raw_dest;
@@ -974,6 +995,10 @@ void godotsharp_packed_vector3_array_destroy(PackedVector3Array *p_self) {
p_self->~PackedVector3Array();
}
+void godotsharp_packed_vector4_array_destroy(PackedVector4Array *p_self) {
+ p_self->~PackedVector4Array();
+}
+
void godotsharp_packed_color_array_destroy(PackedColorArray *p_self) {
p_self->~PackedColorArray();
}
@@ -1456,6 +1481,7 @@ static const void *unmanaged_callbacks[]{
(void *)godotsharp_packed_float64_array_new_mem_copy,
(void *)godotsharp_packed_vector2_array_new_mem_copy,
(void *)godotsharp_packed_vector3_array_new_mem_copy,
+ (void *)godotsharp_packed_vector4_array_new_mem_copy,
(void *)godotsharp_packed_color_array_new_mem_copy,
(void *)godotsharp_packed_string_array_add,
(void *)godotsharp_callable_new_with_delegate,
@@ -1484,6 +1510,7 @@ static const void *unmanaged_callbacks[]{
(void *)godotsharp_variant_new_packed_string_array,
(void *)godotsharp_variant_new_packed_vector2_array,
(void *)godotsharp_variant_new_packed_vector3_array,
+ (void *)godotsharp_variant_new_packed_vector4_array,
(void *)godotsharp_variant_new_packed_color_array,
(void *)godotsharp_variant_as_bool,
(void *)godotsharp_variant_as_int,
@@ -1520,6 +1547,7 @@ static const void *unmanaged_callbacks[]{
(void *)godotsharp_variant_as_packed_string_array,
(void *)godotsharp_variant_as_packed_vector2_array,
(void *)godotsharp_variant_as_packed_vector3_array,
+ (void *)godotsharp_variant_as_packed_vector4_array,
(void *)godotsharp_variant_as_packed_color_array,
(void *)godotsharp_variant_equals,
(void *)godotsharp_string_new_with_utf16_chars,
@@ -1538,6 +1566,7 @@ static const void *unmanaged_callbacks[]{
(void *)godotsharp_packed_string_array_destroy,
(void *)godotsharp_packed_vector2_array_destroy,
(void *)godotsharp_packed_vector3_array_destroy,
+ (void *)godotsharp_packed_vector4_array_destroy,
(void *)godotsharp_packed_color_array_destroy,
(void *)godotsharp_variant_destroy,
(void *)godotsharp_string_destroy,