diff options
| author | magumagu <magumagu9@gmail.com> | 2015-03-04 17:08:30 -0800 |
|---|---|---|
| committer | magumagu <magumagu9@gmail.com> | 2015-03-04 17:15:29 -0800 |
| commit | 863a4c9ce01bbbccafe01487690878f4a817abcd (patch) | |
| tree | 6afba70e4c5e0a87303370c919bda937c7460705 /Source/Core | |
| parent | e96569ff0cb7fa10d2c727dc3141710243a9c94e (diff) | |
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.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/MathUtil.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index 13ef25e647..2519c0872a 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -156,20 +156,20 @@ struct Rectangle // this Clamp. void ClampLL(T x1, T y1, T x2, T y2) { - if (left < x1) left = x1; - if (right > x2) right = x2; - if (top > y1) top = y1; - if (bottom < y2) bottom = y2; + Clamp(&left, x1, x2); + Clamp(&right, x1, x2); + Clamp(&top, y2, y1); + Clamp(&bottom, y2, y1); } // If the rectangle is in a coordinate system with an upper-left origin, // use this Clamp. void ClampUL(T x1, T y1, T x2, T y2) { - if (left < x1) left = x1; - if (right > x2) right = x2; - if (top < y1) top = y1; - if (bottom > y2) bottom = y2; + Clamp(&left, x1, x2); + Clamp(&right, x1, x2); + Clamp(&top, y1, y2); + Clamp(&bottom, y1, y2); } }; |
