diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-09-28 15:56:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 15:56:29 +0200 |
commit | b07f020c99545b756cf58c20e47f06bdf3247ef5 (patch) | |
tree | e1975a2718b1ee85d646a8bca356e2be56f03450 /core/math | |
parent | bd12dc33d9991e69cc4cb9de187bca13d7108c58 (diff) | |
parent | e4942e4a96e6d53c6bf40c5602e29cd38595c2a9 (diff) |
Merge pull request #42133 from vnen/variant-op-consistency
Allow commutative multiplication in Variant
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/quat.h | 4 | ||||
-rw-r--r-- | core/math/vector2.h | 30 |
2 files changed, 33 insertions, 1 deletions
diff --git a/core/math/quat.h b/core/math/quat.h index 8619ea3c5c..3152b7d233 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -224,4 +224,8 @@ bool Quat::operator!=(const Quat &p_quat) const { return x != p_quat.x || y != p_quat.y || z != p_quat.z || w != p_quat.w; } +_FORCE_INLINE_ Quat operator*(const real_t &p_real, const Quat &p_quat) { + return p_quat * p_real; +} + #endif // QUAT_H diff --git a/core/math/vector2.h b/core/math/vector2.h index 0966d3392f..f41bcc15bc 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -150,7 +150,19 @@ _FORCE_INLINE_ Vector2 Vector2::plane_project(real_t p_d, const Vector2 &p_vec) return p_vec - *this * (dot(p_vec) - p_d); } -_FORCE_INLINE_ Vector2 operator*(real_t p_scalar, const Vector2 &p_vec) { +_FORCE_INLINE_ Vector2 operator*(float p_scalar, const Vector2 &p_vec) { + return p_vec * p_scalar; +} + +_FORCE_INLINE_ Vector2 operator*(double p_scalar, const Vector2 &p_vec) { + return p_vec * p_scalar; +} + +_FORCE_INLINE_ Vector2 operator*(int32_t p_scalar, const Vector2 &p_vec) { + return p_vec * p_scalar; +} + +_FORCE_INLINE_ Vector2 operator*(int64_t p_scalar, const Vector2 &p_vec) { return p_vec * p_scalar; } @@ -304,6 +316,22 @@ struct Vector2i { } }; +_FORCE_INLINE_ Vector2i operator*(const int32_t &p_scalar, const Vector2i &p_vector) { + return p_vector * p_scalar; +} + +_FORCE_INLINE_ Vector2i operator*(const int64_t &p_scalar, const Vector2i &p_vector) { + return p_vector * p_scalar; +} + +_FORCE_INLINE_ Vector2i operator*(const float &p_scalar, const Vector2i &p_vector) { + return p_vector * p_scalar; +} + +_FORCE_INLINE_ Vector2i operator*(const double &p_scalar, const Vector2i &p_vector) { + return p_vector * p_scalar; +} + typedef Vector2i Size2i; typedef Vector2i Point2i; |