mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2026-01-04 18:37:40 +00:00
Fix LH perspective matrix
Off by a sign before.
This commit is contained in:
@@ -1788,9 +1788,10 @@ static inline HMM_Mat4 HMM_Perspective_LH(float FOV, float AspectRatio, float Ne
|
||||
ASSERT_COVERED(HMM_Perspective_LH);
|
||||
|
||||
HMM_Mat4 Result = HMM_Perspective_RH(FOV, AspectRatio, Near, Far);
|
||||
Result.Elements[2][3] = +1.0f;
|
||||
|
||||
return Result;
|
||||
Result.Elements[2][2] = -Result.Elements[2][2];
|
||||
Result.Elements[2][3] = -Result.Elements[2][3];
|
||||
|
||||
return (Result);
|
||||
}
|
||||
|
||||
COVERAGE(HMM_InvPerspective, 1)
|
||||
|
||||
@@ -39,11 +39,11 @@ TEST(Projection, Perspective)
|
||||
}
|
||||
{
|
||||
HMM_Mat4 projection = HMM_Perspective_LH(HMM_AngleDeg(90.0f), 2.0f, 5.0f, 15.0f);
|
||||
HMM_Vec3 original = HMM_V3(5.0f, 5.0f, -15.0f);
|
||||
HMM_Vec3 original = HMM_V3(5.0f, 5.0f, 15.0f);
|
||||
HMM_Vec4 projected = HMM_MulM4V4(projection, HMM_V4V(original, 1));
|
||||
EXPECT_FLOAT_EQ(projected.X, 2.5f);
|
||||
EXPECT_FLOAT_EQ(projected.Y, 5.0f);
|
||||
EXPECT_FLOAT_EQ(projected.Z, 15.0f);
|
||||
EXPECT_FLOAT_EQ(projected.W, -15.0f);
|
||||
EXPECT_FLOAT_EQ(projected.W, 15.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user