| 103 | }; |
| 104 | |
| 105 | struct Vector4 { |
| 106 | // ctor |
| 107 | inline constexpr Vector4() SKR_NOEXCEPT |
| 108 | : x(0.0f), |
| 109 | y(0.0f), |
| 110 | z(0.0f), |
| 111 | w(0.0f) |
| 112 | { |
| 113 | } |
| 114 | inline constexpr Vector4(float all) SKR_NOEXCEPT |
| 115 | : x(all), |
| 116 | y(all), |
| 117 | z(all), |
| 118 | w(all) |
| 119 | { |
| 120 | } |
| 121 | inline constexpr Vector4(float x, float y, float z, float w) SKR_NOEXCEPT |
| 122 | : x(x), |
| 123 | y(y), |
| 124 | z(z), |
| 125 | w(w) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | // copy & move & assign & move assign |
| 130 | inline constexpr Vector4(const Vector4& other) SKR_NOEXCEPT = default; |
| 131 | inline constexpr Vector4(Vector4&& other) SKR_NOEXCEPT = default; |
| 132 | inline constexpr Vector4& operator=(const Vector4& other) SKR_NOEXCEPT = default; |
| 133 | inline constexpr Vector4& operator=(Vector4&& other) SKR_NOEXCEPT = default; |
| 134 | |
| 135 | // integrate to vector3 |
| 136 | inline constexpr Vector4(const Vector3& xyz, float w) SKR_NOEXCEPT |
| 137 | : x(xyz.x), |
| 138 | y(xyz.y), |
| 139 | z(xyz.z), |
| 140 | w(w) |
| 141 | { |
| 142 | } |
| 143 | inline constexpr operator Vector3() |
| 144 | { |
| 145 | return Vector3(x, y, z); |
| 146 | } |
| 147 | |
| 148 | // compare |
| 149 | inline constexpr bool operator==(const Vector4& other) const SKR_NOEXCEPT { return x == other.x && y == other.y && z == other.z && w == other.w; } |
| 150 | inline constexpr bool operator!=(const Vector4& other) const SKR_NOEXCEPT { return !(*this == other); } |
| 151 | |
| 152 | // arithmetic ops |
| 153 | inline Vector4 operator-() const SKR_NOEXCEPT { return Vector4(-x, -y, -z, -w); } |
| 154 | |
| 155 | friend inline Vector4 operator+(const Vector4& lhs, float rhs) SKR_NOEXCEPT { return Vector4(lhs.x + rhs, lhs.y + rhs, lhs.z + rhs, lhs.w + rhs); } |
| 156 | friend inline Vector4 operator-(const Vector4& lhs, float rhs) SKR_NOEXCEPT { return Vector4(lhs.x - rhs, lhs.y - rhs, lhs.z - rhs, lhs.w - rhs); } |
| 157 | friend inline Vector4 operator*(const Vector4& lhs, float rhs) SKR_NOEXCEPT { return Vector4(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs, lhs.w * rhs); } |
| 158 | friend inline Vector4 operator/(const Vector4& lhs, float rhs) SKR_NOEXCEPT { return Vector4(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs, lhs.w / rhs); } |
| 159 | friend inline Vector4 operator%(const Vector4& lhs, float rhs) SKR_NOEXCEPT { return Vector4(::std::fmod(lhs.x, rhs), ::std::fmod(lhs.y, rhs), ::std::fmod(lhs.z, rhs), ::std::fmod(lhs.w, rhs)); } |
| 160 | |
| 161 | friend inline Vector4 operator+(float lhs, const Vector4& rhs) SKR_NOEXCEPT { return Vector4(lhs + rhs.x, lhs + rhs.y, lhs + rhs.z, lhs + rhs.w); } |
| 162 | friend inline Vector4 operator-(float lhs, const Vector4& rhs) SKR_NOEXCEPT { return Vector4(lhs - rhs.x, lhs - rhs.y, lhs - rhs.z, lhs - rhs.w); } |