mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
[3.x] Backport some APIs in math structs
This commit is contained in:
@@ -128,6 +128,7 @@ Vector2 Vector2::snapped(const Vector2 &p_by) const {
|
||||
}
|
||||
|
||||
Vector2 Vector2::clamped(real_t p_len) const {
|
||||
WARN_DEPRECATED_MSG("'Vector2.clamped()' is deprecated because it has been renamed to 'limit_length'.");
|
||||
real_t l = length();
|
||||
Vector2 v = *this;
|
||||
if (l > 0 && p_len < l) {
|
||||
@@ -138,6 +139,17 @@ Vector2 Vector2::clamped(real_t p_len) const {
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector2 Vector2::limit_length(const real_t p_len) const {
|
||||
const real_t l = length();
|
||||
Vector2 v = *this;
|
||||
if (l > 0 && p_len < l) {
|
||||
v /= l;
|
||||
v *= p_len;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const {
|
||||
Vector2 p0 = p_pre_a;
|
||||
Vector2 p1 = *this;
|
||||
|
||||
Reference in New Issue
Block a user