summaryrefslogtreecommitdiff
path: root/modules/mono/glue/Managed
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/glue/Managed')
-rw-r--r--modules/mono/glue/Managed/Files/AABB.cs4
-rw-r--r--modules/mono/glue/Managed/Files/Basis.cs45
-rw-r--r--modules/mono/glue/Managed/Files/Color.cs4
-rw-r--r--modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs24
-rw-r--r--modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs4
-rw-r--r--modules/mono/glue/Managed/Files/GD.cs20
-rw-r--r--modules/mono/glue/Managed/Files/Mathf.cs4
-rw-r--r--modules/mono/glue/Managed/Files/MathfEx.cs2
-rw-r--r--modules/mono/glue/Managed/Files/Plane.cs6
-rw-r--r--modules/mono/glue/Managed/Files/Quat.cs2
-rw-r--r--modules/mono/glue/Managed/Files/Rect2.cs4
-rw-r--r--modules/mono/glue/Managed/Files/StringExtensions.cs8
-rw-r--r--modules/mono/glue/Managed/Files/Transform.cs8
-rw-r--r--modules/mono/glue/Managed/Files/Transform2D.cs6
-rw-r--r--modules/mono/glue/Managed/Files/Vector2.cs4
-rw-r--r--modules/mono/glue/Managed/Files/Vector3.cs12
-rw-r--r--modules/mono/glue/Managed/Properties/AssemblyInfo.cs4
17 files changed, 94 insertions, 67 deletions
diff --git a/modules/mono/glue/Managed/Files/AABB.cs b/modules/mono/glue/Managed/Files/AABB.cs
index 66490b5e25..33b2b46712 100644
--- a/modules/mono/glue/Managed/Files/AABB.cs
+++ b/modules/mono/glue/Managed/Files/AABB.cs
@@ -407,8 +407,8 @@ namespace Godot
return new AABB(min, max - min);
}
-
- // Constructors
+
+ // Constructors
public AABB(Vector3 position, Vector3 size)
{
_position = position;
diff --git a/modules/mono/glue/Managed/Files/Basis.cs b/modules/mono/glue/Managed/Files/Basis.cs
index a5618cb28d..b318d96bb9 100644
--- a/modules/mono/glue/Managed/Files/Basis.cs
+++ b/modules/mono/glue/Managed/Files/Basis.cs
@@ -13,9 +13,9 @@ namespace Godot
{
private static readonly Basis identity = new Basis
(
- new Vector3(1f, 0f, 0f),
- new Vector3(0f, 1f, 0f),
- new Vector3(0f, 0f, 1f)
+ 1f, 0f, 0f,
+ 0f, 1f, 0f,
+ 0f, 0f, 1f
);
private static readonly Basis[] orthoBases = {
@@ -159,9 +159,9 @@ namespace Godot
{
return new Basis
(
- new Vector3(xAxis.x, yAxis.x, zAxis.x),
- new Vector3(xAxis.y, yAxis.y, zAxis.y),
- new Vector3(xAxis.z, yAxis.z, zAxis.z)
+ xAxis.x, yAxis.x, zAxis.x,
+ xAxis.y, yAxis.y, zAxis.y,
+ xAxis.z, yAxis.z, zAxis.z
);
}
@@ -410,10 +410,12 @@ namespace Godot
);
}
- public Quat Quat() {
+ public Quat Quat()
+ {
real_t trace = _x[0] + _y[1] + _z[2];
- if (trace > 0.0f) {
+ if (trace > 0.0f)
+ {
real_t s = Mathf.Sqrt(trace + 1.0f) * 2f;
real_t inv_s = 1f / s;
return new Quat(
@@ -424,7 +426,8 @@ namespace Godot
);
}
- if (_x[0] > _y[1] && _x[0] > _z[2]) {
+ if (_x[0] > _y[1] && _x[0] > _z[2])
+ {
real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f;
real_t inv_s = 1f / s;
return new Quat(
@@ -435,7 +438,8 @@ namespace Godot
);
}
- if (_y[1] > _z[2]) {
+ if (_y[1] > _z[2])
+ {
real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f;
real_t inv_s = 1f / s;
return new Quat(
@@ -444,7 +448,9 @@ namespace Godot
(_y[2] + _z[1]) * inv_s,
(_x[2] - _z[0]) * inv_s
);
- } else {
+ }
+ else
+ {
real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f;
real_t inv_s = 1f / s;
return new Quat(
@@ -502,8 +508,8 @@ namespace Godot
{
var axis_sq = new Vector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z);
- real_t cosine = Mathf.Cos( phi);
- real_t sine = Mathf.Sin( phi);
+ real_t cosine = Mathf.Cos(phi);
+ real_t sine = Mathf.Sin(phi);
_x = new Vector3
(
@@ -529,12 +535,17 @@ namespace Godot
public Basis(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis)
{
- _x = xAxis;
- _y = yAxis;
- _z = zAxis;
+ _x = new Vector3(xAxis.x, yAxis.x, zAxis.x);
+ _y = new Vector3(xAxis.y, yAxis.y, zAxis.y);
+ _z = new Vector3(xAxis.z, yAxis.z, zAxis.z);
+ // Same as:
+ // SetAxis(0, xAxis);
+ // SetAxis(1, yAxis);
+ // SetAxis(2, zAxis);
+ // We need to assign the struct fields so we can't do that...
}
- public Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz)
+ internal Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz)
{
_x = new Vector3(xx, xy, xz);
_y = new Vector3(yx, yy, yz);
diff --git a/modules/mono/glue/Managed/Files/Color.cs b/modules/mono/glue/Managed/Files/Color.cs
index 88cb8524b8..fc5bb010a9 100644
--- a/modules/mono/glue/Managed/Files/Color.cs
+++ b/modules/mono/glue/Managed/Files/Color.cs
@@ -379,8 +379,8 @@ namespace Godot
return txt;
}
-
- // Constructors
+
+ // Constructors
public Color(float r, float g, float b, float a = 1.0f)
{
this.r = r;
diff --git a/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
index 71534d7782..366d89b1c2 100644
--- a/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
+++ b/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
@@ -2,42 +2,42 @@ namespace Godot
{
public partial class Node
{
- public T GetNode<T>(NodePath path) where T : Godot.Node
+ public T GetNode<T>(NodePath path) where T : class
{
- return (T)GetNode(path);
+ return (T)(object)GetNode(path);
}
- public T GetNodeOrNull<T>(NodePath path) where T : Godot.Node
+ public T GetNodeOrNull<T>(NodePath path) where T : class
{
return GetNode(path) as T;
}
- public T GetChild<T>(int idx) where T : Godot.Node
+ public T GetChild<T>(int idx) where T : class
{
- return (T)GetChild(idx);
+ return (T)(object)GetChild(idx);
}
- public T GetChildOrNull<T>(int idx) where T : Godot.Node
+ public T GetChildOrNull<T>(int idx) where T : class
{
return GetChild(idx) as T;
}
- public T GetOwner<T>() where T : Godot.Node
+ public T GetOwner<T>() where T : class
{
- return (T)GetOwner();
+ return (T)(object)GetOwner();
}
- public T GetOwnerOrNull<T>() where T : Godot.Node
+ public T GetOwnerOrNull<T>() where T : class
{
return GetOwner() as T;
}
- public T GetParent<T>() where T : Godot.Node
+ public T GetParent<T>() where T : class
{
- return (T)GetParent();
+ return (T)(object)GetParent();
}
- public T GetParentOrNull<T>() where T : Godot.Node
+ public T GetParentOrNull<T>() where T : class
{
return GetParent() as T;
}
diff --git a/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs
index ceecc589e6..684d160b57 100644
--- a/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs
+++ b/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs
@@ -2,9 +2,9 @@ namespace Godot
{
public static partial class ResourceLoader
{
- public static T Load<T>(string path) where T : Godot.Resource
+ public static T Load<T>(string path) where T : class
{
- return (T) Load(path);
+ return (T)(object)Load(path);
}
}
}
diff --git a/modules/mono/glue/Managed/Files/GD.cs b/modules/mono/glue/Managed/Files/GD.cs
index 264be23588..75a35a9eea 100644
--- a/modules/mono/glue/Managed/Files/GD.cs
+++ b/modules/mono/glue/Managed/Files/GD.cs
@@ -65,9 +65,19 @@ namespace Godot
return ResourceLoader.Load(path);
}
- public static T Load<T>(string path) where T : Godot.Resource
+ public static T Load<T>(string path) where T : class
{
- return (T) ResourceLoader.Load(path);
+ return ResourceLoader.Load<T>(path);
+ }
+
+ public static void PushError(string message)
+ {
+ godot_icall_GD_pusherror(message);
+ }
+
+ public static void PushWarning(string message)
+ {
+ godot_icall_GD_pushwarning(message);
}
public static void Print(params object[] what)
@@ -238,5 +248,11 @@ namespace Godot
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static string godot_icall_GD_var2str(object var);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static void godot_icall_GD_pusherror(string type);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static void godot_icall_GD_pushwarning(string type);
}
}
diff --git a/modules/mono/glue/Managed/Files/Mathf.cs b/modules/mono/glue/Managed/Files/Mathf.cs
index a89dfe5f27..dcab3c1ffc 100644
--- a/modules/mono/glue/Managed/Files/Mathf.cs
+++ b/modules/mono/glue/Managed/Files/Mathf.cs
@@ -206,7 +206,7 @@ namespace Godot
public static real_t PosMod(real_t a, real_t b)
{
real_t c = a % b;
- if ((c < 0 && b > 0) || (c > 0 && b < 0))
+ if ((c < 0 && b > 0) || (c > 0 && b < 0))
{
c += b;
}
@@ -219,7 +219,7 @@ namespace Godot
public static int PosMod(int a, int b)
{
int c = a % b;
- if ((c < 0 && b > 0) || (c > 0 && b < 0))
+ if ((c < 0 && b > 0) || (c > 0 && b < 0))
{
c += b;
}
diff --git a/modules/mono/glue/Managed/Files/MathfEx.cs b/modules/mono/glue/Managed/Files/MathfEx.cs
index 739b7fb568..2ef02cc288 100644
--- a/modules/mono/glue/Managed/Files/MathfEx.cs
+++ b/modules/mono/glue/Managed/Files/MathfEx.cs
@@ -29,7 +29,7 @@ namespace Godot
public static int FloorToInt(real_t s)
{
return (int)Math.Floor(s);
- }
+ }
public static int RoundToInt(real_t s)
{
diff --git a/modules/mono/glue/Managed/Files/Plane.cs b/modules/mono/glue/Managed/Files/Plane.cs
index 9611dce11e..f11cd490a9 100644
--- a/modules/mono/glue/Managed/Files/Plane.cs
+++ b/modules/mono/glue/Managed/Files/Plane.cs
@@ -144,7 +144,7 @@ namespace Godot
{
return point - _normal * DistanceTo(point);
}
-
+
// Constants
private static readonly Plane _planeYZ = new Plane(1, 0, 0, 0);
private static readonly Plane _planeXZ = new Plane(0, 1, 0, 0);
@@ -153,8 +153,8 @@ namespace Godot
public static Plane PlaneYZ { get { return _planeYZ; } }
public static Plane PlaneXZ { get { return _planeXZ; } }
public static Plane PlaneXY { get { return _planeXY; } }
-
- // Constructors
+
+ // Constructors
public Plane(real_t a, real_t b, real_t c, real_t d)
{
_normal = new Vector3(a, b, c);
diff --git a/modules/mono/glue/Managed/Files/Quat.cs b/modules/mono/glue/Managed/Files/Quat.cs
index eaa027eb69..fd1ac01083 100644
--- a/modules/mono/glue/Managed/Files/Quat.cs
+++ b/modules/mono/glue/Managed/Files/Quat.cs
@@ -202,7 +202,7 @@ namespace Godot
// Static Readonly Properties
public static Quat Identity { get; } = new Quat(0f, 0f, 0f, 1f);
- // Constructors
+ // Constructors
public Quat(real_t x, real_t y, real_t z, real_t w)
{
this.x = x;
diff --git a/modules/mono/glue/Managed/Files/Rect2.cs b/modules/mono/glue/Managed/Files/Rect2.cs
index cb25c267bc..888f300347 100644
--- a/modules/mono/glue/Managed/Files/Rect2.cs
+++ b/modules/mono/glue/Managed/Files/Rect2.cs
@@ -182,8 +182,8 @@ namespace Godot
return newRect;
}
-
- // Constructors
+
+ // Constructors
public Rect2(Vector2 position, Vector2 size)
{
_position = position;
diff --git a/modules/mono/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs
index 21c9be98c1..c194facd0b 100644
--- a/modules/mono/glue/Managed/Files/StringExtensions.cs
+++ b/modules/mono/glue/Managed/Files/StringExtensions.cs
@@ -185,7 +185,7 @@ namespace Godot
int instanceIndex = 0;
int toIndex = 0;
-
+
if (caseSensitive) // Outside while loop to avoid checking multiple times, despite some code duplication.
{
while (true)
@@ -480,9 +480,9 @@ namespace Godot
return false; // Don't start with number plz
}
- bool validChar = instance[i] >= '0' &&
- instance[i] <= '9' || instance[i] >= 'a' &&
- instance[i] <= 'z' || instance[i] >= 'A' &&
+ bool validChar = instance[i] >= '0' &&
+ instance[i] <= '9' || instance[i] >= 'a' &&
+ instance[i] <= 'z' || instance[i] >= 'A' &&
instance[i] <= 'Z' || instance[i] == '_';
if (!validChar)
diff --git a/modules/mono/glue/Managed/Files/Transform.cs b/modules/mono/glue/Managed/Files/Transform.cs
index 068007d7f0..fa85855edd 100644
--- a/modules/mono/glue/Managed/Files/Transform.cs
+++ b/modules/mono/glue/Managed/Files/Transform.cs
@@ -124,16 +124,16 @@ namespace Godot
// Constants
private static readonly Transform _identity = new Transform(Basis.Identity, Vector3.Zero);
- private static readonly Transform _flipX = new Transform(new Basis(new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)), Vector3.Zero);
- private static readonly Transform _flipY = new Transform(new Basis(new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1)), Vector3.Zero);
- private static readonly Transform _flipZ = new Transform(new Basis(new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, -1)), Vector3.Zero);
+ private static readonly Transform _flipX = new Transform(new Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1), Vector3.Zero);
+ private static readonly Transform _flipY = new Transform(new Basis(1, 0, 0, 0, -1, 0, 0, 0, 1), Vector3.Zero);
+ private static readonly Transform _flipZ = new Transform(new Basis(1, 0, 0, 0, 1, 0, 0, 0, -1), Vector3.Zero);
public static Transform Identity { get { return _identity; } }
public static Transform FlipX { get { return _flipX; } }
public static Transform FlipY { get { return _flipY; } }
public static Transform FlipZ { get { return _flipZ; } }
- // Constructors
+ // Constructors
public Transform(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 origin)
{
basis = Basis.CreateFromAxes(xAxis, yAxis, zAxis);
diff --git a/modules/mono/glue/Managed/Files/Transform2D.cs b/modules/mono/glue/Managed/Files/Transform2D.cs
index 8d30833066..c9e5b560b2 100644
--- a/modules/mono/glue/Managed/Files/Transform2D.cs
+++ b/modules/mono/glue/Managed/Files/Transform2D.cs
@@ -261,15 +261,15 @@ namespace Godot
public static Transform2D Identity { get { return _identity; } }
public static Transform2D FlipX { get { return _flipX; } }
public static Transform2D FlipY { get { return _flipY; } }
-
- // Constructors
+
+ // Constructors
public Transform2D(Vector2 xAxis, Vector2 yAxis, Vector2 origin)
{
x = xAxis;
y = yAxis;
o = origin;
}
-
+
public Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy)
{
x = new Vector2(xx, xy);
diff --git a/modules/mono/glue/Managed/Files/Vector2.cs b/modules/mono/glue/Managed/Files/Vector2.cs
index 080b8802ba..ce41886bfc 100644
--- a/modules/mono/glue/Managed/Files/Vector2.cs
+++ b/modules/mono/glue/Managed/Files/Vector2.cs
@@ -215,7 +215,7 @@ namespace Godot
x = v.x;
y = v.y;
}
-
+
public Vector2 Slerp(Vector2 b, real_t t)
{
real_t theta = AngleTo(b);
@@ -242,7 +242,7 @@ namespace Godot
private static readonly Vector2 _one = new Vector2(1, 1);
private static readonly Vector2 _negOne = new Vector2(-1, -1);
private static readonly Vector2 _inf = new Vector2(Mathf.Inf, Mathf.Inf);
-
+
private static readonly Vector2 _up = new Vector2(0, -1);
private static readonly Vector2 _down = new Vector2(0, 1);
private static readonly Vector2 _right = new Vector2(1, 0);
diff --git a/modules/mono/glue/Managed/Files/Vector3.cs b/modules/mono/glue/Managed/Files/Vector3.cs
index 6fffe5e4d6..f6ff27989d 100644
--- a/modules/mono/glue/Managed/Files/Vector3.cs
+++ b/modules/mono/glue/Managed/Files/Vector3.cs
@@ -204,9 +204,9 @@ namespace Godot
public Basis Outer(Vector3 b)
{
return new Basis(
- new Vector3(x * b.x, x * b.y, x * b.z),
- new Vector3(y * b.x, y * b.y, y * b.z),
- new Vector3(z * b.x, z * b.y, z * b.z)
+ x * b.x, x * b.y, x * b.z,
+ y * b.x, y * b.y, y * b.z,
+ z * b.x, z * b.y, z * b.z
);
}
@@ -276,13 +276,13 @@ namespace Godot
0f, 0f, z
);
}
-
+
// Constants
private static readonly Vector3 _zero = new Vector3(0, 0, 0);
private static readonly Vector3 _one = new Vector3(1, 1, 1);
private static readonly Vector3 _negOne = new Vector3(-1, -1, -1);
private static readonly Vector3 _inf = new Vector3(Mathf.Inf, Mathf.Inf, Mathf.Inf);
-
+
private static readonly Vector3 _up = new Vector3(0, 1, 0);
private static readonly Vector3 _down = new Vector3(0, -1, 0);
private static readonly Vector3 _right = new Vector3(1, 0, 0);
@@ -294,7 +294,7 @@ namespace Godot
public static Vector3 One { get { return _one; } }
public static Vector3 NegOne { get { return _negOne; } }
public static Vector3 Inf { get { return _inf; } }
-
+
public static Vector3 Up { get { return _up; } }
public static Vector3 Down { get { return _down; } }
public static Vector3 Right { get { return _right; } }
diff --git a/modules/mono/glue/Managed/Properties/AssemblyInfo.cs b/modules/mono/glue/Managed/Properties/AssemblyInfo.cs
index 7ed68acad7..77b3774e81 100644
--- a/modules/mono/glue/Managed/Properties/AssemblyInfo.cs
+++ b/modules/mono/glue/Managed/Properties/AssemblyInfo.cs
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-// Information about this assembly is defined by the following attributes.
+// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("Managed")]
@@ -19,7 +19,7 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("1.0.*")]
-// The following attributes are used to specify the signing key for the assembly,
+// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]