summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2022-09-18 18:28:44 -0500
committerAaron Franke <arnfranke@yahoo.com>2022-09-19 03:09:59 -0500
commit7ba459ae7baf9804c3822f38d3818f59dfa7ef47 (patch)
tree697e511d98c2e0f921ae15de20ba2e987771ca8d /include
parent9a2e8d907b86b974c1644ae6e75eb7adefa384b2 (diff)
downloadredot-cpp-7ba459ae7baf9804c3822f38d3818f59dfa7ef47.tar.gz
Add integer posmod and rename range_lerp to remap
https://github.com/godotengine/godot/pull/23310 https://github.com/godotengine/godot/pull/65361
Diffstat (limited to 'include')
-rw-r--r--include/godot_cpp/core/math.hpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/godot_cpp/core/math.hpp b/include/godot_cpp/core/math.hpp
index e864ee1..6bc2344 100644
--- a/include/godot_cpp/core/math.hpp
+++ b/include/godot_cpp/core/math.hpp
@@ -113,7 +113,7 @@ inline float fposmod(float p_x, float p_y) {
if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) {
value += p_y;
}
- value += 0.0;
+ value += 0.0f;
return value;
}
@@ -122,7 +122,7 @@ inline float fposmodp(float p_x, float p_y) {
if (value < 0) {
value += p_y;
}
- value += 0.0;
+ value += 0.0f;
return value;
}
inline double fposmodp(double p_x, double p_y) {
@@ -134,6 +134,14 @@ inline double fposmodp(double p_x, double p_y) {
return value;
}
+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;
+ }
+ return value;
+}
+
inline double floor(double p_x) {
return ::floor(p_x);
}
@@ -454,10 +462,10 @@ inline float inverse_lerp(float p_from, float p_to, float p_value) {
return (p_value - p_from) / (p_to - p_from);
}
-inline double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) {
+inline double remap(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) {
return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value));
}
-inline float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) {
+inline float remap(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) {
return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value));
}