diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-03-16 05:07:33 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2020-04-29 04:02:49 -0400 |
commit | 540156b387270215f513a68b1cf9ffc909ac381b (patch) | |
tree | e5c7f89c9c70294dd1a5aac5461fbb9170868578 /core | |
parent | ad3c3e1bbbdbf47fca6d775e01867820040d84f1 (diff) |
[Core] Rename linear_interpolate to lerp
Diffstat (limited to 'core')
-rw-r--r-- | core/color.h | 2 | ||||
-rw-r--r-- | core/input/input.cpp | 2 | ||||
-rw-r--r-- | core/math/audio_frame.h | 2 | ||||
-rw-r--r-- | core/math/geometry.cpp | 4 | ||||
-rw-r--r-- | core/math/geometry.h | 4 | ||||
-rw-r--r-- | core/math/transform.cpp | 4 | ||||
-rw-r--r-- | core/math/transform_2d.cpp | 6 | ||||
-rw-r--r-- | core/math/vector2.h | 15 | ||||
-rw-r--r-- | core/math/vector3.h | 4 | ||||
-rw-r--r-- | core/variant_call.cpp | 12 | ||||
-rw-r--r-- | core/variant_op.cpp | 16 |
11 files changed, 30 insertions, 41 deletions
diff --git a/core/color.h b/core/color.h index 16dc721072..d95e80f5da 100644 --- a/core/color.h +++ b/core/color.h @@ -97,7 +97,7 @@ struct Color { Color inverted() const; Color contrasted() const; - _FORCE_INLINE_ Color linear_interpolate(const Color &p_b, float p_t) const { + _FORCE_INLINE_ Color lerp(const Color &p_b, float p_t) const { Color res = *this; diff --git a/core/input/input.cpp b/core/input/input.cpp index 5301f5f4ee..357e4c06c1 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -175,7 +175,7 @@ void Input::SpeedTrack::update(const Vector2 &p_delta_p) { accum = accum - slice; accum_t -= min_ref_frame; - speed = (slice / min_ref_frame).linear_interpolate(speed, min_ref_frame / max_ref_frame); + speed = (slice / min_ref_frame).lerp(speed, min_ref_frame / max_ref_frame); } } diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index e1dbb385e4..4665311059 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -104,7 +104,7 @@ struct AudioFrame { r = ::undenormalise(r); } - _FORCE_INLINE_ AudioFrame linear_interpolate(const AudioFrame &p_b, float p_t) const { + _FORCE_INLINE_ AudioFrame lerp(const AudioFrame &p_b, float p_t) const { AudioFrame res = *this; diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 3e07e9253e..4733c27cbc 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -911,7 +911,7 @@ Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_l for (int j = 1; j <= p_lats; j++) { // FIXME: This is stupid. - Vector3 angle = normal.linear_interpolate(axis, j / (real_t)p_lats).normalized(); + Vector3 angle = normal.lerp(axis, j / (real_t)p_lats).normalized(); Vector3 pos = angle * p_radius; planes.push_back(Plane(pos, angle)); planes.push_back(Plane(pos * axis_neg, angle * axis_neg)); @@ -943,7 +943,7 @@ Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, i for (int j = 1; j <= p_lats; j++) { - Vector3 angle = normal.linear_interpolate(axis, j / (real_t)p_lats).normalized(); + Vector3 angle = normal.lerp(axis, j / (real_t)p_lats).normalized(); Vector3 pos = axis * p_height * 0.5 + angle * p_radius; planes.push_back(Plane(pos, angle)); planes.push_back(Plane(pos * axis_neg, angle * axis_neg)); diff --git a/core/math/geometry.h b/core/math/geometry.h index e47d18b056..a86db6e395 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -117,8 +117,8 @@ public: if (mub < 0) mub = 0; if (mua > 1) mua = 1; if (mub > 1) mub = 1; - c1 = p1.linear_interpolate(p2, mua); - c2 = q1.linear_interpolate(q2, mub); + c1 = p1.lerp(p2, mua); + c2 = q1.lerp(q2, mub); } static real_t get_closest_distance_between_segments(const Vector3 &p_from_a, const Vector3 &p_to_a, const Vector3 &p_from_b, const Vector3 &p_to_b) { diff --git a/core/math/transform.cpp b/core/math/transform.cpp index 9dad3262d2..82e4005d3e 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -129,8 +129,8 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) Vector3 dst_loc = p_transform.origin; Transform interp; - interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.linear_interpolate(dst_scale, p_c)); - interp.origin = src_loc.linear_interpolate(dst_loc, p_c); + interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.lerp(dst_scale, p_c)); + interp.origin = src_loc.lerp(dst_loc, p_c); return interp; } diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index f28b664e46..97a9216a5a 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -267,7 +267,7 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t Vector2 v; if (dot > 0.9995) { - v = Vector2::linear_interpolate(v1, v2, p_c).normalized(); //linearly interpolate to avoid numerical precision issues + v = v1.lerp(v2, p_c).normalized(); //linearly interpolate to avoid numerical precision issues } else { real_t angle = p_c * Math::acos(dot); Vector2 v3 = (v2 - v1 * dot).normalized(); @@ -275,8 +275,8 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t } //construct matrix - Transform2D res(Math::atan2(v.y, v.x), Vector2::linear_interpolate(p1, p2, p_c)); - res.scale_basis(Vector2::linear_interpolate(s1, s2, p_c)); + Transform2D res(Math::atan2(v.y, v.x), p1.lerp(p2, p_c)); + res.scale_basis(s1.lerp(s2, p_c)); return res; } diff --git a/core/math/vector2.h b/core/math/vector2.h index 95d2474838..c0057f2543 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -82,8 +82,7 @@ struct Vector2 { Vector2 clamped(real_t p_len) const; - _FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t); - _FORCE_INLINE_ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const; + _FORCE_INLINE_ Vector2 lerp(const Vector2 &p_b, real_t p_t) const; _FORCE_INLINE_ Vector2 slerp(const Vector2 &p_b, real_t p_t) const; Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const; @@ -224,7 +223,7 @@ _FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const { return x != p_vec2.x || y != p_vec2.y; } -Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const { +Vector2 Vector2::lerp(const Vector2 &p_b, real_t p_t) const { Vector2 res = *this; @@ -248,16 +247,6 @@ Vector2 Vector2::direction_to(const Vector2 &p_b) const { return ret; } -Vector2 Vector2::linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t) { - - Vector2 res = p_a; - - res.x += (p_t * (p_b.x - p_a.x)); - res.y += (p_t * (p_b.y - p_a.y)); - - return res; -} - typedef Vector2 Size2; typedef Vector2 Point2; diff --git a/core/math/vector3.h b/core/math/vector3.h index 3bf8644af9..a5e9d09208 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -89,7 +89,7 @@ struct Vector3 { /* Static Methods between 2 vector3s */ - _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3 &p_b, real_t p_t) const; + _FORCE_INLINE_ Vector3 lerp(const Vector3 &p_b, real_t p_t) const; _FORCE_INLINE_ Vector3 slerp(const Vector3 &p_b, real_t p_t) const; Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const; Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const; @@ -206,7 +206,7 @@ Vector3 Vector3::round() const { return Vector3(Math::round(x), Math::round(y), Math::round(z)); } -Vector3 Vector3::linear_interpolate(const Vector3 &p_b, real_t p_t) const { +Vector3 Vector3::lerp(const Vector3 &p_b, real_t p_t) const { return Vector3( x + (p_t * (p_b.x - x)), diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 483565648a..39bfd04a0b 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -362,7 +362,7 @@ struct _VariantCall { VCALL_LOCALMEM1R(Vector2, angle_to); VCALL_LOCALMEM1R(Vector2, angle_to_point); VCALL_LOCALMEM1R(Vector2, direction_to); - VCALL_LOCALMEM2R(Vector2, linear_interpolate); + VCALL_LOCALMEM2R(Vector2, lerp); VCALL_LOCALMEM2R(Vector2, slerp); VCALL_LOCALMEM4R(Vector2, cubic_interpolate); VCALL_LOCALMEM2R(Vector2, move_toward); @@ -426,7 +426,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(Vector3, inverse); VCALL_LOCALMEM1R(Vector3, snapped); VCALL_LOCALMEM2R(Vector3, rotated); - VCALL_LOCALMEM2R(Vector3, linear_interpolate); + VCALL_LOCALMEM2R(Vector3, lerp); VCALL_LOCALMEM2R(Vector3, slerp); VCALL_LOCALMEM4R(Vector3, cubic_interpolate); VCALL_LOCALMEM2R(Vector3, move_toward); @@ -509,7 +509,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(Color, to_rgba64); VCALL_LOCALMEM0R(Color, inverted); VCALL_LOCALMEM0R(Color, contrasted); - VCALL_LOCALMEM2R(Color, linear_interpolate); + VCALL_LOCALMEM2R(Color, lerp); VCALL_LOCALMEM1R(Color, blend); VCALL_LOCALMEM1R(Color, lightened); VCALL_LOCALMEM1R(Color, darkened); @@ -1801,7 +1801,7 @@ void register_variant_methods() { ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, FLOAT, "mod", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR2, VECTOR2, Vector2, lerp, VECTOR2, "b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", FLOAT, "t", varray()); ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", FLOAT, "delta", varray()); @@ -1866,7 +1866,7 @@ void register_variant_methods() { ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray()); ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, lerp, VECTOR3, "b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", FLOAT, "t", varray()); ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", FLOAT, "delta", varray()); @@ -1925,7 +1925,7 @@ void register_variant_methods() { ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray()); ADDFUNC0R(COLOR, COLOR, Color, inverted, varray()); ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray()); - ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", FLOAT, "t", varray()); + ADDFUNC2R(COLOR, COLOR, Color, lerp, COLOR, "b", FLOAT, "t", varray()); ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray()); ADDFUNC1R(COLOR, COLOR, Color, lightened, FLOAT, "amount", varray()); ADDFUNC1R(COLOR, COLOR, Color, darkened, FLOAT, "amount", varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index f173c88054..27624b81ee 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -4220,7 +4220,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case VECTOR2: { - r_dst = reinterpret_cast<const Vector2 *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Vector2 *>(b._data._mem), c); + r_dst = reinterpret_cast<const Vector2 *>(a._data._mem)->lerp(*reinterpret_cast<const Vector2 *>(b._data._mem), c); } return; case VECTOR2I: { @@ -4233,7 +4233,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & return; case RECT2: { - r_dst = Rect2(reinterpret_cast<const Rect2 *>(a._data._mem)->position.linear_interpolate(reinterpret_cast<const Rect2 *>(b._data._mem)->position, c), reinterpret_cast<const Rect2 *>(a._data._mem)->size.linear_interpolate(reinterpret_cast<const Rect2 *>(b._data._mem)->size, c)); + r_dst = Rect2(reinterpret_cast<const Rect2 *>(a._data._mem)->position.lerp(reinterpret_cast<const Rect2 *>(b._data._mem)->position, c), reinterpret_cast<const Rect2 *>(a._data._mem)->size.lerp(reinterpret_cast<const Rect2 *>(b._data._mem)->size, c)); } return; case RECT2I: { @@ -4254,7 +4254,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & return; case VECTOR3: { - r_dst = reinterpret_cast<const Vector3 *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Vector3 *>(b._data._mem), c); + r_dst = reinterpret_cast<const Vector3 *>(a._data._mem)->lerp(*reinterpret_cast<const Vector3 *>(b._data._mem), c); } return; case VECTOR3I: { @@ -4281,7 +4281,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case AABB: { - r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c)); + r_dst = ::AABB(a._data._aabb->position.lerp(b._data._aabb->position, c), a._data._aabb->size.lerp(b._data._aabb->size, c)); } return; case BASIS: { @@ -4293,7 +4293,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case COLOR: { - r_dst = reinterpret_cast<const Color *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Color *>(b._data._mem), c); + r_dst = reinterpret_cast<const Color *>(a._data._mem)->lerp(*reinterpret_cast<const Color *>(b._data._mem), c); } return; case STRING_NAME: { @@ -4448,7 +4448,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector2 *br = arr_b->ptr(); for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); + vw[i] = ar[i].lerp(br[i], c); } } r_dst = v; @@ -4473,7 +4473,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector3 *br = arr_b->ptr(); for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); + vw[i] = ar[i].lerp(br[i], c); } } r_dst = v; @@ -4497,7 +4497,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Color *br = arr_b->ptr(); for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); + vw[i] = ar[i].lerp(br[i], c); } } r_dst = v; |