| 5 | namespace skr::gui |
| 6 | { |
| 7 | struct Vector3 { |
| 8 | // ctor |
| 9 | inline constexpr Vector3() SKR_NOEXCEPT |
| 10 | : x(0.0f), |
| 11 | y(0.0f), |
| 12 | z(0.0f) |
| 13 | { |
| 14 | } |
| 15 | inline constexpr Vector3(float all) SKR_NOEXCEPT |
| 16 | : x(all), |
| 17 | y(all), |
| 18 | z(all) |
| 19 | { |
| 20 | } |
| 21 | inline constexpr Vector3(float x, float y, float z) SKR_NOEXCEPT |
| 22 | : x(x), |
| 23 | y(y), |
| 24 | z(z) |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | // assign |
| 29 | inline constexpr Vector3& operator=(float all) SKR_NOEXCEPT |
| 30 | { |
| 31 | x = all; |
| 32 | y = all; |
| 33 | z = all; |
| 34 | return *this; |
| 35 | } |
| 36 | |
| 37 | // copy & move & assign & move assign |
| 38 | inline constexpr Vector3(const Vector3& other) SKR_NOEXCEPT = default; |
| 39 | inline constexpr Vector3(Vector3&& other) SKR_NOEXCEPT = default; |
| 40 | inline constexpr Vector3& operator=(const Vector3& other) SKR_NOEXCEPT = default; |
| 41 | inline constexpr Vector3& operator=(Vector3&& other) SKR_NOEXCEPT = default; |
| 42 | |
| 43 | // compare |
| 44 | inline constexpr bool operator==(const Vector3& other) const SKR_NOEXCEPT { return x == other.x && y == other.y && z == other.z; } |
| 45 | inline constexpr bool operator!=(const Vector3& other) const SKR_NOEXCEPT { return !(*this == other); } |
| 46 | |
| 47 | // arithmetic ops |
| 48 | inline Vector3 operator-() const SKR_NOEXCEPT { return Vector3(-x, -y, -z); } |
| 49 | |
| 50 | friend inline Vector3 operator+(const Vector3& lhs, float rhs) SKR_NOEXCEPT { return Vector3(lhs.x + rhs, lhs.y + rhs, lhs.z + rhs); } |
| 51 | friend inline Vector3 operator-(const Vector3& lhs, float rhs) SKR_NOEXCEPT { return Vector3(lhs.x - rhs, lhs.y - rhs, lhs.z - rhs); } |
| 52 | friend inline Vector3 operator*(const Vector3& lhs, float rhs) SKR_NOEXCEPT { return Vector3(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs); } |
| 53 | friend inline Vector3 operator/(const Vector3& lhs, float rhs) SKR_NOEXCEPT { return Vector3(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs); } |
| 54 | friend inline Vector3 operator%(const Vector3& lhs, float rhs) SKR_NOEXCEPT { return Vector3(::std::fmod(lhs.x, rhs), ::std::fmod(lhs.y, rhs), ::std::fmod(lhs.z, rhs)); } |
| 55 | |
| 56 | friend inline Vector3 operator+(float lhs, const Vector3& rhs) SKR_NOEXCEPT { return Vector3(lhs + rhs.x, lhs + rhs.y, lhs + rhs.z); } |
| 57 | friend inline Vector3 operator-(float lhs, const Vector3& rhs) SKR_NOEXCEPT { return Vector3(lhs - rhs.x, lhs - rhs.y, lhs - rhs.z); } |
| 58 | friend inline Vector3 operator*(float lhs, const Vector3& rhs) SKR_NOEXCEPT { return Vector3(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z); } |
| 59 | friend inline Vector3 operator/(float lhs, const Vector3& rhs) SKR_NOEXCEPT { return Vector3(lhs / rhs.x, lhs / rhs.y, lhs / rhs.z); } |
| 60 | friend inline Vector3 operator%(float lhs, const Vector3& rhs) SKR_NOEXCEPT { return Vector3(::std::fmod(lhs, rhs.x), ::std::fmod(lhs, rhs.y), ::std::fmod(lhs, rhs.z)); } |
| 61 | |
| 62 | inline Vector3 operator+(const Vector3& other) const SKR_NOEXCEPT { return Vector3(x + other.x, y + other.y, z + other.z); } |
| 63 | inline Vector3 operator-(const Vector3& other) const SKR_NOEXCEPT { return Vector3(x - other.x, y - other.y, z - other.z); } |
| 64 | inline Vector3 operator*(const Vector3& other) const SKR_NOEXCEPT { return Vector3(x * other.x, y * other.y, z * other.z); } |