Skip to content

Commit

Permalink
feat(sourcepp): add vector equality operators
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Jun 13, 2024
1 parent 7cc5cde commit eb8d9ce
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/sourcepp/math/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct Vec2 {
return {this->x - other.x, this->y - other.y};
}

[[nodiscard]] bool operator==(const Vec2& other) const {
return this->x == other.x && this->y == other.y;
}

[[nodiscard]] static constexpr Vec2 zero() {
return {{}, {}};
}
Expand Down Expand Up @@ -52,6 +56,10 @@ struct Vec3 {
return {this->x - other.x, this->y - other.y, this->z - other.z};
}

[[nodiscard]] bool operator==(const Vec3& other) const {
return this->x == other.x && this->y == other.y && this->z == other.z;
}

[[nodiscard]] static constexpr Vec3 zero() {
return {{}, {}, {}};
}
Expand Down Expand Up @@ -88,6 +96,10 @@ struct Vec4 {
return {this->x - other.x, this->y - other.y, this->z - other.z, this->w - other.w};
}

[[nodiscard]] bool operator==(const Vec4& other) const {
return this->x == other.x && this->y == other.y && this->z == other.z && this->w == other.w;
}

[[nodiscard]] static constexpr Vec4 zero() {
return {{}, {}, {}, {}};
}
Expand Down

0 comments on commit eb8d9ce

Please sign in to comment.