diff options
author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-03-31 00:12:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-31 00:12:16 +0200 |
commit | d2eb731878a4d660dd4a6babaea5967183b8f324 (patch) | |
tree | be1427f0f7ddf5b2fcd378c6323adabdf39c557a | |
parent | 6e1bba198791e87320862e9cd3ab4244ac284ab8 (diff) | |
parent | d52722c6da069549f56530fc56fe09e9a74027ce (diff) |
Merge pull request #17772 from Chaosus/monowrap
Add wrap functions to C#
-rw-r--r-- | modules/mono/glue/cs_files/Mathf.cs | 12 |
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)); + } } } |