summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-02 14:18:19 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-02 14:18:19 +0100
commit34c66fac0a7238fa1c6b2ff7efef908224aa47c5 (patch)
treef1010000ffad430efb036fcd83b949a50e87e068
parent910cf9a9b3b8a8e617ad21ad9e18d49f16e82eb1 (diff)
parent9487a6ea32cb57cf0a8768cf221814c915cd8486 (diff)
Merge pull request #68161 from Chaosus/dotnet_quaternion_constructor
Add missed Quaternion constructor to C#
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
index d459fe8c96..a80963a37e 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
@@ -572,6 +572,30 @@ namespace Godot
}
}
+ public Quaternion(Vector3 arcFrom, Vector3 arcTo)
+ {
+ Vector3 c = arcFrom.Cross(arcTo);
+ real_t d = arcFrom.Dot(arcTo);
+
+ if (d < -1.0f + Mathf.Epsilon)
+ {
+ x = 0f;
+ y = 1f;
+ z = 0f;
+ w = 0f;
+ }
+ else
+ {
+ real_t s = Mathf.Sqrt((1.0f + d) * 2.0f);
+ real_t rs = 1.0f / s;
+
+ x = c.x * rs;
+ y = c.y * rs;
+ z = c.z * rs;
+ w = s * 0.5f;
+ }
+ }
+
/// <summary>
/// Composes these two quaternions by multiplying them together.
/// This has the effect of rotating the second quaternion