mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2026-04-18 06:10:27 +00:00
Fix inverse perspective
This commit is contained in:
@@ -1857,10 +1857,10 @@ static inline HMM_Mat4 HMM_Perspective_LH_ZO(float FOV, float AspectRatio, float
|
||||
return Result;
|
||||
}
|
||||
|
||||
COVERAGE(HMM_InvPerspective, 1)
|
||||
static inline HMM_Mat4 HMM_InvPerspective(HMM_Mat4 PerspectiveMatrix)
|
||||
COVERAGE(HMM_InvPerspective_RH, 1)
|
||||
static inline HMM_Mat4 HMM_InvPerspective_RH(HMM_Mat4 PerspectiveMatrix)
|
||||
{
|
||||
ASSERT_COVERED(HMM_InvPerspective);
|
||||
ASSERT_COVERED(HMM_InvPerspective_RH);
|
||||
|
||||
HMM_Mat4 Result = {0};
|
||||
Result.Elements[0][0] = 1.0f / PerspectiveMatrix.Elements[0][0];
|
||||
@@ -1874,6 +1874,23 @@ static inline HMM_Mat4 HMM_InvPerspective(HMM_Mat4 PerspectiveMatrix)
|
||||
return Result;
|
||||
}
|
||||
|
||||
COVERAGE(HMM_InvPerspective_LH, 1)
|
||||
static inline HMM_Mat4 HMM_InvPerspective_LH(HMM_Mat4 PerspectiveMatrix)
|
||||
{
|
||||
ASSERT_COVERED(HMM_InvPerspective_LH);
|
||||
|
||||
HMM_Mat4 Result = {0};
|
||||
Result.Elements[0][0] = 1.0f / PerspectiveMatrix.Elements[0][0];
|
||||
Result.Elements[1][1] = 1.0f / PerspectiveMatrix.Elements[1][1];
|
||||
Result.Elements[2][2] = 0.0f;
|
||||
|
||||
Result.Elements[2][3] = 1.0f / PerspectiveMatrix.Elements[3][2];
|
||||
Result.Elements[3][3] = PerspectiveMatrix.Elements[2][2] * -Result.Elements[2][3];
|
||||
Result.Elements[3][2] = PerspectiveMatrix.Elements[2][3];
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
COVERAGE(HMM_Translate, 1)
|
||||
static inline HMM_Mat4 HMM_Translate(HMM_Vec3 Translation)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user