summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2020-12-21 18:02:57 +0000
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2020-12-28 13:01:30 +0000
commitb743a2ef3cc48a94d626fccb49217237b7d4497c (patch)
tree7c9082151468bcae97a39bdd4ff265c5b9ba05f7 /core
parentbe509bf5e4d00b33f2867e6d06a23285b2a8fd29 (diff)
Rename Math::stepify to snapped
Diffstat (limited to 'core')
-rw-r--r--core/math/math_funcs.cpp2
-rw-r--r--core/math/math_funcs.h6
-rw-r--r--core/math/vector2.cpp6
-rw-r--r--core/math/vector3.cpp12
-rw-r--r--core/variant/variant_call.cpp4
-rw-r--r--core/variant/variant_utility.cpp6
6 files changed, 18 insertions, 18 deletions
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index e57257b442..f664b2f006 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -123,7 +123,7 @@ double Math::ease(double p_x, double p_c) {
}
}
-double Math::stepify(double p_value, double p_step) {
+double Math::snapped(double p_value, double p_step) {
if (p_step != 0) {
p_value = Math::floor(p_value / p_step + 0.5) * p_step;
}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 471aa58996..f4ebffe81c 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -292,7 +292,7 @@ public:
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
static int range_step_decimals(double p_step);
- static double stepify(double p_value, double p_step);
+ static double snapped(double p_value, double p_step);
static double dectime(double p_value, double p_amount, double p_step);
static uint32_t larger_prime(uint32_t p_val);
@@ -472,12 +472,12 @@ public:
}
static _ALWAYS_INLINE_ float snap_scalar(float p_offset, float p_step, float p_target) {
- return p_step != 0 ? Math::stepify(p_target - p_offset, p_step) + p_offset : p_target;
+ return p_step != 0 ? Math::snapped(p_target - p_offset, p_step) + p_offset : p_target;
}
static _ALWAYS_INLINE_ float snap_scalar_separation(float p_offset, float p_step, float p_target, float p_separation) {
if (p_step != 0) {
- float a = Math::stepify(p_target - p_offset, p_step + p_separation) + p_offset;
+ float a = Math::snapped(p_target - p_offset, p_step + p_separation) + p_offset;
float b = a;
if (p_target >= 0) {
b -= p_separation;
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index f9c2eeb57d..7d5a051a34 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -122,10 +122,10 @@ Vector2 Vector2::project(const Vector2 &p_to) const {
return p_to * (dot(p_to) / p_to.length_squared());
}
-Vector2 Vector2::snapped(const Vector2 &p_by) const {
+Vector2 Vector2::snapped(const Vector2 &p_step) const {
return Vector2(
- Math::stepify(x, p_by.x),
- Math::stepify(y, p_by.y));
+ Math::snapped(x, p_step.x),
+ Math::snapped(y, p_step.y));
}
Vector2 Vector2::clamped(real_t p_len) const {
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 09354d8e79..ebacf07fd4 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -60,15 +60,15 @@ int Vector3::max_axis() const {
return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0);
}
-void Vector3::snap(Vector3 p_val) {
- x = Math::stepify(x, p_val.x);
- y = Math::stepify(y, p_val.y);
- z = Math::stepify(z, p_val.z);
+void Vector3::snap(Vector3 p_step) {
+ x = Math::snapped(x, p_step.x);
+ y = Math::snapped(y, p_step.y);
+ z = Math::snapped(z, p_step.z);
}
-Vector3 Vector3::snapped(Vector3 p_val) const {
+Vector3 Vector3::snapped(Vector3 p_step) const {
Vector3 v = *this;
- v.snap(p_val);
+ v.snap(p_step);
return v;
}
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 2b6364786e..4c30bc5371 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1016,7 +1016,7 @@ static void _register_variant_builtin_methods() {
bind_method(Vector2, cross, sarray("with"), varray());
bind_method(Vector2, abs, sarray(), varray());
bind_method(Vector2, sign, sarray(), varray());
- bind_method(Vector2, snapped, sarray("by"), varray());
+ bind_method(Vector2, snapped, sarray("step"), varray());
bind_method(Vector2, clamped, sarray("length"), varray());
/* Vector2i */
@@ -1070,7 +1070,7 @@ static void _register_variant_builtin_methods() {
bind_method(Vector3, is_normalized, sarray(), varray());
bind_method(Vector3, is_equal_approx, sarray("to"), varray());
bind_method(Vector3, inverse, sarray(), varray());
- bind_method(Vector3, snapped, sarray("by"), varray());
+ bind_method(Vector3, snapped, sarray("step"), varray());
bind_method(Vector3, rotated, sarray("by_axis", "phi"), varray());
bind_method(Vector3, lerp, sarray("to", "weight"), varray());
bind_method(Vector3, slerp, sarray("to", "weight"), varray());
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index 46359b80ce..9a344143b8 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -217,8 +217,8 @@ struct VariantUtilityFunctions {
return Math::range_step_decimals(step);
}
- static inline double stepify(double value, double step) {
- return Math::stepify(value, step);
+ static inline double snapped(double value, double step) {
+ return Math::snapped(value, step);
}
static inline double lerp(double from, double to, double weight) {
@@ -1181,7 +1181,7 @@ void Variant::_register_variant_utility_functions() {
FUNCBINDR(ease, sarray("x", "curve"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(step_decimals, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(range_step_decimals, sarray("x"), Variant::UTILITY_FUNC_TYPE_MATH);
- FUNCBINDR(stepify, sarray("x", "step"), Variant::UTILITY_FUNC_TYPE_MATH);
+ FUNCBINDR(snapped, sarray("x", "step"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(lerp, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(lerp_angle, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);