Rename Vector2 clamped to limit_length and add limit_length to Vector3

This commit is contained in:
Aaron Franke
2021-02-01 00:42:00 -05:00
parent f288a79482
commit 94bc0bd919
10 changed files with 75 additions and 35 deletions

View File

@@ -64,6 +64,17 @@ Vector3 Vector3::snapped(Vector3 p_step) const {
return v;
}
Vector3 Vector3::limit_length(const real_t p_len) const {
const real_t l = length();
Vector3 v = *this;
if (l > 0 && p_len < l) {
v /= l;
v *= p_len;
}
return v;
}
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
Vector3 p0 = p_pre_a;
Vector3 p1 = *this;