Commit 0a316fd0 authored by hybrid's avatar hybrid

Add equals method.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2837 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b56ddb92
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef __IRR_MATRIX_H_INCLUDED__ #ifndef __IRR_MATRIX_H_INCLUDED__
#define __IRR_MATRIX_H_INCLUDED__ #define __IRR_MATRIX_H_INCLUDED__
#include "irrTypes.h" #include "irrMath.h"
#include "vector3d.h" #include "vector3d.h"
#include "vector2d.h" #include "vector2d.h"
#include "plane3d.h" #include "plane3d.h"
...@@ -323,12 +323,11 @@ namespace core ...@@ -323,12 +323,11 @@ namespace core
\param axis: axis to rotate about \param axis: axis to rotate about
\param from: source vector to rotate from \param from: source vector to rotate from
*/ */
void buildAxisAlignedBillboard( const core::vector3df& camPos, void buildAxisAlignedBillboard(const core::vector3df& camPos,
const core::vector3df& center, const core::vector3df& center,
const core::vector3df& translation, const core::vector3df& translation,
const core::vector3df& axis, const core::vector3df& axis,
const core::vector3df& from const core::vector3df& from);
);
/* /*
construct 2D Texture transformations construct 2D Texture transformations
...@@ -384,6 +383,9 @@ namespace core ...@@ -384,6 +383,9 @@ namespace core
//! Gets if the matrix is definitely identity matrix //! Gets if the matrix is definitely identity matrix
bool getDefinitelyIdentityMatrix() const; bool getDefinitelyIdentityMatrix() const;
//! Compare two matrices using the equal method
bool equals(const core::CMatrix4<T>& other, const T tolerance=(T)ROUNDING_ERROR_f64) const;
private: private:
//! Matrix data, stored in row-major order //! Matrix data, stored in row-major order
T M[16]; T M[16];
...@@ -938,10 +940,10 @@ namespace core ...@@ -938,10 +940,10 @@ namespace core
if (definitelyIdentityMatrix) if (definitelyIdentityMatrix)
return true; return true;
#endif #endif
if (!equals( M[ 0], (T)1 ) || if (!core::equals( M[ 0], (T)1 ) ||
!equals( M[ 5], (T)1 ) || !core::equals( M[ 5], (T)1 ) ||
!equals( M[10], (T)1 ) || !core::equals( M[10], (T)1 ) ||
!equals( M[15], (T)1 )) !core::equals( M[15], (T)1 ))
return false; return false;
for (s32 i=0; i<4; ++i) for (s32 i=0; i<4; ++i)
...@@ -2090,6 +2092,22 @@ namespace core ...@@ -2090,6 +2092,22 @@ namespace core
} }
//! Compare two matrices using the equal method
template <class T>
inline bool CMatrix4<T>::equals(const core::CMatrix4<T>& other, const T tolerance) const
{
#if defined ( USE_MATRIX_TEST )
if (definitelyIdentityMatrix && other.definitelyIdentityMatrix)
return true;
#endif
for (s32 i = 0; i < 16; ++i)
if (!core::equals(M[i],other.M[i], tolerance))
return false;
return true;
}
// Multiply by scalar. // Multiply by scalar.
template <class T> template <class T>
inline CMatrix4<T> operator*(const T scalar, const CMatrix4<T>& mat) inline CMatrix4<T> operator*(const T scalar, const CMatrix4<T>& mat)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment