diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index 073c946c7..65448c2c2 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -665,6 +665,7 @@ struct TVector3 template struct TVector4 { + typedef TVector2 Vector2; typedef TVector3 Vector3; vec_t X, Y, Z, W; @@ -723,6 +724,29 @@ struct TVector4 return X != other.X || Y != other.Y || Z != other.Z || W != other.W; } + // returns the XY fields as a 2D-vector. + const Vector2& XY() const + { + return *reinterpret_cast(this); + } + + Vector2& XY() + { + return *reinterpret_cast(this); + } + + // returns the XY fields as a 2D-vector. + const Vector3& XYZ() const + { + return *reinterpret_cast(this); + } + + Vector3& XYZ() + { + return *reinterpret_cast(this); + } + + // Test for approximate equality bool ApproximatelyEquals(const TVector4 &other) const { @@ -838,12 +862,6 @@ struct TVector4 return *this; } - // returns the XYZ fields as a 3D-vector. - Vector3 XYZ() const - { - return{ X, Y, Z }; - } - // Add a 4D vector and a 3D vector. friend TVector4 operator+ (const TVector4 &v4, const Vector3 &v3) { diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 1eba52cb6..3cfd61590 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -240,6 +240,16 @@ public: __int_vel = x; } + void set_float_bvel(DVector3 x) + { + __int_vel = { FloatToFixed(x.X), FloatToFixed(x.Y), FloatToFixed(x.Z) }; + } + + void set_float_bvel_xy(DVector2 x) + { + __int_vel.XY() = { FloatToFixed(x.X), FloatToFixed(x.Y) }; + } + void add_int_bvel_x(int x) { __int_vel .X += x;