Fix LH perspective matrix

Off by a sign before.
This commit is contained in:
dev_dwarf
2023-01-24 22:42:15 -07:00
committed by Ben Visness
parent f106a0f5f3
commit 7e493a5481
2 changed files with 6 additions and 5 deletions

View File

@@ -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)

View File

@@ -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);
}
}