From 7f3c5ae18d3dcb985d752ea40a8174a1cc672efa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Oct 2022 00:00:35 +0200 Subject: [PATCH] - added a 'dot' function to DVector2 because using the '|' operator is not intuitive. --- source/common/utility/vectors.h | 5 +++++ source/core/fixedhorizon.h | 1 + source/core/intvec.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index 616f2a988..5a38fb8b5 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -272,6 +272,11 @@ struct TVector2 return X*other.X + Y*other.Y; } + vec_t dot(const TVector2 &other) const + { + return X*other.X + Y*other.Y; + } + // Returns the angle that the ray (0,0)-(X,Y) faces TAngle Angle() const; diff --git a/source/core/fixedhorizon.h b/source/core/fixedhorizon.h index 23058a840..c58475240 100644 --- a/source/core/fixedhorizon.h +++ b/source/core/fixedhorizon.h @@ -81,6 +81,7 @@ class fixedhoriz public: fixedhoriz() = default; fixedhoriz(const fixedhoriz &other) = default; + fixedhoriz& operator=(const fixedhoriz&) = default; // This class intentionally makes no allowances for implicit type conversions because those would render it ineffective. constexpr short asbuild() const { return FixedToInt(value); } diff --git a/source/core/intvec.h b/source/core/intvec.h index 6b9fd8b4d..4b99c5be7 100644 --- a/source/core/intvec.h +++ b/source/core/intvec.h @@ -13,6 +13,8 @@ struct vec2_t vec2_t() = default; vec2_t(const vec2_t&) = default; + vec2_t& operator=(const vec2_t&) = default; + vec2_t(int x, int y) : X(x), Y(y) {} vec2_t operator+(const vec2_t& other) const { return { X + other.X, Y + other.Y }; } vec2_t operator-(const vec2_t& other) const { return { X - other.X, Y - other.Y }; } @@ -36,6 +38,8 @@ struct vec3_t vec3_t() = default; vec3_t(const vec3_t&) = default; + vec3_t& operator=(const vec3_t&) = default; + vec3_t(int x, int y, int z) : X(x), Y(y), Z(z) {} vec3_t operator+(const vec3_t& other) const { return { X + other.X, Y + other.Y, Z + other.Z }; } vec3_t operator-(const vec3_t& other) const { return { X - other.X, Y - other.Y, Z - other.Z }; }