summaryrefslogtreecommitdiff
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-07-19 15:07:49 +0200
committerGitHub <noreply@github.com>2019-07-19 15:07:49 +0200
commitf796779f7c89cd2c92bc4531e5e90f49acda30f9 (patch)
tree96bffa75633d0a624f788c2e8bd402937b46c3b0 /core/math/math_funcs.h
parent2ca3e47d66fe3f3d849e2084d516949c84011f4b (diff)
parenta60f242982d70e85a5b2c182eb3289b2fa7812e1 (diff)
Merge pull request #23310 from aaronfranke/posmod-int
Add integer posmod and rename default arg names
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r--core/math/math_funcs.h7
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; }