MathUtil: Make Rectangle work with unsigned types.
This commit is contained in:
parent
c5c6e095f0
commit
e02ff0121f
1 changed files with 5 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "common/common.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace MathUtil
|
||||
|
@ -112,8 +113,8 @@ struct Rectangle
|
|||
|
||||
bool operator==(const Rectangle& r) { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; }
|
||||
|
||||
T GetWidth() const { return abs(right - left); }
|
||||
T GetHeight() const { return abs(bottom - top); }
|
||||
T GetWidth() const { return std::abs(static_cast<typename std::make_signed<T>::type>(right - left)); }
|
||||
T GetHeight() const { return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top)); }
|
||||
|
||||
// If the rectangle is in a coordinate system with a lower-left origin, use
|
||||
// this Clamp.
|
||||
|
|
Loading…
Reference in a new issue