mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2025-10-17 14:11:47 +00:00
HMM2.0 (#149)
These changes were all made by @dev-dwarf. Many thanks for his work on this! * Renaming * First Pass on 2.0UpdateTool * Another pass on UpdateTool, changed name * Another pass on UpdateTool, changed name * Do Renaming * Working on Angles Consistency * Passing Coverage * Remove unused arc-tangent functions * Change macro defaults By default if user is overriding trig functions assume their input and internal units are the same. * wrap in AngleDeg instead of AngleRad * Remove HMM_PREFIX configuration * Fix for Slerp https://discord.com/channels/239737791225790464/489148972305350656/1055167647274246265 Justified by most implementations of Slerp. EX: http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/ * Handedness Changes * More renaming. C11 _Generics Generics enable by default when available (see lines 97-104). User can also force them by defining HANDMADE_MATH_C11_GENERICS Also fixed some missed things w.r.t renaming. My old tool didn't catch cases like HMM_MultiplyVec3f needing to be HMM_MulV3F instead of HMM_MulV3f. * Reuse more SSE codepaths for Quaternions Also improved quaternion tests. More work could be done here, see discussion here about optimizing slerp: https://discord.com/channels/239737791225790464/489148972305350656/1055167647274246265 * Just saving these alternate versions of SLerp * Reduce V4/M4 Linear Comb. codepaths * Simple implementation of 2x2 and 3x3 basic matrix operations. Also renamed Transpose to TransposeM4, so that we can have TransposeM2,M3 * Norm is dead! Long live Norm! As can be seen from the tests, precision has declined quite a bit from using the FastNorm implementations for various things. We can only guarantee about 0.001f precision for anything where a norm happens now. If this is undesired we can change back easily. * Started work on Matrix Inverses TODO: Tests for simple 4x4 Inverses * Matrix Inverses + Tests * Generics for Matrices and Rename MXd/f functions * Fixes + Better Output for UpdateTool * I think I count as a contributor : ) * Ported UpdateTool, Inlined my library code. * Moved tool to different repo https://github.com/dev-dwarf/HMM2.0UpdateTool * Remove small test change * Found some more references to atan functions * Standardize angle function names, use short names * Remove other slerp comments * woops that wasnt meant to be commited. * Finish changing ToRadians to ToRad * Fix [] overloads per https://discord.com/channels/239737791225790464/600063880533770251/1051600188302692402 * Tests for 2x2, 3x3 Matrices and Other Matrix Ops * Add an option to use Z: [0, 1] range for projection matrices. This will make HMM more convenient to use with other graphics APIs such as Direct3d and Metal. * Update test imports * #if should've been #ifdef! * Implement requested changes
This commit is contained in:
@@ -5,8 +5,8 @@ TEST(Initialization, Vectors)
|
||||
//
|
||||
// Test vec2
|
||||
//
|
||||
hmm_vec2 v2 = HMM_Vec2(1.0f, 2.0f);
|
||||
hmm_vec2 v2i = HMM_Vec2i(1, 2);
|
||||
HMM_Vec2 v2 = HMM_V2(1.0f, 2.0f);
|
||||
HMM_Vec2 v2i = HMM_V2I(1, 2);
|
||||
|
||||
EXPECT_FLOAT_EQ(v2.X, 1.0f);
|
||||
EXPECT_FLOAT_EQ(v2.Y, 2.0f);
|
||||
@@ -41,8 +41,8 @@ TEST(Initialization, Vectors)
|
||||
//
|
||||
// Test vec3
|
||||
//
|
||||
hmm_vec3 v3 = HMM_Vec3(1.0f, 2.0f, 3.0f);
|
||||
hmm_vec3 v3i = HMM_Vec3i(1, 2, 3);
|
||||
HMM_Vec3 v3 = HMM_V3(1.0f, 2.0f, 3.0f);
|
||||
HMM_Vec3 v3i = HMM_V3I(1, 2, 3);
|
||||
|
||||
EXPECT_FLOAT_EQ(v3.X, 1.0f);
|
||||
EXPECT_FLOAT_EQ(v3.Y, 2.0f);
|
||||
@@ -99,9 +99,9 @@ TEST(Initialization, Vectors)
|
||||
//
|
||||
// Test vec4
|
||||
//
|
||||
hmm_vec4 v4 = HMM_Vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
hmm_vec4 v4i = HMM_Vec4i(1, 2, 3, 4);
|
||||
hmm_vec4 v4v = HMM_Vec4v(v3, 4.0f);
|
||||
HMM_Vec4 v4 = HMM_V4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
HMM_Vec4 v4i = HMM_V4I(1, 2, 3, 4);
|
||||
HMM_Vec4 v4v = HMM_V4V(v3, 4.0f);
|
||||
|
||||
EXPECT_FLOAT_EQ(v4.X, 1.0f);
|
||||
EXPECT_FLOAT_EQ(v4.Y, 2.0f);
|
||||
@@ -193,7 +193,7 @@ TEST(Initialization, Vectors)
|
||||
|
||||
TEST(Initialization, MatrixEmpty)
|
||||
{
|
||||
hmm_mat4 m4 = HMM_Mat4();
|
||||
HMM_Mat4 m4 = HMM_M4();
|
||||
for (int Column = 0; Column < 4; ++Column)
|
||||
{
|
||||
for (int Row = 0; Row < 4; ++Row)
|
||||
@@ -208,7 +208,7 @@ TEST(Initialization, MatrixEmpty)
|
||||
|
||||
TEST(Initialization, MatrixDiagonal)
|
||||
{
|
||||
hmm_mat4 m4d = HMM_Mat4d(1.0f);
|
||||
HMM_Mat4 m4d = HMM_M4D(1.0f);
|
||||
for (int Column = 0; Column < 4; ++Column)
|
||||
{
|
||||
for (int Row = 0; Row < 4; ++Row)
|
||||
@@ -224,7 +224,7 @@ TEST(Initialization, MatrixDiagonal)
|
||||
|
||||
TEST(Initialization, Quaternion)
|
||||
{
|
||||
hmm_quaternion q = HMM_Quaternion(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
HMM_Quat q = HMM_Q(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
|
||||
EXPECT_FLOAT_EQ(q.X, 1.0f);
|
||||
EXPECT_FLOAT_EQ(q.Y, 2.0f);
|
||||
@@ -236,8 +236,8 @@ TEST(Initialization, Quaternion)
|
||||
EXPECT_FLOAT_EQ(q.Elements[2], 3.0f);
|
||||
EXPECT_FLOAT_EQ(q.Elements[3], 4.0f);
|
||||
|
||||
hmm_vec4 v = HMM_Vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
hmm_quaternion qv = HMM_QuaternionV4(v);
|
||||
HMM_Vec4 v = HMM_V4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
HMM_Quat qv = HMM_QV4(v);
|
||||
|
||||
EXPECT_FLOAT_EQ(qv.X, 1.0f);
|
||||
EXPECT_FLOAT_EQ(qv.Y, 2.0f);
|
||||
|
Reference in New Issue
Block a user