From 5b2b23c9a950e8fcc6e76099449c7e421d147b73 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 10 Jun 2018 03:36:49 -0500 Subject: [PATCH] [Mono] Rename Fposmod to PosMod [Mono] Rename Fposmod to PosMod --- modules/mono/glue/cs_files/Mathf.cs | 36 +++++++++++++++++++------- modules/mono/glue/cs_files/VERSION.txt | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs index 0d20a125632..6b39a47641d 100644 --- a/modules/mono/glue/cs_files/Mathf.cs +++ b/modules/mono/glue/cs_files/Mathf.cs @@ -138,16 +138,6 @@ namespace Godot return (real_t)Math.Floor(s); } - public static real_t Fposmod(real_t x, real_t y) - { - if (x >= 0f) - { - return x % y; - } - - return y - -x % y; - } - public static real_t InverseLerp(real_t from, real_t to, real_t weight) { return (Clamp(weight, 0f, 1f) - from) / (to - from); @@ -210,6 +200,32 @@ namespace Godot return new Vector2(r * Cos(th), r * Sin(th)); } + /// + /// Performs a canonical Modulus operation, where the output is on the range [0, b). + /// + public static real_t PosMod(real_t a, real_t b) + { + real_t c = a % b; + if ((c < 0 && b > 0) || (c > 0 && b < 0)) + { + c += b; + } + return c; + } + + /// + /// Performs a canonical Modulus operation, where the output is on the range [0, b). + /// + public static int PosMod(int a, int b) + { + int c = a % b; + if ((c < 0 && b > 0) || (c > 0 && b < 0)) + { + c += b; + } + return c; + } + public static real_t Pow(real_t x, real_t y) { return (real_t)Math.Pow(x, y); diff --git a/modules/mono/glue/cs_files/VERSION.txt b/modules/mono/glue/cs_files/VERSION.txt index 00750edc07d..b8626c4cff2 100755 --- a/modules/mono/glue/cs_files/VERSION.txt +++ b/modules/mono/glue/cs_files/VERSION.txt @@ -1 +1 @@ -3 +4