mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2025-10-25 20:07:08 +00:00
General Cleanup
This commit is contained in:
@@ -1309,7 +1309,6 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(Mat4d)(float Diagonal)
|
|||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HANDMADE_MATH__USE_SSE
|
|
||||||
COVERAGE(HMM_Transpose, 1)
|
COVERAGE(HMM_Transpose, 1)
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix)
|
HMM_INLINE hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix)
|
||||||
{
|
{
|
||||||
@@ -1317,18 +1316,9 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix)
|
|||||||
|
|
||||||
hmm_mat4 Result = Matrix;
|
hmm_mat4 Result = Matrix;
|
||||||
|
|
||||||
|
#ifdef HANDMADE_MATH__USE_SSE
|
||||||
_MM_TRANSPOSE4_PS(Result.Columns[0], Result.Columns[1], Result.Columns[2], Result.Columns[3]);
|
_MM_TRANSPOSE4_PS(Result.Columns[0], Result.Columns[1], Result.Columns[2], Result.Columns[3]);
|
||||||
|
|
||||||
return (Result);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
COVERAGE(HMM_Transpose, 1)
|
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix)
|
|
||||||
{
|
|
||||||
ASSERT_COVERED(HMM_Transpose);
|
|
||||||
|
|
||||||
hmm_mat4 Result;
|
|
||||||
|
|
||||||
int Columns;
|
int Columns;
|
||||||
for(Columns = 0; Columns < 4; ++Columns)
|
for(Columns = 0; Columns < 4; ++Columns)
|
||||||
{
|
{
|
||||||
@@ -1338,12 +1328,12 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(Transpose)(hmm_mat4 Matrix)
|
|||||||
Result.Elements[Rows][Columns] = Matrix.Elements[Columns][Rows];
|
Result.Elements[Rows][Columns] = Matrix.Elements[Columns][Rows];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HANDMADE_MATH__USE_SSE
|
|
||||||
COVERAGE(HMM_AddMat4, 1)
|
COVERAGE(HMM_AddMat4, 1)
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
HMM_INLINE hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
||||||
{
|
{
|
||||||
@@ -1351,21 +1341,12 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|||||||
|
|
||||||
hmm_mat4 Result;
|
hmm_mat4 Result;
|
||||||
|
|
||||||
|
#ifdef HANDMADE_MATH__USE_SSE
|
||||||
Result.Columns[0] = _mm_add_ps(Left.Columns[0], Right.Columns[0]);
|
Result.Columns[0] = _mm_add_ps(Left.Columns[0], Right.Columns[0]);
|
||||||
Result.Columns[1] = _mm_add_ps(Left.Columns[1], Right.Columns[1]);
|
Result.Columns[1] = _mm_add_ps(Left.Columns[1], Right.Columns[1]);
|
||||||
Result.Columns[2] = _mm_add_ps(Left.Columns[2], Right.Columns[2]);
|
Result.Columns[2] = _mm_add_ps(Left.Columns[2], Right.Columns[2]);
|
||||||
Result.Columns[3] = _mm_add_ps(Left.Columns[3], Right.Columns[3]);
|
Result.Columns[3] = _mm_add_ps(Left.Columns[3], Right.Columns[3]);
|
||||||
|
|
||||||
return (Result);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
COVERAGE(HMM_AddMat4, 1)
|
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|
||||||
{
|
|
||||||
ASSERT_COVERED(HMM_AddMat4);
|
|
||||||
|
|
||||||
hmm_mat4 Result;
|
|
||||||
|
|
||||||
int Columns;
|
int Columns;
|
||||||
for(Columns = 0; Columns < 4; ++Columns)
|
for(Columns = 0; Columns < 4; ++Columns)
|
||||||
{
|
{
|
||||||
@@ -1375,12 +1356,12 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(AddMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|||||||
Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] + Right.Elements[Columns][Rows];
|
Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] + Right.Elements[Columns][Rows];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HANDMADE_MATH__USE_SSE
|
|
||||||
COVERAGE(HMM_SubtractMat4, 1)
|
COVERAGE(HMM_SubtractMat4, 1)
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
HMM_INLINE hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
||||||
{
|
{
|
||||||
@@ -1388,21 +1369,12 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|||||||
|
|
||||||
hmm_mat4 Result;
|
hmm_mat4 Result;
|
||||||
|
|
||||||
|
#ifdef HANDMADE_MATH__USE_SSE
|
||||||
Result.Columns[0] = _mm_sub_ps(Left.Columns[0], Right.Columns[0]);
|
Result.Columns[0] = _mm_sub_ps(Left.Columns[0], Right.Columns[0]);
|
||||||
Result.Columns[1] = _mm_sub_ps(Left.Columns[1], Right.Columns[1]);
|
Result.Columns[1] = _mm_sub_ps(Left.Columns[1], Right.Columns[1]);
|
||||||
Result.Columns[2] = _mm_sub_ps(Left.Columns[2], Right.Columns[2]);
|
Result.Columns[2] = _mm_sub_ps(Left.Columns[2], Right.Columns[2]);
|
||||||
Result.Columns[3] = _mm_sub_ps(Left.Columns[3], Right.Columns[3]);
|
Result.Columns[3] = _mm_sub_ps(Left.Columns[3], Right.Columns[3]);
|
||||||
|
|
||||||
return (Result);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
COVERAGE(HMM_SubtractMat4, 1)
|
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|
||||||
{
|
|
||||||
ASSERT_COVERED(HMM_SubtractMat4);
|
|
||||||
|
|
||||||
hmm_mat4 Result;
|
|
||||||
|
|
||||||
int Columns;
|
int Columns;
|
||||||
for(Columns = 0; Columns < 4; ++Columns)
|
for(Columns = 0; Columns < 4; ++Columns)
|
||||||
{
|
{
|
||||||
@@ -1412,10 +1384,10 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(SubtractMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|||||||
Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] - Right.Elements[Columns][Rows];
|
Result.Elements[Columns][Rows] = Left.Elements[Columns][Rows] - Right.Elements[Columns][Rows];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
COVERAGE(HMM_MultiplyMat4, 1)
|
COVERAGE(HMM_MultiplyMat4, 1)
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
||||||
@@ -1452,7 +1424,6 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4)(hmm_mat4 Left, hmm_mat4 Right)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HANDMADE_MATH__USE_SSE
|
|
||||||
COVERAGE(HMM_MultiplyMat4f, 1)
|
COVERAGE(HMM_MultiplyMat4f, 1)
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar)
|
HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar)
|
||||||
{
|
{
|
||||||
@@ -1460,22 +1431,13 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar)
|
|||||||
|
|
||||||
hmm_mat4 Result;
|
hmm_mat4 Result;
|
||||||
|
|
||||||
|
#ifdef HANDMADE_MATH__USE_SSE
|
||||||
__m128 SSEScalar = _mm_set1_ps(Scalar);
|
__m128 SSEScalar = _mm_set1_ps(Scalar);
|
||||||
Result.Columns[0] = _mm_mul_ps(Matrix.Columns[0], SSEScalar);
|
Result.Columns[0] = _mm_mul_ps(Matrix.Columns[0], SSEScalar);
|
||||||
Result.Columns[1] = _mm_mul_ps(Matrix.Columns[1], SSEScalar);
|
Result.Columns[1] = _mm_mul_ps(Matrix.Columns[1], SSEScalar);
|
||||||
Result.Columns[2] = _mm_mul_ps(Matrix.Columns[2], SSEScalar);
|
Result.Columns[2] = _mm_mul_ps(Matrix.Columns[2], SSEScalar);
|
||||||
Result.Columns[3] = _mm_mul_ps(Matrix.Columns[3], SSEScalar);
|
Result.Columns[3] = _mm_mul_ps(Matrix.Columns[3], SSEScalar);
|
||||||
|
|
||||||
return (Result);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
COVERAGE(HMM_MultiplyMat4f, 1)
|
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar)
|
|
||||||
{
|
|
||||||
ASSERT_COVERED(HMM_MultiplyMat4f);
|
|
||||||
|
|
||||||
hmm_mat4 Result;
|
|
||||||
|
|
||||||
int Columns;
|
int Columns;
|
||||||
for(Columns = 0; Columns < 4; ++Columns)
|
for(Columns = 0; Columns < 4; ++Columns)
|
||||||
{
|
{
|
||||||
@@ -1485,12 +1447,11 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(MultiplyMat4f)(hmm_mat4 Matrix, float Scalar)
|
|||||||
Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] * Scalar;
|
Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] * Scalar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
COVERAGE(HMM_MultiplyMat4ByVec4, 1)
|
COVERAGE(HMM_MultiplyMat4ByVec4, 1)
|
||||||
HMM_INLINE hmm_vec4 HMM_PREFIX(MultiplyMat4ByVec4)(hmm_mat4 Matrix, hmm_vec4 Vector)
|
HMM_INLINE hmm_vec4 HMM_PREFIX(MultiplyMat4ByVec4)(hmm_mat4 Matrix, hmm_vec4 Vector)
|
||||||
{
|
{
|
||||||
@@ -1518,7 +1479,6 @@ HMM_INLINE hmm_vec4 HMM_PREFIX(MultiplyMat4ByVec4)(hmm_mat4 Matrix, hmm_vec4 Vec
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HANDMADE_MATH__USE_SSE
|
|
||||||
COVERAGE(HMM_DivideMat4f, 1)
|
COVERAGE(HMM_DivideMat4f, 1)
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar)
|
HMM_INLINE hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar)
|
||||||
{
|
{
|
||||||
@@ -1526,22 +1486,13 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar)
|
|||||||
|
|
||||||
hmm_mat4 Result;
|
hmm_mat4 Result;
|
||||||
|
|
||||||
|
#ifdef HANDMADE_MATH__USE_SSE
|
||||||
__m128 SSEScalar = _mm_set1_ps(Scalar);
|
__m128 SSEScalar = _mm_set1_ps(Scalar);
|
||||||
Result.Columns[0] = _mm_div_ps(Matrix.Columns[0], SSEScalar);
|
Result.Columns[0] = _mm_div_ps(Matrix.Columns[0], SSEScalar);
|
||||||
Result.Columns[1] = _mm_div_ps(Matrix.Columns[1], SSEScalar);
|
Result.Columns[1] = _mm_div_ps(Matrix.Columns[1], SSEScalar);
|
||||||
Result.Columns[2] = _mm_div_ps(Matrix.Columns[2], SSEScalar);
|
Result.Columns[2] = _mm_div_ps(Matrix.Columns[2], SSEScalar);
|
||||||
Result.Columns[3] = _mm_div_ps(Matrix.Columns[3], SSEScalar);
|
Result.Columns[3] = _mm_div_ps(Matrix.Columns[3], SSEScalar);
|
||||||
|
|
||||||
return (Result);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
COVERAGE(HMM_DivideMat4f, 1);
|
|
||||||
HMM_INLINE hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar)
|
|
||||||
{
|
|
||||||
ASSERT_COVERED(HMM_DivideMat4f);
|
|
||||||
|
|
||||||
hmm_mat4 Result;
|
|
||||||
|
|
||||||
int Columns;
|
int Columns;
|
||||||
for(Columns = 0; Columns < 4; ++Columns)
|
for(Columns = 0; Columns < 4; ++Columns)
|
||||||
{
|
{
|
||||||
@@ -1551,11 +1502,10 @@ HMM_INLINE hmm_mat4 HMM_PREFIX(DivideMat4f)(hmm_mat4 Matrix, float Scalar)
|
|||||||
Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] / Scalar;
|
Result.Elements[Columns][Rows] = Matrix.Elements[Columns][Rows] / Scalar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return (Result);
|
return (Result);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common graphics transformations
|
* Common graphics transformations
|
||||||
|
|||||||
Reference in New Issue
Block a user