summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/mono/glue/cs_files/Mathf.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs
index 8b9c264d0d..adbcc855ef 100644
--- a/modules/mono/glue/cs_files/Mathf.cs
+++ b/modules/mono/glue/cs_files/Mathf.cs
@@ -257,5 +257,17 @@ namespace Godot
{
return (real_t)Math.Tanh(s);
}
+
+ public static int Wrap(int val, int min, int max)
+ {
+ int rng = max - min;
+ return min + ((((val - min) % rng) + rng) % rng);
+ }
+
+ public static real_t Wrap(real_t val, real_t min, real_t max)
+ {
+ real_t rng = max - min;
+ return min + (val - min) - (rng * Floor((val - min) / rng));
+ }
}
}