Fixed discrepancy between compiler intrinsics mode and unparallelized mode. Also added const * *= operator to matrix.
This commit is contained in:
parent
b168289208
commit
2a505e0321
@ -2,7 +2,7 @@
|
||||
#include "Vector3.h"
|
||||
#include "Math.h"
|
||||
|
||||
#define _EULE_NO_INTRINSICS_
|
||||
//#define _EULE_NO_INTRINSICS_
|
||||
#ifndef _EULE_NO_INTRINSICS_
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
@ -404,6 +404,16 @@ bool Matrix4x4::operator!=(const Matrix4x4& other)
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool Matrix4x4::operator==(const Matrix4x4& other) const
|
||||
{
|
||||
return v == other.v;
|
||||
}
|
||||
|
||||
bool Matrix4x4::operator!=(const Matrix4x4& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
const Vector3d Matrix4x4::GetTranslationComponent() const
|
||||
{
|
||||
return Vector3d(d, h, l);
|
||||
|
@ -77,7 +77,9 @@ namespace Eule
|
||||
void operator=(Matrix4x4&& other) noexcept;
|
||||
|
||||
bool operator==(const Matrix4x4& other);
|
||||
bool operator==(const Matrix4x4& other) const;
|
||||
bool operator!=(const Matrix4x4& other);
|
||||
bool operator!=(const Matrix4x4& other) const;
|
||||
|
||||
//! Will return d,h,l as a Vector3d(x,y,z)
|
||||
const Vector3d GetTranslationComponent() const;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "Quaternion.h"
|
||||
#include "Constants.h"
|
||||
|
||||
#define _EULE_NO_INTRINSICS_
|
||||
//#define _EULE_NO_INTRINSICS_
|
||||
#ifndef _EULE_NO_INTRINSICS_
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Math.h"
|
||||
#include <iostream>
|
||||
|
||||
#define _EULE_NO_INTRINSICS_
|
||||
//#define _EULE_NO_INTRINSICS_
|
||||
#ifndef _EULE_NO_INTRINSICS_
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Math.h"
|
||||
#include <iostream>
|
||||
|
||||
#define _EULE_NO_INTRINSICS_
|
||||
//#define _EULE_NO_INTRINSICS_
|
||||
#ifndef _EULE_NO_INTRINSICS_
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
@ -673,7 +673,6 @@ void Vector3<T>::operator/=(const T scale)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Good, optimized chad version for doubles
|
||||
Vector3<double> Vector3<double>::operator*(const Matrix4x4& mat) const
|
||||
{
|
||||
@ -714,9 +713,9 @@ Vector3<double> Vector3<double>::operator*(const Matrix4x4& mat) const
|
||||
|
||||
#else
|
||||
// Rotation, Scaling
|
||||
newVec.x = (mat[0][0] * x) + (mat[1][0] * y) + (mat[2][0] * z);
|
||||
newVec.y = (mat[0][1] * x) + (mat[1][1] * y) + (mat[2][1] * z);
|
||||
newVec.z = (mat[0][2] * x) + (mat[1][2] * y) + (mat[2][2] * z);
|
||||
newVec.x = (mat[0][0] * x) + (mat[0][1] * y) + (mat[0][2] * z);
|
||||
newVec.y = (mat[1][0] * x) + (mat[1][1] * y) + (mat[1][2] * z);
|
||||
newVec.z = (mat[2][0] * x) + (mat[2][1] * y) + (mat[2][2] * z);
|
||||
|
||||
// Translation
|
||||
newVec.x += mat[0][3];
|
||||
@ -733,9 +732,9 @@ Vector3<int> Vector3<int>::operator*(const Matrix4x4& mat) const
|
||||
Vector3<double> newVec;
|
||||
|
||||
// Rotation, Scaling
|
||||
newVec.x = ((mat[0][0] * x) + (mat[1][0] * y) + (mat[2][0] * z));
|
||||
newVec.y = ((mat[0][1] * x) + (mat[1][1] * y) + (mat[2][1] * z));
|
||||
newVec.z = ((mat[0][2] * x) + (mat[1][2] * y) + (mat[2][2] * z));
|
||||
newVec.x = (mat[0][0] * x) + (mat[0][1] * y) + (mat[0][2] * z);
|
||||
newVec.y = (mat[1][0] * x) + (mat[1][1] * y) + (mat[1][2] * z);
|
||||
newVec.z = (mat[2][0] * x) + (mat[2][1] * y) + (mat[2][2] * z);
|
||||
|
||||
// Translation
|
||||
newVec.x += mat[0][3];
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Math.h"
|
||||
#include <iostream>
|
||||
|
||||
#define _EULE_NO_INTRINSICS_
|
||||
//#define _EULE_NO_INTRINSICS_
|
||||
#ifndef _EULE_NO_INTRINSICS_
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
@ -980,5 +980,51 @@ namespace Matrices
|
||||
Assert::IsFalse(a != b);
|
||||
return;
|
||||
}
|
||||
|
||||
// Tests if the equal const operator (==) and not-equals operator (!=) work (equal: false)
|
||||
TEST_METHOD(Operator_Equals_Const_NotEquals_False)
|
||||
{
|
||||
Matrix4x4 a;
|
||||
a[0] = { 0x0, 0x1, 0x2, 0x3 };
|
||||
a[1] = { 0x4, 0x5, 0x6, 0x7 };
|
||||
a[2] = { 0x8, 0x9, 0xA, 0xB };
|
||||
a[3] = { 0xC, 0xD, 0xE, 0xF };
|
||||
|
||||
Matrix4x4 b;
|
||||
b[3] = { 0xF ,0xD, 0xE, 0xC };
|
||||
b[2] = { 0xB ,0x9, 0xA, 0x8 };
|
||||
b[1] = { 0x7 ,0x5, 0x6, 0x4 };
|
||||
b[0] = { 0x3 ,0x1, 0x2, 0x0 };
|
||||
|
||||
const Matrix4x4 a_const = a;
|
||||
const Matrix4x4 b_const = b;
|
||||
|
||||
Assert::IsFalse(a_const == b_const);
|
||||
Assert::IsTrue(a_const != b_const);
|
||||
return;
|
||||
}
|
||||
|
||||
// Tests if the equal const operator (==) and not-equals operator (!=) work (equal: true)
|
||||
TEST_METHOD(Operator_Equals_Const_False)
|
||||
{
|
||||
Matrix4x4 a;
|
||||
a[0] = { 0x0, 0x1, 0x2, 0x3 };
|
||||
a[1] = { 0x4, 0x5, 0x6, 0x7 };
|
||||
a[2] = { 0x8, 0x9, 0xA, 0xB };
|
||||
a[3] = { 0xC, 0xD, 0xE, 0xF };
|
||||
|
||||
Matrix4x4 b;
|
||||
b[0] = { 0x0, 0x1, 0x2, 0x3 };
|
||||
b[1] = { 0x4, 0x5, 0x6, 0x7 };
|
||||
b[2] = { 0x8, 0x9, 0xA, 0xB };
|
||||
b[3] = { 0xC, 0xD, 0xE, 0xF };
|
||||
|
||||
const Matrix4x4 a_const = a;
|
||||
const Matrix4x4 b_const = b;
|
||||
|
||||
Assert::IsTrue(a_const == b_const);
|
||||
Assert::IsFalse(a_const != b_const);
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -128,7 +128,11 @@ namespace TransformRelated
|
||||
|
||||
Vector3d point(32, 19, -14);
|
||||
|
||||
Assert::IsTrue((point * a.ToRotationMatrix()).Similar(a * point));
|
||||
// Generate debug output
|
||||
std::wstringstream ss;
|
||||
ss << (point * a.ToRotationMatrix()) << std::endl << L"===" << (a * point) << std::endl;
|
||||
|
||||
Assert::IsTrue((point * a.ToRotationMatrix()).Similar(a * point), ss.str().c_str());
|
||||
}
|
||||
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user