From bb31a1666f4dd681601ec2a01b9d07bf11de0814 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 9 Jun 2013 15:41:57 +0200 Subject: [PATCH] Added [Box|Rect]::Get[Maximum|Minimum]() Former-commit-id: 5226f2dfd2beaec2bc9075543f555cc48a457e3a --- include/Nazara/Math/Box.hpp | 2 ++ include/Nazara/Math/Box.inl | 13 +++++++++++++ include/Nazara/Math/Rect.hpp | 2 ++ include/Nazara/Math/Rect.inl | 13 +++++++++++++ src/Nazara/Renderer/DebugDrawer.cpp | 4 ++-- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index 9c6f97ad0..feb16a81b 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -41,6 +41,8 @@ class NzBox NzVector3 GetCorner(nzCorner corner) const; NzVector3 GetCenter() const; NzVector3 GetLengths() const; + NzVector3 GetMaximum() const; + NzVector3 GetMinimum() const; NzVector3 GetNegativeVertex(const NzVector3& normal) const; NzVector3 GetPosition() const; NzVector3 GetPositiveVertex(const NzVector3& normal) const; diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index e30297f7a..bd6f8cc7a 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -168,6 +168,19 @@ NzVector3 NzBox::GetLengths() const return NzVector3(width, height, depth); } +template +NzVector3 NzBox::GetMaximum() const +{ + return GetPosition() + GetLengths(); +} + +template +NzVector3 NzBox::GetMinimum() const +{ + ///DOC: Alias de GetPosition() + return GetPosition(); +} + template NzVector3 NzBox::GetNegativeVertex(const NzVector3& normal) const { diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index e9a808b72..b899e9bf0 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -34,6 +34,8 @@ class NzRect NzVector2 GetCenter() const; NzVector2 GetLengths() const; + NzVector2 GetMaximum() const; + NzVector2 GetMinimum() const; NzVector2 GetNegativeVertex(const NzVector2& normal) const; NzVector2 GetPosition() const; NzVector2 GetPositiveVertex(const NzVector2& normal) const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 089710fe6..981c5fba5 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -115,6 +115,19 @@ NzVector2 NzRect::GetLengths() const return NzVector2(width, height); } +template +NzVector2 NzRect::GetMaximum() const +{ + return GetPosition() + GetLengths(); +} + +template +NzVector2 NzRect::GetMinimum() const +{ + ///DOC: Alias de GetPosition() + return GetPosition(); +} + template NzVector2 NzRect::GetNegativeVertex(const NzVector2& normal) const { diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 6e6af4d7e..0f20549b0 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -63,8 +63,8 @@ void NzDebugDrawer::Draw(const NzBoxf& box) NzVertexStruct_XYZ* vertex = reinterpret_cast(mapper.GetPointer()); NzVector3f max, min; - max = box.GetPosition() + box.GetLengths(); - min = box.GetPosition(); + max = box.GetMaximum(); + min = box.GetMinimum(); vertex->position.Set(min.x, min.y, min.z); vertex++;