diff options
Diffstat (limited to 'geometry/rect2d.hpp')
-rw-r--r-- | geometry/rect2d.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/geometry/rect2d.hpp b/geometry/rect2d.hpp index 40109415bf..a4cd5a6b79 100644 --- a/geometry/rect2d.hpp +++ b/geometry/rect2d.hpp @@ -17,6 +17,7 @@ namespace m2 template <typename T> struct min_max_value<T, true> { T get_min() { return numeric_limits<T>::max(); } + // TODO: There is an overflow here: -(-128) != 127. T get_max() { return -get_min(); } }; template <typename T> struct min_max_value<T, false> @@ -52,6 +53,16 @@ namespace m2 { } + static Rect GetEmptyRect() { return Rect(); } + + static Rect GetInfiniteRect() + { + T const tMax = numeric_limits<T>::max(); + // This works for both ints and floats. + T const tMin = min(-tMax, numeric_limits<T>::min()); + return Rect(tMin, tMin, tMax, tMax); + } + void MakeEmpty() { m_minX = m_minY = impl::min_max_value<T, numeric_limits<T>::is_signed>().get_min(); |