diff options
| author | Chaosus | 2018-03-26 14:33:09 +0300 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-04-15 00:52:29 +0200 |
| commit | 63a88c69ace63de4a3024854e991c8ca896471e9 (patch) | |
| tree | 93cf54c6197e953f3f462414e85ba78c7298cfbe /modules | |
| parent | bfc94dd4c911aa1ee0f93662dafb9594d5ff3e5e (diff) | |
| download | godot-63a88c69ace63de4a3024854e991c8ca896471e9.tar.gz godot-63a88c69ace63de4a3024854e991c8ca896471e9.tar.zst godot-63a88c69ace63de4a3024854e991c8ca896471e9.zip | |
Added wrap functions to C#
(cherry picked from commit d52722c6da069549f56530fc56fe09e9a74027ce)
Diffstat (limited to 'modules')
| -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 8b9c264d0..adbcc855e 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)); + } } } |
