aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelly thomas2018-05-04 20:17:10 +0800
committerHein-Pieter van Braam2018-06-01 18:08:52 +0200
commitf697b53eba3819a99200ed84f72cc1a8b97ed159 (patch)
tree143f53b36a52979a7c54e1cf38f201e51140fa24
parent8231b3cef8b3551ff17e8432a7fc84cc01e0fe18 (diff)
downloadgodot-f697b53eba3819a99200ed84f72cc1a8b97ed159.tar.gz
godot-f697b53eba3819a99200ed84f72cc1a8b97ed159.tar.zst
godot-f697b53eba3819a99200ed84f72cc1a8b97ed159.zip
round / ceil methods for c sharp vectors
(cherry picked from commit a6bd2c6e72de373fab783d2ce15b67f5413e98ea)
-rw-r--r--modules/mono/glue/cs_files/Vector2.cs10
-rw-r--r--modules/mono/glue/cs_files/Vector3.cs5
2 files changed, 15 insertions, 0 deletions
diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs
index 2dfee5e51..c27436489 100644
--- a/modules/mono/glue/cs_files/Vector2.cs
+++ b/modules/mono/glue/cs_files/Vector2.cs
@@ -97,6 +97,11 @@ namespace Godot
return -Reflect(n);
}
+ public Vector2 Ceil()
+ {
+ return new Vector2(Mathf.Ceil(x), Mathf.Ceil(y));
+ }
+
public Vector2 Clamped(real_t length)
{
var v = this;
@@ -190,6 +195,11 @@ namespace Godot
return new Vector2(Mathf.Cos(rads), Mathf.Sin(rads)) * Length();
}
+ public Vector2 Round()
+ {
+ return new Vector2(Mathf.Round(x), Mathf.Round(y));
+ }
+
public void Set(real_t x, real_t y)
{
this.x = x;
diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/cs_files/Vector3.cs
index 259a8e063..085a4f004 100644
--- a/modules/mono/glue/cs_files/Vector3.cs
+++ b/modules/mono/glue/cs_files/Vector3.cs
@@ -219,6 +219,11 @@ namespace Godot
return 2.0f * n * Dot(n) - this;
}
+ public Vector3 Round()
+ {
+ return new Vector3(Mathf.Round(x), Mathf.Round(y), Mathf.Round(z));
+ }
+
public Vector3 Rotated(Vector3 axis, real_t phi)
{
return new Basis(axis, phi).Xform(this);