Core: Add constexpr constructors/operators to math structs

• Begin integrating `constexpr` on math tests; use `static_assert` where appropriate
This commit is contained in:
Thaddeus Crews 2024-11-01 11:15:21 -05:00
parent 9e6ee9c5c3
commit ea62170dac
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
56 changed files with 1109 additions and 1159 deletions

View file

@ -205,8 +205,8 @@ struct [[nodiscard]] Rect2 {
bool is_same(const Rect2 &p_rect) const;
bool is_finite() const;
bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; }
bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
constexpr bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; }
constexpr bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
inline Rect2 grow(real_t p_amount) const {
Rect2 g = *this;
@ -361,12 +361,12 @@ struct [[nodiscard]] Rect2 {
operator String() const;
operator Rect2i() const;
Rect2() {}
Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) :
Rect2() = default;
constexpr Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) :
position(Point2(p_x, p_y)),
size(Size2(p_width, p_height)) {
}
Rect2(const Point2 &p_pos, const Size2 &p_size) :
constexpr Rect2(const Point2 &p_pos, const Size2 &p_size) :
position(p_pos),
size(p_size) {
}