|
@@ -1,4 +1,5 @@
|
|
using System;
|
|
using System;
|
|
|
|
+using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
namespace Godot
|
|
namespace Godot
|
|
@@ -31,6 +32,23 @@ namespace Godot
|
|
/// </summary>
|
|
/// </summary>
|
|
public Vector2 origin;
|
|
public Vector2 origin;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Returns the transform's rotation (in radians).
|
|
|
|
+ /// </summary>
|
|
|
|
+ public readonly real_t Rotation => Mathf.Atan2(x.y, x.x);
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Returns the scale.
|
|
|
|
+ /// </summary>
|
|
|
|
+ public readonly Vector2 Scale
|
|
|
|
+ {
|
|
|
|
+ get
|
|
|
|
+ {
|
|
|
|
+ real_t detSign = Mathf.Sign(BasisDeterminant());
|
|
|
|
+ return new Vector2(x.Length(), detSign * y.Length());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Access whole columns in the form of <see cref="Vector2"/>.
|
|
/// Access whole columns in the form of <see cref="Vector2"/>.
|
|
/// The third column is the <see cref="origin"/> vector.
|
|
/// The third column is the <see cref="origin"/> vector.
|
|
@@ -131,6 +149,7 @@ namespace Godot
|
|
/// and is usually considered invalid.
|
|
/// and is usually considered invalid.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns>The determinant of the basis matrix.</returns>
|
|
/// <returns>The determinant of the basis matrix.</returns>
|
|
|
|
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
private readonly real_t BasisDeterminant()
|
|
private readonly real_t BasisDeterminant()
|
|
{
|
|
{
|
|
return (x.x * y.y) - (x.y * y.x);
|
|
return (x.x * y.y) - (x.y * y.x);
|
|
@@ -163,23 +182,6 @@ namespace Godot
|
|
return new Vector2(x.Dot(v), y.Dot(v));
|
|
return new Vector2(x.Dot(v), y.Dot(v));
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// Returns the transform's rotation (in radians).
|
|
|
|
- /// </summary>
|
|
|
|
- public readonly real_t GetRotation()
|
|
|
|
- {
|
|
|
|
- return Mathf.Atan2(x.y, x.x);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Returns the scale.
|
|
|
|
- /// </summary>
|
|
|
|
- public readonly Vector2 GetScale()
|
|
|
|
- {
|
|
|
|
- real_t detSign = Mathf.Sign(BasisDeterminant());
|
|
|
|
- return new Vector2(x.Length(), detSign * y.Length());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Interpolates this transform to the other <paramref name="transform"/> by <paramref name="weight"/>.
|
|
/// Interpolates this transform to the other <paramref name="transform"/> by <paramref name="weight"/>.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -188,11 +190,11 @@ namespace Godot
|
|
/// <returns>The interpolated transform.</returns>
|
|
/// <returns>The interpolated transform.</returns>
|
|
public readonly Transform2D InterpolateWith(Transform2D transform, real_t weight)
|
|
public readonly Transform2D InterpolateWith(Transform2D transform, real_t weight)
|
|
{
|
|
{
|
|
- real_t r1 = GetRotation();
|
|
|
|
- real_t r2 = transform.GetRotation();
|
|
|
|
|
|
+ real_t r1 = Rotation;
|
|
|
|
+ real_t r2 = transform.Rotation;
|
|
|
|
|
|
- Vector2 s1 = GetScale();
|
|
|
|
- Vector2 s2 = transform.GetScale();
|
|
|
|
|
|
+ Vector2 s1 = Scale;
|
|
|
|
+ Vector2 s2 = transform.Scale;
|
|
|
|
|
|
// Slerp rotation
|
|
// Slerp rotation
|
|
(real_t sin1, real_t cos1) = Mathf.SinCos(r1);
|
|
(real_t sin1, real_t cos1) = Mathf.SinCos(r1);
|