mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Fix clamping for rectangles.
Clamping a rectangle correctly requires fully clamping all four coordinates in the general case. This should fix issue 6923, sort of; at least, it fixes the part where a rectangle ends up with a nonsensical height after being clamped.
This commit is contained in:
@ -156,20 +156,20 @@ struct Rectangle
|
|||||||
// this Clamp.
|
// this Clamp.
|
||||||
void ClampLL(T x1, T y1, T x2, T y2)
|
void ClampLL(T x1, T y1, T x2, T y2)
|
||||||
{
|
{
|
||||||
if (left < x1) left = x1;
|
Clamp(&left, x1, x2);
|
||||||
if (right > x2) right = x2;
|
Clamp(&right, x1, x2);
|
||||||
if (top > y1) top = y1;
|
Clamp(&top, y2, y1);
|
||||||
if (bottom < y2) bottom = y2;
|
Clamp(&bottom, y2, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the rectangle is in a coordinate system with an upper-left origin,
|
// If the rectangle is in a coordinate system with an upper-left origin,
|
||||||
// use this Clamp.
|
// use this Clamp.
|
||||||
void ClampUL(T x1, T y1, T x2, T y2)
|
void ClampUL(T x1, T y1, T x2, T y2)
|
||||||
{
|
{
|
||||||
if (left < x1) left = x1;
|
Clamp(&left, x1, x2);
|
||||||
if (right > x2) right = x2;
|
Clamp(&right, x1, x2);
|
||||||
if (top < y1) top = y1;
|
Clamp(&top, y1, y2);
|
||||||
if (bottom > y2) bottom = y2;
|
Clamp(&bottom, y1, y2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user