mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-12-22 06:09:49 +01:00
math: avoid assert fail in std::clamp in closestPoint
This commit is contained in:
parent
bbc76ba4e4
commit
1d20063da2
1 changed files with 8 additions and 2 deletions
|
@ -206,8 +206,14 @@ Vector2D Hyprutils::Math::CBox::closestPoint(const Vector2D& vec) const {
|
|||
Vector2D nv = vec;
|
||||
Vector2D maxPoint = {x + w - EPSILON, y + h - EPSILON};
|
||||
|
||||
nv.x = std::clamp(nv.x, x, maxPoint.x);
|
||||
nv.y = std::clamp(nv.y, y, maxPoint.y);
|
||||
if (x < maxPoint.x)
|
||||
nv.x = std::clamp(nv.x, x, maxPoint.x);
|
||||
else
|
||||
nv.x = x;
|
||||
if (y < maxPoint.y)
|
||||
nv.y = std::clamp(nv.y, y, maxPoint.y);
|
||||
else
|
||||
nv.y = y;
|
||||
|
||||
if (std::fabs(nv.x - x) < EPSILON)
|
||||
nv.x = x;
|
||||
|
|
Loading…
Reference in a new issue