Fix possible usage of clamp with lo > hi in Vector2D (#2049)

This commit is contained in:
dann-merlin 2023-04-16 00:27:14 +00:00 committed by GitHub
parent afc887d941
commit c86f06caa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@ Vector2D Vector2D::floor() {
} }
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) { Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
return Vector2D(std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x), std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y)); return Vector2D(std::clamp(this->x, min.x, max.x < min.x ? INFINITY : max.x), std::clamp(this->y, min.y, max.y < min.y ? INFINITY : max.y));
} }
double Vector2D::distance(const Vector2D& other) { double Vector2D::distance(const Vector2D& other) {