You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
[Core] Add scalar versions of Vector* min/max/clamp/snap(ped)
Convenience for a number of cases operating on single values
This commit is contained in:
@@ -135,12 +135,24 @@ Vector2 Vector2::clamp(const Vector2 &p_min, const Vector2 &p_max) const {
|
||||
CLAMP(y, p_min.y, p_max.y));
|
||||
}
|
||||
|
||||
Vector2 Vector2::clampf(real_t p_min, real_t p_max) const {
|
||||
return Vector2(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max));
|
||||
}
|
||||
|
||||
Vector2 Vector2::snapped(const Vector2 &p_step) const {
|
||||
return Vector2(
|
||||
Math::snapped(x, p_step.x),
|
||||
Math::snapped(y, p_step.y));
|
||||
}
|
||||
|
||||
Vector2 Vector2::snappedf(real_t p_step) const {
|
||||
return Vector2(
|
||||
Math::snapped(x, p_step),
|
||||
Math::snapped(y, p_step));
|
||||
}
|
||||
|
||||
Vector2 Vector2::limit_length(real_t p_len) const {
|
||||
const real_t l = length();
|
||||
Vector2 v = *this;
|
||||
|
||||
Reference in New Issue
Block a user