Update vector.h

This commit is contained in:
s1lent 2019-08-14 01:13:26 +07:00
parent 7420ba158a
commit f96ca908db
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C

View File

@ -64,12 +64,14 @@ public:
decltype(auto) operator/(float fl) const { return Vector2D(x / fl, y / fl); } decltype(auto) operator/(float fl) const { return Vector2D(x / fl, y / fl); }
#endif #endif
decltype(auto) operator=(std::nullptr_t) { return Vector2D(0, 0); }
decltype(auto) operator+=(float fl) { return (*this = *this + fl); } decltype(auto) operator+=(float fl) { return (*this = *this + fl); }
decltype(auto) operator-=(float fl) { return (*this = *this - fl); } decltype(auto) operator-=(float fl) { return (*this = *this - fl); }
decltype(auto) operator*=(float fl) { return (*this = *this * fl); } decltype(auto) operator*=(float fl) { return (*this = *this * fl); }
decltype(auto) operator/=(float fl) { return (*this = *this / fl); } decltype(auto) operator/=(float fl) { return (*this = *this / fl); }
// Methods // Methods
inline void Clear() { x = 0; y = 0; }
inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; } inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; }
inline real_t Length() const { return Q_sqrt(real_t(x * x + y * y)); } // Get the vector's magnitude inline real_t Length() const { return Q_sqrt(real_t(x * x + y * y)); } // Get the vector's magnitude
inline float LengthSquared() const { return (x * x + y * y); } // Get the vector's magnitude squared inline float LengthSquared() const { return (x * x + y * y); } // Get the vector's magnitude squared
@ -166,11 +168,20 @@ public:
decltype(auto) operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); } decltype(auto) operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); }
#endif #endif
decltype(auto) operator=(std::nullptr_t) { return Vector(0, 0, 0); }
decltype(auto) operator+=(float fl) { return (*this = *this + fl); } decltype(auto) operator+=(float fl) { return (*this = *this + fl); }
decltype(auto) operator-=(float fl) { return (*this = *this - fl); } decltype(auto) operator-=(float fl) { return (*this = *this - fl); }
decltype(auto) operator*=(float fl) { return (*this = *this * fl); } decltype(auto) operator*=(float fl) { return (*this = *this * fl); }
decltype(auto) operator/=(float fl) { return (*this = *this / fl); } decltype(auto) operator/=(float fl) { return (*this = *this / fl); }
// Methods
void Clear()
{
x = 0;
y = 0;
z = 0;
}
void CopyToArray(float *rgfl) const void CopyToArray(float *rgfl) const
{ {
*(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[0] = *(int *)&x;