From c940abdb756866085202283790b9165427d86d74 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 9 Jun 2013 15:34:36 +0200 Subject: [PATCH] Renamed [Box|Rect]::GetSize() to GetLengths() Former-commit-id: 3c122057634a6472034b284bfe7091acbb41d004 --- include/Nazara/Math/Box.hpp | 2 +- include/Nazara/Math/Box.inl | 18 +++++++++--------- include/Nazara/Math/Rect.hpp | 2 +- include/Nazara/Math/Rect.inl | 14 +++++++------- src/Nazara/Renderer/DebugDrawer.cpp | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index fa10186c6..9c6f97ad0 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -40,11 +40,11 @@ class NzBox NzSphere GetBoundingSphere() const; NzVector3 GetCorner(nzCorner corner) const; NzVector3 GetCenter() const; + NzVector3 GetLengths() const; NzVector3 GetNegativeVertex(const NzVector3& normal) const; NzVector3 GetPosition() const; NzVector3 GetPositiveVertex(const NzVector3& normal) const; T GetRadius() const; - NzVector3 GetSize() const; T GetSquaredRadius() const; bool Intersect(const NzBox& box, NzBox* intersection = nullptr) const; diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index c3930249e..e30297f7a 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -159,7 +159,13 @@ NzSphere NzBox::GetBoundingSphere() const template NzVector3 NzBox::GetCenter() const { - return GetPosition() + F(0.5)*GetSize(); + return GetPosition() + F(0.5)*GetLengths(); +} + +template +NzVector3 NzBox::GetLengths() const +{ + return NzVector3(width, height, depth); } template @@ -208,16 +214,10 @@ T NzBox::GetRadius() const return std::sqrt(GetSquaredRadius()); } -template -NzVector3 NzBox::GetSize() const -{ - return NzVector3(width, height, depth); -} - template T NzBox::GetSquaredRadius() const { - NzVector3 size(GetSize()); + NzVector3 size(GetLengths()); size *= F(0.5); // La taille étant relative à la position (minimum) de la boite et non pas à son centre return size.GetSquaredLength(); @@ -375,7 +375,7 @@ template NzBox& NzBox::Transform(const NzMatrix4& matrix, bool applyTranslation) { NzVector3 center = matrix.Transform(GetCenter(), (applyTranslation) ? F(1.0) : F(0.0)); // Valeur multipliant la translation - NzVector3 halfSize = GetSize() * F(0.5); + NzVector3 halfSize = GetLengths() * F(0.5); halfSize.Set(std::fabs(matrix(0,0))*halfSize.x + std::fabs(matrix(1,0))*halfSize.y + std::fabs(matrix(2,0))*halfSize.z, std::fabs(matrix(0,1))*halfSize.x + std::fabs(matrix(1,1))*halfSize.y + std::fabs(matrix(2,1))*halfSize.z, diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 3a9f0b64b..e9a808b72 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -33,10 +33,10 @@ class NzRect NzRect& ExtendTo(const NzRect& rect); NzVector2 GetCenter() const; + NzVector2 GetLengths() const; NzVector2 GetNegativeVertex(const NzVector2& normal) const; NzVector2 GetPosition() const; NzVector2 GetPositiveVertex(const NzVector2& normal) const; - NzVector2 GetSize() const; bool Intersect(const NzRect& rect, NzRect* intersection = nullptr) const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index df80185b2..089710fe6 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -106,7 +106,13 @@ NzRect& NzRect::ExtendTo(const NzRect& rect) template NzVector2 NzRect::GetCenter() const { - return NzVector2(x + width/F(2.0), y + height/F(2.0)); + return GetPosition() + F(0.5)*GetLengths(); +} + +template +NzVector2 NzRect::GetLengths() const +{ + return NzVector2(width, height); } template @@ -143,12 +149,6 @@ NzVector2 NzRect::GetPositiveVertex(const NzVector2& normal) const return pos; } -template -NzVector2 NzRect::GetSize() const -{ - return NzVector2(width, height); -} - template bool NzRect::Intersect(const NzRect& rect, NzRect* intersection) const { diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 482adc9b4..6e6af4d7e 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -63,7 +63,7 @@ void NzDebugDrawer::Draw(const NzBoxf& box) NzVertexStruct_XYZ* vertex = reinterpret_cast(mapper.GetPointer()); NzVector3f max, min; - max = box.GetPosition() + box.GetSize(); + max = box.GetPosition() + box.GetLengths(); min = box.GetPosition(); vertex->position.Set(min.x, min.y, min.z);