Added [Box|Rect]::Translate
Former-commit-id: 72b4cd351a7233df89709366fbe7ce59e4ba94e7
This commit is contained in:
@@ -67,6 +67,7 @@ class NzBox
|
||||
NzString ToString() const;
|
||||
|
||||
NzBox& Transform(const NzMatrix4<T>& matrix, bool applyTranslation = true);
|
||||
NzBox& Translate(const NzVector3<T>& translation);
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
@@ -397,6 +397,16 @@ NzBox<T>& NzBox<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslation)
|
||||
return Set(center - halfSize, center + halfSize);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBox<T>& NzBox<T>::Translate(const NzVector3<T>& translation)
|
||||
{
|
||||
x += translation.x;
|
||||
y += translation.y;
|
||||
z += translation.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzBox<T>::operator[](unsigned int i)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,8 @@ class NzRect
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzRect& Translate(const NzVector2<T>& translation);
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
|
||||
@@ -281,6 +281,15 @@ NzString NzRect<T>::ToString() const
|
||||
return ss << "Rect(" << x << ", " << y << ", " << width << ", " << height << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::Translate(const NzVector2<T>& translation)
|
||||
{
|
||||
x += translation.x;
|
||||
y += translation.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzRect<T>::operator[](unsigned int i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user