Reintroduce Vector comparison operator
Since it can be used for integer vector, also fixed comparison technique. Former-commit-id: 3a193ed21beb4d9b7d311eb29bc2852b0776a41c
This commit is contained in:
parent
5c7a9e1011
commit
437c7047c9
|
|
@ -79,6 +79,10 @@ class NzVector2
|
||||||
|
|
||||||
bool operator==(const NzVector2& vec) const;
|
bool operator==(const NzVector2& vec) const;
|
||||||
bool operator!=(const NzVector2& vec) const;
|
bool operator!=(const NzVector2& vec) const;
|
||||||
|
bool operator<(const NzVector2& vec) const;
|
||||||
|
bool operator<=(const NzVector2& vec) const;
|
||||||
|
bool operator>(const NzVector2& vec) const;
|
||||||
|
bool operator>=(const NzVector2& vec) const;
|
||||||
|
|
||||||
static NzVector2 Lerp(const NzVector2& from, const NzVector2& to, T interpolation);
|
static NzVector2 Lerp(const NzVector2& from, const NzVector2& to, T interpolation);
|
||||||
static NzVector2 UnitX();
|
static NzVector2 UnitX();
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,33 @@ bool NzVector2<T>::operator!=(const NzVector2& vec) const
|
||||||
return !operator==(vec);
|
return !operator==(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector2<T>::operator<(const NzVector2& vec) const
|
||||||
|
{
|
||||||
|
if (x == vec.x)
|
||||||
|
return y < vec.y;
|
||||||
|
else
|
||||||
|
return x < vec.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector2<T>::operator<=(const NzVector2& vec) const
|
||||||
|
{
|
||||||
|
return operator<(vec) || operator==(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector2<T>::operator>(const NzVector2& vec) const
|
||||||
|
{
|
||||||
|
return !operator<=(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector2<T>::operator>=(const NzVector2& vec) const
|
||||||
|
{
|
||||||
|
return !operator<(vec);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzVector2<T> NzVector2<T>::Lerp(const NzVector2& from, const NzVector2& to, T interpolation)
|
NzVector2<T> NzVector2<T>::Lerp(const NzVector2& from, const NzVector2& to, T interpolation)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,10 @@ template<typename T> class NzVector3
|
||||||
|
|
||||||
bool operator==(const NzVector3& vec) const;
|
bool operator==(const NzVector3& vec) const;
|
||||||
bool operator!=(const NzVector3& vec) const;
|
bool operator!=(const NzVector3& vec) const;
|
||||||
|
bool operator<(const NzVector3& vec) const;
|
||||||
|
bool operator<=(const NzVector3& vec) const;
|
||||||
|
bool operator>(const NzVector3& vec) const;
|
||||||
|
bool operator>=(const NzVector3& vec) const;
|
||||||
|
|
||||||
static NzVector3 CrossProduct(const NzVector3& vec1, const NzVector3& vec2);
|
static NzVector3 CrossProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||||
static T DotProduct(const NzVector3& vec1, const NzVector3& vec2);
|
static T DotProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,38 @@ bool NzVector3<T>::operator!=(const NzVector3& vec) const
|
||||||
return !operator==(vec);
|
return !operator==(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector3<T>::operator<(const NzVector3& vec) const
|
||||||
|
{
|
||||||
|
if (x == vec.x)
|
||||||
|
{
|
||||||
|
if (y < vec.y)
|
||||||
|
return z < vec.z;
|
||||||
|
else
|
||||||
|
return y < vec.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return x < vec.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector3<T>::operator<=(const NzVector3& vec) const
|
||||||
|
{
|
||||||
|
return operator<(vec) || operator==(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector3<T>::operator>(const NzVector3& vec) const
|
||||||
|
{
|
||||||
|
return !operator<=(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector3<T>::operator>=(const NzVector3& vec) const
|
||||||
|
{
|
||||||
|
return !operator<(vec);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzVector3<T> NzVector3<T>::CrossProduct(const NzVector3& vec1, const NzVector3& vec2)
|
NzVector3<T> NzVector3<T>::CrossProduct(const NzVector3& vec1, const NzVector3& vec2)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,10 @@ template<typename T> class NzVector4
|
||||||
|
|
||||||
bool operator==(const NzVector4& vec) const;
|
bool operator==(const NzVector4& vec) const;
|
||||||
bool operator!=(const NzVector4& vec) const;
|
bool operator!=(const NzVector4& vec) const;
|
||||||
|
bool operator<(const NzVector4& vec) const;
|
||||||
|
bool operator<=(const NzVector4& vec) const;
|
||||||
|
bool operator>(const NzVector4& vec) const;
|
||||||
|
bool operator>=(const NzVector4& vec) const;
|
||||||
|
|
||||||
static NzVector4 UnitX();
|
static NzVector4 UnitX();
|
||||||
static NzVector4 UnitY();
|
static NzVector4 UnitY();
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,43 @@ bool NzVector4<T>::operator!=(const NzVector4& vec) const
|
||||||
return !operator==(vec);
|
return !operator==(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector4<T>::operator<(const NzVector4& vec) const
|
||||||
|
{
|
||||||
|
if (x == vec.x)
|
||||||
|
{
|
||||||
|
if (y == vec.y)
|
||||||
|
{
|
||||||
|
if (z == vec.z)
|
||||||
|
return w < vec.w;
|
||||||
|
else
|
||||||
|
return z < vec.z;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return y < vec.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return x < vec.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector4<T>::operator<=(const NzVector4& vec) const
|
||||||
|
{
|
||||||
|
return operator<(vec) || operator==(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector3<T>::operator>(const NzVector3& vec) const
|
||||||
|
{
|
||||||
|
return !operator<=(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzVector3<T>::operator>=(const NzVector3& vec) const
|
||||||
|
{
|
||||||
|
return !operator<(vec);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzVector4<T> NzVector4<T>::UnitX()
|
NzVector4<T> NzVector4<T>::UnitX()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue