diff --git a/include/blah_spatial.h b/include/blah_spatial.h index aaea9cd..4193662 100644 --- a/include/blah_spatial.h +++ b/include/blah_spatial.h @@ -192,6 +192,7 @@ namespace Blah constexpr Line bottom_line() const; constexpr bool contains(const Vec2& pt) const; + constexpr bool contains(const Rect& rect) const; constexpr bool overlaps(const Rect& rect) const; constexpr Rect overlap_rect(const Rect& other) const; constexpr bool intersects(const Line& line) const; @@ -719,6 +720,10 @@ namespace Blah constexpr bool Rect::contains(const Vec2& pt) const { return pt.x >= x && pt.x < x + w && pt.y >= y && pt.y < y + h; } + template + constexpr bool Rect::contains(const Rect& rect) const { + return rect.x >= x && rect.x + rect.w < x + w && rect.y >= y && rect.y + rect.h < y + h; + } template constexpr bool Rect::overlaps(const Rect& rect) const {