Merge pull request #17772 from Chaosus/monowrap

Add wrap functions to C#
This commit is contained in:
Ignacio Etcheverry 2018-03-31 00:12:16 +02:00 committed by GitHub
commit d2eb731878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -257,5 +257,17 @@ namespace Godot
{ {
return (real_t)Math.Tanh(s); 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));
}
} }
} }