diff --git a/ChangeLog.md b/ChangeLog.md index b2f87f16a..5a7a81ea1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -201,6 +201,7 @@ Nazara Engine: - Add Flags::Clear() helper method, to reset flags - Add Flags::Set(Flags) helper method, to enable flags - ⚠ Constraint2D are no longer managed by references and are now handled objects +- ⚠ Removed all Set methods from math classes taking their own type (e.g. Box::Set(Box)) Nazara Development Kit: - Added ImageWidget (#139) diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index e2b1095dc..01c797e89 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -125,14 +125,14 @@ namespace Nz state.Pop(); } - mat->Set(values); + *mat = Matrix4d(values); return 1; } default: { if (state.IsOfType(index, "Matrix4")) - mat->Set(*static_cast(state.ToUserdata(index))); + *mat = *static_cast(state.ToUserdata(index)); return 1; } diff --git a/SDK/src/NDK/Lua/LuaBinding_Math.cpp b/SDK/src/NDK/Lua/LuaBinding_Math.cpp index c218c2a66..15deebfab 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Math.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Math.cpp @@ -282,7 +282,7 @@ namespace Ndk { case 1: if (lua.IsOfType(argIndex, "Matrix4")) - instance.Set(*static_cast(lua.ToUserdata(argIndex))); + instance = *static_cast(lua.ToUserdata(argIndex)); break; case 16: @@ -291,7 +291,7 @@ namespace Ndk for (std::size_t i = 0; i < 16; ++i) values[i] = lua.CheckNumber(argIndex++); - instance.Set(values); + instance = Nz::Matrix4d(values); return 0; } diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index 555e10130..e9e57c8f0 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -63,7 +63,6 @@ namespace Nz Box& Set(T Width, T Height, T Depth); Box& Set(T X, T Y, T Z, T Width, T Height, T Depth); Box& Set(const T box[6]); - Box& Set(const Box& box); Box& Set(const Rect& rect); Box& Set(const Vector3& lengths); Box& Set(const Vector3& vec1, const Vector3& vec2); diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 6b0ed9112..6055b3444 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -585,21 +585,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the box with components from another - * \return A reference to this box - * - * \param box The other box - */ - - template - Box& Box::Set(const Box& box) - { - std::memcpy(this, &box, sizeof(Box)); - - return *this; - } - /*! * \brief Sets the components of the box with components from a Rect * \return A reference to this box diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index 0079d2f6a..503a0fb94 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -37,7 +37,6 @@ namespace Nz EulerAngles& Set(T P, T Y, T R); EulerAngles& Set(const T angles[3]); template EulerAngles& Set(const Angle& angles); - EulerAngles& Set(const EulerAngles& angles); //EulerAngles& Set(const Matrix3& mat); EulerAngles& Set(const Quaternion& quat); template EulerAngles& Set(const EulerAngles& angles); diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 52c2e4b41..00f78bf27 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -169,20 +169,6 @@ namespace Nz return Set(angle.ToEulerAngles()); } - /*! - * \brief Sets the components of the euler angle from another euler angle - * \return A reference to this euler angle - * - * \param angles The other euler angle - */ - template - EulerAngles& EulerAngles::Set(const EulerAngles& angles) - { - std::memcpy(this, &angles, sizeof(EulerAngles)); - - return *this; - } - /*! * \brief Sets the components of the euler angle from a quaternion * \return A reference to this euler angle diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index 042d55cee..f1b37811a 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -52,7 +52,6 @@ namespace Nz Frustum& operator=(const Frustum& other) = default; - Frustum& Set(const Frustum& frustum); template Frustum& Set(const Frustum& frustum); String ToString() const; diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 6d6d38500..36a13a316 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -623,21 +623,6 @@ namespace Nz return (c == 6) ? IntersectionSide_Inside : IntersectionSide_Intersecting; } - /*! - * \brief Sets the components of the frustum from another frustum - * \return A reference to this frustum - * - * \param frustum The other frustum - */ - - template - Frustum& Frustum::Set(const Frustum& frustum) - { - std::memcpy(this, &frustum, sizeof(Frustum)); - - return *this; - } - /*! * \brief Sets the components of the frustum from another type of Frustum * \return A reference to this frustum diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index cb8667036..5a0e1808f 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -82,9 +82,7 @@ namespace Nz T r21, T r22, T r23, T r24, T r31, T r32, T r33, T r34, T r41, T r42, T r43, T r44); - Matrix4& Set(const T matrix[16]); //Matrix4(const Matrix3& matrix); - Matrix4& Set(const Matrix4& matrix); template Matrix4& Set(const Matrix4& matrix); Matrix4& SetRotation(const Quaternion& rotation); Matrix4& SetScale(const Vector3& scale); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 297edf8a8..48d99f21e 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -55,9 +55,12 @@ namespace Nz */ template - Matrix4::Matrix4(const T matrix[16]) + Matrix4::Matrix4(const T matrix[16]) : + Matrix4(matrix[ 0], matrix[ 1], matrix[ 2], matrix[ 3], + matrix[ 4], matrix[ 5], matrix[ 6], matrix[ 7], + matrix[ 8], matrix[ 9], matrix[10], matrix[11], + matrix[12], matrix[13], matrix[14], matrix[15]) { - Set(matrix); } /*! @@ -448,7 +451,7 @@ namespace Nz for (unsigned int i = 0; i < 16; ++i) inv[i] *= invDet; - dest->Set(inv); + *dest = inv; return true; } else @@ -550,7 +553,7 @@ namespace Nz inv[15] = F(1.0); - dest->Set(inv); + *dest = inv; return true; } else @@ -1097,37 +1100,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the matrix from an array of sixteen elements - * \return A reference to this matrix - * - * \param matrix[16] Matrix components - */ - - template - Matrix4& Matrix4::Set(const T matrix[16]) - { - // Here we are confident of the continuity of memory elements - std::memcpy(&m11, matrix, 16 * sizeof(T)); - - return *this; - } - - /*! - * \brief Sets the components of the matrix from another matrix - * \return A reference to this matrix - * - * \param matrix The other matrix - */ - - template - Matrix4& Matrix4::Set(const Matrix4& matrix) - { - std::memcpy(this, &matrix, sizeof(Matrix4)); - - return *this; - } - /*! * \brief Sets the components of the matrix from another type of Matrix4 * \return A reference to this matrix diff --git a/include/Nazara/Math/OrientedBox.hpp b/include/Nazara/Math/OrientedBox.hpp index ab136a530..dbc1820c5 100644 --- a/include/Nazara/Math/OrientedBox.hpp +++ b/include/Nazara/Math/OrientedBox.hpp @@ -36,7 +36,6 @@ namespace Nz OrientedBox& Set(T X, T Y, T Z, T Width, T Height, T Depth); OrientedBox& Set(const Box& box); - OrientedBox& Set(const OrientedBox& orientedBox); OrientedBox& Set(const Vector3& vec1, const Vector3& vec2); template OrientedBox& Set(const OrientedBox& orientedBox); diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index df864fe26..7e561eb41 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -164,21 +164,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the oriented box with components from another - * \return A reference to this oriented box - * - * \param orientedBox The other OrientedBox - */ - - template - OrientedBox& OrientedBox::Set(const OrientedBox& orientedBox) - { - std::memcpy(this, &orientedBox, sizeof(OrientedBox)); - - return *this; - } - /*! * \brief Sets a OrientedBox object from two vectors representing point of the space * (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum diff --git a/include/Nazara/Math/Plane.hpp b/include/Nazara/Math/Plane.hpp index d5384b3fe..0f0dbd5f0 100644 --- a/include/Nazara/Math/Plane.hpp +++ b/include/Nazara/Math/Plane.hpp @@ -37,7 +37,6 @@ namespace Nz Plane& Set(T normalX, T normalY, T normalZ, T Distance); Plane& Set(const T plane[4]); - Plane& Set(const Plane& plane); Plane& Set(const Vector3& Normal, T Distance); Plane& Set(const Vector3& Normal, const Vector3& point); Plane& Set(const Vector3& point1, const Vector3& point2, const Vector3& point3); diff --git a/include/Nazara/Math/Plane.inl b/include/Nazara/Math/Plane.inl index 4c2adc90c..7430b4dca 100644 --- a/include/Nazara/Math/Plane.inl +++ b/include/Nazara/Math/Plane.inl @@ -212,21 +212,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the plane from another plane - * \return A reference to this plane - * - * \param plane The other plane - */ - - template - Plane& Plane::Set(const Plane& plane) - { - std::memcpy(this, &plane, sizeof(Plane)); - - return *this; - } - /*! * \brief Sets the components of the plane from a normal and a distance * \return A reference to this plane diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index 16e88b8ef..991b23b94 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -56,7 +56,6 @@ namespace Nz Quaternion& Set(T angle, const Vector3& normalizedAxis); Quaternion& Set(const T quat[4]); //Quaternion& Set(const Matrix3& mat); - Quaternion& Set(const Quaternion& quat); template Quaternion& Set(const Quaternion& quat); T SquaredMagnitude() const; diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index f253d7d6b..6d8937566 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -430,21 +430,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the quaternion from another quaternion - * \return A reference to this quaternion - * - * \param quat The other quaternion - */ - - template - Quaternion& Quaternion::Set(const Quaternion& quat) - { - std::memcpy(this, &quat, sizeof(Quaternion)); - - return *this; - } - /*! * \brief Sets the components of the quaternion from another type of Quaternion * \return A reference to this quaternion diff --git a/include/Nazara/Math/Ray.hpp b/include/Nazara/Math/Ray.hpp index 677bf50b9..8429e7dc8 100644 --- a/include/Nazara/Math/Ray.hpp +++ b/include/Nazara/Math/Ray.hpp @@ -54,7 +54,6 @@ namespace Nz Ray& Set(const Vector3& origin, const Vector3& direction); Ray& Set(const T origin[3], const T direction[3]); Ray& Set(const Plane& planeOne, const Plane& planeTwo); - Ray& Set(const Ray& ray); template Ray& Set(const Ray& ray); template Ray& Set(const Vector3& origin, const Vector3& direction); diff --git a/include/Nazara/Math/Ray.inl b/include/Nazara/Math/Ray.inl index 673dca796..f2248baca 100644 --- a/include/Nazara/Math/Ray.inl +++ b/include/Nazara/Math/Ray.inl @@ -593,21 +593,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the ray with components from another - * \return A reference to this ray - * - * \param ray The other ray - */ - - template - Ray& Ray::Set(const Ray& ray) - { - std::memcpy(this, &ray, sizeof(Ray)); - - return *this; - } - /*! * \brief Sets the components of the ray from another type of Ray * \return A reference to this ray diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index db7ee15f0..edad69493 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -55,7 +55,6 @@ namespace Nz Rect& Set(T Width, T Height); Rect& Set(T X, T Y, T Width, T Height); Rect& Set(const T rect[4]); - Rect& Set(const Rect& rect); Rect& Set(const Vector2& lengths); Rect& Set(const Vector2& vec1, const Vector2& vec2); template Rect& Set(const Rect& rect); diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 93b6e6d79..20181a763 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -475,21 +475,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the rectangle with components from another - * \return A reference to this rectangle - * - * \param rect The other Rect - */ - - template - Rect& Rect::Set(const Rect& rect) - { - std::memcpy(this, &rect, sizeof(Rect)); - - return *this; - } - /*! * \brief Sets the components of the rectange from a vector representing width and height * \return A reference to this rectangle diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 0c9880287..762a276dc 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -53,7 +53,6 @@ namespace Nz Sphere& Set(T X, T Y, T Z, T Radius); //Sphere& Set(const Circle& rect); - Sphere& Set(const Sphere& sphere); Sphere& Set(const Vector3& center, T Radius); Sphere& Set(const T sphere[4]); template Sphere& Set(const Sphere& sphere); diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 643fcee82..c9ac33414 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -397,21 +397,6 @@ namespace Nz } */ - /*! - * \brief Sets the components of the sphere with center and radius from another - * \return A reference to this sphere - * - * \param sphere The other sphere - */ - - template - Sphere& Sphere::Set(const Sphere& sphere) - { - std::memcpy(this, &sphere, sizeof(Sphere)); - - return *this; - } - /*! * \brief Sets the components of the sphere from an array of four elements * \return A reference to this sphere diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index d8a53eb47..fa41597a1 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -55,7 +55,6 @@ namespace Nz Vector2& Set(T X, T Y); Vector2& Set(T scale); Vector2& Set(const T vec[2]); - Vector2& Set(const Vector2& vec); Vector2& Set(const Vector3& vec); Vector2& Set(const Vector4& vec); template Vector2& Set(const Vector2& vec); diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 15739b024..d1724f838 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -367,22 +367,8 @@ namespace Nz template Vector2& Vector2::Set(const T vec[2]) { - std::memcpy(&x, vec, 2*sizeof(T)); - - return *this; - } - - /*! - * \brief Sets the components of the vector from another vector - * \return A reference to this vector - * - * \param vec The other vector - */ - - template - Vector2& Vector2::Set(const Vector2& vec) - { - std::memcpy(this, &vec, sizeof(Vector2)); + x = vec[0]; + y = vec[1]; return *this; } diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index b46f2e40b..99e3696df 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -67,7 +67,6 @@ namespace Nz Vector3& Set(T scale); Vector3& Set(const T vec[3]); Vector3& Set(const Vector2& vec, T Z = 0.0); - Vector3& Set(const Vector3& vec); template Vector3& Set(const Vector3& vec); Vector3& Set(const Vector4& vec); diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 5a77c8e05..1dcf48fe7 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -523,20 +523,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the vector from another vector - * \return A reference to this vector - * - * \param vec The other vector - */ - template - Vector3& Vector3::Set(const Vector3& vec) - { - std::memcpy(this, &vec, sizeof(Vector3)); - - return *this; - } - /*! * \brief Sets the components of the vector from another type of Vector3 * \return A reference to this vector diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 7a34a6d11..2938df3bb 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -57,7 +57,6 @@ namespace Nz Vector4& Set(const T vec[4]); Vector4& Set(const Vector2& vec, T Z = 0.0, T W = 1.0); Vector4& Set(const Vector3& vec, T W = 1.0); - Vector4& Set(const Vector4& vec); template Vector4& Set(const Vector4& vec); String ToString() const; diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 8c602d214..6deadf5f5 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -417,7 +417,10 @@ namespace Nz template Vector4& Vector4::Set(const T vec[4]) { - std::memcpy(&x, vec, 4*sizeof(T)); + x = vec[0]; + y = vec[1]; + z = vec[2]; + w = vec[3]; return *this; } @@ -459,21 +462,6 @@ namespace Nz return *this; } - /*! - * \brief Sets the components of the vector from another vector - * \return A reference to this vector - * - * \param vec The other vector - */ - - template - Vector4& Vector4::Set(const Vector4& vec) - { - std::memcpy(this, &vec, sizeof(Vector4)); - - return *this; - } - /*! * \brief Sets the components of the vector from another type of Vector4 * \return A reference to this vector diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index ea6e58621..c18055f56 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -444,6 +444,6 @@ namespace Nz NazaraUnused(threadIndex); RigidBody3D* me = static_cast(NewtonBodyGetUserData(body)); - me->m_matrix.Set(matrix); + me->m_matrix = matrix; } }