Added wrap functions to C#

(cherry picked from commit d52722c6da)
This commit is contained in:
Chaosus 2018-03-26 14:33:09 +03:00 committed by Hein-Pieter van Braam
parent bfc94dd4c9
commit 63a88c69ac

View file

@ -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));
}
}
}