refactor: use XCEngine::Math module in sphere test, update matrix to left-handed coordinate system

- Use Matrix4x4 type directly instead of float[16]
- Remove wrapper functions (IdentityMatrix, TranslationMatrix, PerspectiveMatrix, LookAtMatrix, MultiplyMatrix, TransposeMatrix)
- Direct use of Matrix4x4::Identity(), Matrix4x4::Translation(), Matrix4x4::Perspective()
- Transpose matrices before uploading to GPU to match HLSL column-major
- Update Math module Perspective and Orthographic to left-handed coordinate system
- Update math unit tests for new matrix values
This commit is contained in:
2026-03-22 20:08:36 +08:00
parent 70cc86793f
commit 0eadc7cfd1
3 changed files with 25 additions and 86 deletions

View File

@@ -146,9 +146,9 @@ Matrix4 Matrix4::Perspective(float fov, float aspect, float near, float far) {
Matrix4 result;
result.m[0][0] = 1.0f / (aspect * tanHalfFov);
result.m[1][1] = 1.0f / tanHalfFov;
result.m[2][2] = -(far + near) / (far - near);
result.m[2][3] = -(2.0f * far * near) / (far - near);
result.m[3][2] = -1.0f;
result.m[2][2] = far / (far - near);
result.m[2][3] = -far * near / (far - near);
result.m[3][2] = 1.0f;
return result;
}
@@ -156,10 +156,10 @@ Matrix4 Matrix4::Orthographic(float left, float right, float bottom, float top,
Matrix4 result = Identity();
result.m[0][0] = 2.0f / (right - left);
result.m[1][1] = 2.0f / (top - bottom);
result.m[2][2] = -2.0f / (far - near);
result.m[2][2] = 1.0f / (far - near);
result.m[0][3] = -(right + left) / (right - left);
result.m[1][3] = -(top + bottom) / (top - bottom);
result.m[2][3] = -(far + near) / (far - near);
result.m[2][3] = -near / (far - near);
return result;
}