Math: Remove all Set(class) methods

This commit is contained in:
Lynix 2019-12-10 09:49:40 +01:00
parent ef030ddaac
commit be8e89b228
30 changed files with 19 additions and 234 deletions

View File

@ -201,6 +201,7 @@ Nazara Engine:
- Add Flags<E>::Clear() helper method, to reset flags
- Add Flags<E>::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)

View File

@ -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<Matrix4d*>(state.ToUserdata(index)));
*mat = *static_cast<Matrix4d*>(state.ToUserdata(index));
return 1;
}

View File

@ -282,7 +282,7 @@ namespace Ndk
{
case 1:
if (lua.IsOfType(argIndex, "Matrix4"))
instance.Set(*static_cast<Nz::Matrix4d*>(lua.ToUserdata(argIndex)));
instance = *static_cast<Nz::Matrix4d*>(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;
}

View File

@ -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<T>& rect);
Box& Set(const Vector3<T>& lengths);
Box& Set(const Vector3<T>& vec1, const Vector3<T>& vec2);

View File

@ -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<typename T>
Box<T>& Box<T>::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

View File

@ -37,7 +37,6 @@ namespace Nz
EulerAngles& Set(T P, T Y, T R);
EulerAngles& Set(const T angles[3]);
template<AngleUnit Unit> EulerAngles& Set(const Angle<Unit, T>& angles);
EulerAngles& Set(const EulerAngles<T>& angles);
//EulerAngles& Set(const Matrix3<T>& mat);
EulerAngles& Set(const Quaternion<T>& quat);
template<typename U> EulerAngles& Set(const EulerAngles<U>& angles);

View File

@ -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<typename T>
EulerAngles<T>& EulerAngles<T>::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

View File

@ -52,7 +52,6 @@ namespace Nz
Frustum& operator=(const Frustum& other) = default;
Frustum& Set(const Frustum& frustum);
template<typename U> Frustum& Set(const Frustum<U>& frustum);
String ToString() const;

View File

@ -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<typename T>
Frustum<T>& Frustum<T>::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

View File

@ -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<T>& matrix);
Matrix4& Set(const Matrix4& matrix);
template<typename U> Matrix4& Set(const Matrix4<U>& matrix);
Matrix4& SetRotation(const Quaternion<T>& rotation);
Matrix4& SetScale(const Vector3<T>& scale);

View File

@ -55,9 +55,12 @@ namespace Nz
*/
template<typename T>
Matrix4<T>::Matrix4(const T matrix[16])
Matrix4<T>::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<typename T>
Matrix4<T>& Matrix4<T>::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<typename T>
Matrix4<T>& Matrix4<T>::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

View File

@ -36,7 +36,6 @@ namespace Nz
OrientedBox& Set(T X, T Y, T Z, T Width, T Height, T Depth);
OrientedBox& Set(const Box<T>& box);
OrientedBox& Set(const OrientedBox& orientedBox);
OrientedBox& Set(const Vector3<T>& vec1, const Vector3<T>& vec2);
template<typename U> OrientedBox& Set(const OrientedBox<U>& orientedBox);

View File

@ -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<typename T>
OrientedBox<T>& OrientedBox<T>::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

View File

@ -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<T>& Normal, T Distance);
Plane& Set(const Vector3<T>& Normal, const Vector3<T>& point);
Plane& Set(const Vector3<T>& point1, const Vector3<T>& point2, const Vector3<T>& point3);

View File

@ -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<typename T>
Plane<T>& Plane<T>::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

View File

@ -56,7 +56,6 @@ namespace Nz
Quaternion& Set(T angle, const Vector3<T>& normalizedAxis);
Quaternion& Set(const T quat[4]);
//Quaternion& Set(const Matrix3<T>& mat);
Quaternion& Set(const Quaternion& quat);
template<typename U> Quaternion& Set(const Quaternion<U>& quat);
T SquaredMagnitude() const;

View File

@ -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<typename T>
Quaternion<T>& Quaternion<T>::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

View File

@ -54,7 +54,6 @@ namespace Nz
Ray& Set(const Vector3<T>& origin, const Vector3<T>& direction);
Ray& Set(const T origin[3], const T direction[3]);
Ray& Set(const Plane<T>& planeOne, const Plane<T>& planeTwo);
Ray& Set(const Ray& ray);
template<typename U> Ray& Set(const Ray<U>& ray);
template<typename U> Ray& Set(const Vector3<U>& origin, const Vector3<U>& direction);

View File

@ -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<typename T>
Ray<T>& Ray<T>::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

View File

@ -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<T>& rect);
Rect& Set(const Vector2<T>& lengths);
Rect& Set(const Vector2<T>& vec1, const Vector2<T>& vec2);
template<typename U> Rect& Set(const Rect<U>& rect);

View File

@ -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<typename T>
Rect<T>& Rect<T>::Set(const Rect<T>& 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

View File

@ -53,7 +53,6 @@ namespace Nz
Sphere& Set(T X, T Y, T Z, T Radius);
//Sphere& Set(const Circle<T>& rect);
Sphere& Set(const Sphere& sphere);
Sphere& Set(const Vector3<T>& center, T Radius);
Sphere& Set(const T sphere[4]);
template<typename U> Sphere& Set(const Sphere<U>& sphere);

View File

@ -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<typename T>
Sphere<T>& Sphere<T>::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

View File

@ -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<T>& vec);
Vector2& Set(const Vector4<T>& vec);
template<typename U> Vector2& Set(const Vector2<U>& vec);

View File

@ -367,22 +367,8 @@ namespace Nz
template<typename T>
Vector2<T>& Vector2<T>::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<typename T>
Vector2<T>& Vector2<T>::Set(const Vector2& vec)
{
std::memcpy(this, &vec, sizeof(Vector2));
x = vec[0];
y = vec[1];
return *this;
}

View File

@ -67,7 +67,6 @@ namespace Nz
Vector3& Set(T scale);
Vector3& Set(const T vec[3]);
Vector3& Set(const Vector2<T>& vec, T Z = 0.0);
Vector3& Set(const Vector3<T>& vec);
template<typename U> Vector3& Set(const Vector3<U>& vec);
Vector3& Set(const Vector4<T>& vec);

View File

@ -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<typename T>
Vector3<T>& Vector3<T>::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

View File

@ -57,7 +57,6 @@ namespace Nz
Vector4& Set(const T vec[4]);
Vector4& Set(const Vector2<T>& vec, T Z = 0.0, T W = 1.0);
Vector4& Set(const Vector3<T>& vec, T W = 1.0);
Vector4& Set(const Vector4<T>& vec);
template<typename U> Vector4& Set(const Vector4<U>& vec);
String ToString() const;

View File

@ -417,7 +417,10 @@ namespace Nz
template<typename T>
Vector4<T>& Vector4<T>::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<typename T>
Vector4<T>& Vector4<T>::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

View File

@ -444,6 +444,6 @@ namespace Nz
NazaraUnused(threadIndex);
RigidBody3D* me = static_cast<RigidBody3D*>(NewtonBodyGetUserData(body));
me->m_matrix.Set(matrix);
me->m_matrix = matrix;
}
}