1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Replace float with real_t, default Vectors, other misc C# improvements

Replace float with real_t in most files, defined at the top of each file via using. Objects such as Vector3 now accept doubles as inputs, and convert to real_t internally. I've added default Vectors such as Vector3.Zero. Other misc C# improvements such as Mathf.RoundToInt(). Color continues to use float only because high precision is not needed for 8-bit color math and to keep things simple. Everything seems to compile and work fine, but testing is requested, as this is the first time I've ever contributed to Godot.
This commit is contained in:
Aaron Franke
2018-03-01 01:51:35 -06:00
parent c094e90b25
commit ff97c97c93
13 changed files with 473 additions and 291 deletions

View File

@@ -1,6 +1,12 @@
using System;
using System.Runtime.InteropServices;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
using real_t = System.Single;
#endif
namespace Godot
{
[StructLayout(LayoutKind.Sequential)]
@@ -33,7 +39,7 @@ namespace Godot
return new Transform(basis.Orthonormalized(), origin);
}
public Transform Rotated(Vector3 axis, float phi)
public Transform Rotated(Vector3 axis, real_t phi)
{
return new Transform(new Basis(axis, phi), new Vector3()) * this;
}
@@ -97,7 +103,8 @@ namespace Godot
(basis[0, 2] * vInv.x) + (basis[1, 2] * vInv.y) + (basis[2, 2] * vInv.z)
);
}
// Constructors
public Transform(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 origin)
{
this.basis = Basis.CreateFromAxes(xAxis, yAxis, zAxis);