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

@@ -139,9 +139,9 @@ TEST(Math_Matrix4, Perspective) {
EXPECT_FLOAT_EQ(m.m[0][0], 1.0f / (aspect * std::tan(fov * 0.5f)));
EXPECT_FLOAT_EQ(m.m[1][1], 1.0f / std::tan(fov * 0.5f));
EXPECT_FLOAT_EQ(m.m[2][2], -(farPlane + nearPlane) / (farPlane - nearPlane));
EXPECT_FLOAT_EQ(m.m[2][3], -(2.0f * farPlane * nearPlane) / (farPlane - nearPlane));
EXPECT_FLOAT_EQ(m.m[3][2], -1.0f);
EXPECT_FLOAT_EQ(m.m[2][2], farPlane / (farPlane - nearPlane));
EXPECT_FLOAT_EQ(m.m[2][3], -farPlane * nearPlane / (farPlane - nearPlane));
EXPECT_FLOAT_EQ(m.m[3][2], 1.0f);
}
TEST(Math_Matrix4, Orthographic) {
@@ -153,7 +153,7 @@ TEST(Math_Matrix4, Orthographic) {
EXPECT_FLOAT_EQ(m.m[0][0], 0.1f);
EXPECT_FLOAT_EQ(m.m[1][1], 0.1f);
EXPECT_FLOAT_EQ(m.m[2][2], -2.0f / (farPlane - nearPlane));
EXPECT_FLOAT_EQ(m.m[2][2], 1.0f / (farPlane - nearPlane));
}
TEST(Math_Matrix4, Multiply_MatrixWithMatrix) {