From 0063ca995037758846e52922792279c4d9a7569d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 18 Feb 2018 18:57:30 +0100 Subject: [PATCH] Math/VectorI: Remove array constructor --- ChangeLog.md | 1 + include/Nazara/Math/Matrix4.inl | 4 ++-- include/Nazara/Math/Vector2.hpp | 1 - include/Nazara/Math/Vector2.inl | 12 ------------ include/Nazara/Math/Vector3.hpp | 1 - include/Nazara/Math/Vector3.inl | 15 +++------------ include/Nazara/Math/Vector4.hpp | 1 - include/Nazara/Math/Vector4.inl | 14 +------------- tests/Engine/Math/Vector3.cpp | 3 +-- 9 files changed, 8 insertions(+), 44 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 346147435..6e2e4095c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -69,6 +69,7 @@ Nazara Engine: - Fix Window triggering KeyPressed event after triggering a resize/movement event on Windows - (WIP) Add support for materials and callbacks to Physics3D module. - PhysWorld3D class is now movable +- ⚠️ Removed array/pointer constructor from Vector classes Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index f259607a6..07eb86182 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -242,8 +242,8 @@ namespace Nz } #endif - const T* ptr = (&m11) + column*4; - return Vector4(ptr); + const T* ptr = &m11 + column * 4; + return Vector4(ptr[0], ptr[1], ptr[2], ptr[3]); } /*! diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index 5bb5573ba..d68268dbf 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -24,7 +24,6 @@ namespace Nz Vector2() = default; Vector2(T X, T Y); explicit Vector2(T scale); - explicit Vector2(const T vec[2]); template explicit Vector2(const Vector2& vec); Vector2(const Vector2& vec) = default; explicit Vector2(const Vector3& vec); diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index f3e6609bd..f88a82dbd 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -45,18 +45,6 @@ namespace Nz Set(scale); } - /*! - * \brief Constructs a Vector2 object from an array of two elements - * - * \param vec[2] vec[0] is X component and vec[1] is Y component - */ - - template - Vector2::Vector2(const T vec[2]) - { - Set(vec); - } - /*! * \brief Constructs a Vector2 object from another type of Vector2 * diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index acb87d6c1..bbc65cede 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -25,7 +25,6 @@ namespace Nz Vector3(T X, T Y, T Z); Vector3(T X, const Vector2& vec); explicit Vector3(T scale); - explicit Vector3(const T vec[3]); Vector3(const Vector2& vec, T Z = 0.0); template explicit Vector3(const Vector3& vec); Vector3(const Vector3& vec) = default; diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index b7a884749..38291fc12 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -58,17 +58,6 @@ namespace Nz Set(scale); } - /*! - * \brief Constructs a Vector3 object from an array of three elements - * - * \param vec[3] vec[0] is X component, vec[1] is Y component and vec[2] is Z component - */ - template - Vector3::Vector3(const T vec[3]) - { - Set(vec); - } - /*! * \brief Constructs a Vector3 object from a Vector2 and a component * @@ -522,7 +511,9 @@ namespace Nz template Vector3& Vector3::Set(const T vec[3]) { - std::memcpy(&x, vec, 3*sizeof(T)); + x = vec[0]; + y = vec[1]; + z = vec[2]; return *this; } diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index de04884e1..2c8005fc0 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -27,7 +27,6 @@ namespace Nz Vector4(T X, const Vector2& vec, T W); Vector4(T X, const Vector3& vec); explicit Vector4(T scale); - explicit Vector4(const T vec[4]); Vector4(const Vector2& vec, T Z = 0.0, T W = 1.0); Vector4(const Vector3& vec, T W = 1.0); template explicit Vector4(const Vector4& vec); diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 873cea235..ffaf284d2 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -17,7 +17,7 @@ namespace Nz { /*! - * \ingroup math + * \ingroup math * \class Nz::Vector4 * \brief Math class that represents an element of the three dimensional vector space with the notion of projectivity. When the fourth component is 1, it describes an 'usual' point and when it is 0, it represents the point at infinity */ @@ -90,18 +90,6 @@ namespace Nz Set(scale); } - /*! - * \brief Constructs a Vector4 object from an array of four elements - * - * \param vec[4] vec[0] is X component, vec[1] is Y component, vec[2] is Z component and vec[3] is W component - */ - - template - Vector4::Vector4(const T vec[4]) - { - Set(vec); - } - /*! * \brief Constructs a Vector4 object from a Vector2 and two components * diff --git a/tests/Engine/Math/Vector3.cpp b/tests/Engine/Math/Vector3.cpp index 2bcfbd361..faeb03cca 100644 --- a/tests/Engine/Math/Vector3.cpp +++ b/tests/Engine/Math/Vector3.cpp @@ -104,8 +104,7 @@ SCENARIO("Vector3", "[MATH][VECTOR3]") Nz::Vector2f unit = Nz::Vector2f::Unit(); Nz::Vector3f smaller(-1.f, unit); - float data[3] = { 1.f, unit.x, unit.y }; - Nz::Vector3f bigger(data); + Nz::Vector3f bigger(1.f, unit.x, unit.y); WHEN("We combine divisions and multiplications") {