Disabled intrinsics and made Quaternions thread safe
This commit is contained in:
parent
68ac55b760
commit
b168289208
@ -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
|
||||
|
@ -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
|
||||
@ -174,6 +174,8 @@ bool Quaternion::operator!= (const Quaternion& q) const
|
||||
|
||||
Quaternion Quaternion::Inverse() const
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(lock_inverseCache);
|
||||
|
||||
if (!isCacheUpToDate_inverse)
|
||||
{
|
||||
cache_inverse = (Conjugate() * (1.0 / v.SqrMagnitude())).v;
|
||||
@ -214,6 +216,8 @@ Vector3d Quaternion::RotateVector(const Vector3d& vec) const
|
||||
|
||||
Vector3d Quaternion::ToEulerAngles() const
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(lock_eulerCache);
|
||||
|
||||
if (!isCacheUpToDate_euler)
|
||||
{
|
||||
Vector3d euler;
|
||||
@ -245,6 +249,8 @@ Vector3d Quaternion::ToEulerAngles() const
|
||||
|
||||
Matrix4x4 Quaternion::ToRotationMatrix() const
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(lock_matrixCache);
|
||||
|
||||
if (!isCacheUpToDate_matrix)
|
||||
{
|
||||
Matrix4x4 m;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Vector3.h"
|
||||
#include "Vector4.h"
|
||||
#include "Matrix4x4.h"
|
||||
#include <mutex>
|
||||
|
||||
namespace Eule
|
||||
{
|
||||
@ -95,5 +96,9 @@ namespace Eule
|
||||
mutable bool isCacheUpToDate_inverse = false;
|
||||
mutable Vector4d cache_inverse;
|
||||
|
||||
// Mutexes for thread-safe caching
|
||||
mutable std::mutex lock_eulerCache;
|
||||
mutable std::mutex lock_matrixCache;
|
||||
mutable std::mutex lock_inverseCache;
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user