mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibGfx: Allow Vector{2,3,4} operators to accept different argument types
This is needed to e.g. multiply a Vector4<f32x4> by a float.
This commit is contained in:
parent
486d2d099c
commit
b07bb85700
3 changed files with 12 additions and 6 deletions
|
@ -60,12 +60,14 @@ public:
|
||||||
return Vector2(m_x / other.m_x, m_y / other.m_y);
|
return Vector2(m_x / other.m_x, m_y / other.m_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector2 operator*(T f) const
|
template<typename U>
|
||||||
|
constexpr Vector2 operator*(U f) const
|
||||||
{
|
{
|
||||||
return Vector2(m_x * f, m_y * f);
|
return Vector2(m_x * f, m_y * f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector2 operator/(T f) const
|
template<typename U>
|
||||||
|
constexpr Vector2 operator/(U f) const
|
||||||
{
|
{
|
||||||
return Vector2(m_x / f, m_y / f);
|
return Vector2(m_x / f, m_y / f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,12 +65,14 @@ public:
|
||||||
return Vector3(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z);
|
return Vector3(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector3 operator*(T f) const
|
template<typename U>
|
||||||
|
constexpr Vector3 operator*(U f) const
|
||||||
{
|
{
|
||||||
return Vector3(m_x * f, m_y * f, m_z * f);
|
return Vector3(m_x * f, m_y * f, m_z * f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector3 operator/(T f) const
|
template<typename U>
|
||||||
|
constexpr Vector3 operator/(U f) const
|
||||||
{
|
{
|
||||||
return Vector3(m_x / f, m_y / f, m_z / f);
|
return Vector3(m_x / f, m_y / f, m_z / f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,12 +70,14 @@ public:
|
||||||
return Vector4(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z, m_w / other.m_w);
|
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
|
template<typename U>
|
||||||
|
constexpr Vector4 operator*(U f) const
|
||||||
{
|
{
|
||||||
return Vector4(m_x * f, m_y * f, m_z * f, m_w * f);
|
return Vector4(m_x * f, m_y * f, m_z * f, m_w * f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector4 operator/(T f) const
|
template<typename U>
|
||||||
|
constexpr Vector4 operator/(U f) const
|
||||||
{
|
{
|
||||||
return Vector4(m_x / f, m_y / f, m_z / f, m_w / f);
|
return Vector4(m_x / f, m_y / f, m_z / f, m_w / f);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue