Fixed discrepancy between compiler intrinsics mode and unparallelized mode. Also added const * *= operator to matrix.

This commit is contained in:
Leonetienne
2021-11-17 19:28:51 +01:00
parent b168289208
commit 2a505e0321
8 changed files with 78 additions and 17 deletions

View File

@@ -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);
@@ -617,7 +627,7 @@ bool Matrix4x4::Similar(const Matrix4x4& other, double epsilon) const
namespace Eule
{
std::ostream& operator<<(std::ostream& os, const Matrix4x4& m)
std::ostream& operator<< (std::ostream& os, const Matrix4x4& m)
{
os << std::endl;
@@ -632,7 +642,7 @@ namespace Eule
return os;
}
std::wostream& operator<<(std::wostream& os, const Matrix4x4& m)
std::wostream& operator<< (std::wostream& os, const Matrix4x4& m)
{
os << std::endl;

View File

@@ -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;
@@ -121,8 +123,8 @@ namespace Eule
//! Will compare if two matrices are similar to a certain epsilon value
bool Similar(const Matrix4x4& other, double epsilon = 0.00001) const;
friend std::ostream& operator<<(std::ostream& os, const Matrix4x4& m);
friend std::wostream& operator<<(std::wostream& os, const Matrix4x4& m);
friend std::ostream& operator<< (std::ostream& os, const Matrix4x4& m);
friend std::wostream& operator<< (std::wostream& os, const Matrix4x4& m);
// Shorthands
double& a = v[0][0];

View File

@@ -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

View File

@@ -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

View File

@@ -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];

View File

@@ -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