diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2018-10-27 16:12:27 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2019-07-18 16:33:43 -0400 |
commit | a60f242982d70e85a5b2c182eb3289b2fa7812e1 (patch) | |
tree | 212cd72bf8e9b157de9b35ec8ccda3337f30bbbc /core/math/math_funcs.h | |
parent | 20a3bb9c484431439ffa60a158d7563c466cd530 (diff) |
Add integer posmod and rename default arg names
"posmod" is the integer version of "fposmod". We do not need a "mod" because of the % operator.
I changed the default arg names from "x" and "y" to "a" and "b" because they are not coordinates. I also changed pow's arg names to "base" and "exp". Also, I reorganized the code in the VS built-in funcs switch statement.
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r-- | core/math/math_funcs.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 0e3bd8a318..b6398712e4 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -198,6 +198,13 @@ public: value += 0.0; return value; } + static _ALWAYS_INLINE_ int posmod(int p_x, int p_y) { + int value = p_x % p_y; + if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) { + value += p_y; + } + return value; + } static _ALWAYS_INLINE_ double deg2rad(double p_y) { return p_y * Math_PI / 180.0; } static _ALWAYS_INLINE_ float deg2rad(float p_y) { return p_y * Math_PI / 180.0; } |