mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2025-12-28 15:44:33 +00:00
Compare commits
6 Commits
1.12.0
...
quaternion
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c7bffdccb | ||
|
|
a22d411267 | ||
|
|
2a050bc124 | ||
|
|
0e2bc9be4f | ||
|
|
ec5bc9c0d3 | ||
|
|
baf1a70fc6 |
@@ -481,8 +481,17 @@ typedef union hmm_quaternion
|
||||
|
||||
float W;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
hmm_vec4 XYZW;
|
||||
};
|
||||
|
||||
float Elements[4];
|
||||
|
||||
#if HANDMADE_MATH__USE_SSE
|
||||
_m128 InternalElementsSSE;
|
||||
#endif
|
||||
} hmm_quaternion;
|
||||
|
||||
typedef int32_t hmm_bool;
|
||||
@@ -1317,11 +1326,14 @@ HMM_INLINE hmm_quaternion HMM_Quaternion(float X, float Y, float Z, float W)
|
||||
{
|
||||
hmm_quaternion Result;
|
||||
|
||||
#if HANDMADE_MATH__USE_SSE
|
||||
Result.InternalElementsSSE = _mm_setr_ps(X, Y, Z, W);
|
||||
#else
|
||||
Result.X = X;
|
||||
Result.Y = Y;
|
||||
Result.Z = Z;
|
||||
Result.W = W;
|
||||
|
||||
#endif
|
||||
return (Result);
|
||||
}
|
||||
|
||||
@@ -1329,11 +1341,15 @@ HMM_INLINE hmm_quaternion HMM_QuaternionV4(hmm_vec4 Vector)
|
||||
{
|
||||
hmm_quaternion Result;
|
||||
|
||||
#if HANDMADE_MATH__USE_SSE
|
||||
Result.InternalElementsSSE = _mm_setr_ps(Vector.X, Vector.Y, Vector.Z, Vector.W);
|
||||
#else
|
||||
Result.X = Vector.X;
|
||||
Result.Y = Vector.Y;
|
||||
Result.Z = Vector.Z;
|
||||
Result.W = Vector.W;
|
||||
|
||||
Result.W = Vector.W;
|
||||
#endif
|
||||
|
||||
return (Result);
|
||||
}
|
||||
|
||||
@@ -1341,11 +1357,14 @@ HMM_INLINE hmm_quaternion HMM_AddQuaternion(hmm_quaternion Left, hmm_quaternion
|
||||
{
|
||||
hmm_quaternion Result;
|
||||
|
||||
#if HANDMADE_MATH__USE_SSE
|
||||
Result.InternalElementsSSE = _mm_add_ps(Left.InternalElementsSSE, Right.InternalElementsSSE);
|
||||
#else
|
||||
Result.X = Left.X + Right.X;
|
||||
Result.Y = Left.Y + Right.Y;
|
||||
Result.Z = Left.Z + Right.Z;
|
||||
Result.W = Left.W + Right.W;
|
||||
|
||||
#endif
|
||||
return (Result);
|
||||
}
|
||||
|
||||
@@ -1353,11 +1372,15 @@ HMM_INLINE hmm_quaternion HMM_SubtractQuaternion(hmm_quaternion Left, hmm_quater
|
||||
{
|
||||
hmm_quaternion Result;
|
||||
|
||||
#if HANDMADE_MATH__USE_SSE
|
||||
Result.InternalElementsSSE = _mm_sub_ps(Left.InternalElementsSSE, Right.InternalElementsSSE);
|
||||
#else
|
||||
Result.X = Left.X - Right.X;
|
||||
Result.Y = Left.Y - Right.Y;
|
||||
Result.Z = Left.Z - Right.Z;
|
||||
Result.W = Left.W - Right.W;
|
||||
|
||||
#endif
|
||||
|
||||
return (Result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user