summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-05-04 15:15:52 +0200
committerGitHub <noreply@github.com>2021-05-04 15:15:52 +0200
commitc9e874b62db78902b4963e656b3b97b57e93c42f (patch)
tree7345c8c6a294e6e467aa0e67c22a22a87db0dffd /core
parentea9cab3e76b7cb8754b6d64102101f79a253ed8d (diff)
parente196733e880792ca75fce72e642383c777280aa5 (diff)
Merge pull request #48442 from akien-mga/posmod-int64_t
Re-bind posmod, use int64_t instead of int
Diffstat (limited to 'core')
-rw-r--r--core/math/math_funcs.h4
-rw-r--r--core/variant/variant_utility.cpp5
2 files changed, 7 insertions, 2 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 8cf13efdb6..c0d7649b65 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -218,8 +218,8 @@ public:
return value;
}
- static _ALWAYS_INLINE_ int posmod(int p_x, int p_y) {
- int value = p_x % p_y;
+ static _ALWAYS_INLINE_ int64_t posmod(int64_t p_x, int64_t p_y) {
+ int64_t value = p_x % p_y;
if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) {
value += p_y;
}
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index f154ab1ed6..553f2b23a2 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -93,6 +93,10 @@ struct VariantUtilityFunctions {
return Math::fposmod(b, r);
}
+ static inline int64_t posmod(int64_t b, int64_t r) {
+ return Math::posmod(b, r);
+ }
+
static inline double floor(double x) {
return Math::floor(x);
}
@@ -1154,6 +1158,7 @@ void Variant::_register_variant_utility_functions() {
FUNCBINDR(sqrt, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(fmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(fposmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
+ FUNCBINDR(posmod, sarray("x", "y"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(floor, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(ceil, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(round, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);