From 077c340ea29527998dd8131c71be3a29a3c05f56 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Tue, 11 May 2021 19:24:39 +0200 Subject: [PATCH] LibGfx: Add component wise * and / operators to Vector3 and Vector4 --- Userland/Libraries/LibGfx/Vector3.h | 10 ++++++++++ Userland/Libraries/LibGfx/Vector4.h | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Userland/Libraries/LibGfx/Vector3.h b/Userland/Libraries/LibGfx/Vector3.h index fee55ce59c..8e2d928acf 100644 --- a/Userland/Libraries/LibGfx/Vector3.h +++ b/Userland/Libraries/LibGfx/Vector3.h @@ -54,6 +54,16 @@ public: return Vector3(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z); } + constexpr Vector3 operator*(const Vector3& other) const + { + return Vector3(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z); + } + + constexpr Vector3 operator/(const Vector3& other) const + { + return Vector3(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z); + } + constexpr Vector3 operator*(T f) const { return Vector3(m_x * f, m_y * f, m_z * f); diff --git a/Userland/Libraries/LibGfx/Vector4.h b/Userland/Libraries/LibGfx/Vector4.h index 3b13c1678a..aacd0bf16c 100644 --- a/Userland/Libraries/LibGfx/Vector4.h +++ b/Userland/Libraries/LibGfx/Vector4.h @@ -59,6 +59,16 @@ public: return Vector4(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z, m_w - other.m_w); } + constexpr Vector4 operator*(const Vector4& other) const + { + return Vector4(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z, m_w * other.m_w); + } + + constexpr Vector4 operator/(const Vector4& other) const + { + return Vector4(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z, m_w / other.m_w); + } + constexpr Vector4 operator*(T f) const { return Vector4(m_x * f, m_y * f, m_z * f, m_w * f);