diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index feb16a81b..d301d5cec 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -67,6 +67,7 @@ class NzBox NzString ToString() const; NzBox& Transform(const NzMatrix4& matrix, bool applyTranslation = true); + NzBox& Translate(const NzVector3& translation); T& operator[](unsigned int i); T operator[](unsigned int i) const; diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index bd6f8cc7a..b9387a262 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -397,6 +397,16 @@ NzBox& NzBox::Transform(const NzMatrix4& matrix, bool applyTranslation) return Set(center - halfSize, center + halfSize); } +template +NzBox& NzBox::Translate(const NzVector3& translation) +{ + x += translation.x; + y += translation.y; + z += translation.z; + + return *this; +} + template T& NzBox::operator[](unsigned int i) { diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index b899e9bf0..17a60778b 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -56,6 +56,8 @@ class NzRect NzString ToString() const; + NzRect& Translate(const NzVector2& translation); + T& operator[](unsigned int i); T operator[](unsigned int i) const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 981c5fba5..5973df9ef 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -281,6 +281,15 @@ NzString NzRect::ToString() const return ss << "Rect(" << x << ", " << y << ", " << width << ", " << height << ')'; } +template +NzRect& NzRect::Translate(const NzVector2& translation) +{ + x += translation.x; + y += translation.y; + + return *this; +} + template T& NzRect::operator[](unsigned int i) {