From 4c65781c6f65af34011c29112bad7805be903851 Mon Sep 17 00:00:00 2001 From: Orange Date: Sat, 25 Apr 2026 05:34:53 +0300 Subject: [PATCH] improvement --- include/omath/linear_algebra/mat.hpp | 16 ++++++++-------- tests/general/unit_test_mat.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/omath/linear_algebra/mat.hpp b/include/omath/linear_algebra/mat.hpp index 9d6c34a..ca04b8c 100644 --- a/include/omath/linear_algebra/mat.hpp +++ b/include/omath/linear_algebra/mat.hpp @@ -667,8 +667,8 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> mat_perspective_left_handed(const float field_of_view, const float aspect_ratio, - const float near, const float far) noexcept + Mat<4, 4, Type, St> mat_perspective_left_handed(const Type field_of_view, const Type aspect_ratio, + const Type near, const Type far) noexcept { const auto fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / Type{2}); @@ -689,8 +689,8 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> mat_perspective_right_handed(const float field_of_view, const float aspect_ratio, - const float near, const float far) noexcept + Mat<4, 4, Type, St> mat_perspective_right_handed(const Type field_of_view, const Type aspect_ratio, + const Type near, const Type far) noexcept { const auto fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / Type{2}); @@ -748,10 +748,10 @@ namespace omath const auto y_axis = inv_tan_half_hfov * aspect_ratio; if constexpr (DepthRange == NDCDepthRange::ZERO_TO_ONE) - return {{x_axis, Type{0}, Type{0}, Type{0}}, - {Type{0}, y_axis, Type{0}, Type{0}}, - {Type{0}, Type{0}, -far / (far - near), -(near * far) / (far - near)}, - {Type{0}, Type{0}, -Type{1}, Type{0}}}; + return {{x_axis, Type{0}, Type{0}, Type{0}}, + {Type{0}, y_axis, Type{0}, Type{0}}, + {Type{0}, Type{0}, -far / (far - near), -(near * far) / (far - near)}, + {Type{0}, Type{0}, -Type{1}, Type{0}}}; else if constexpr (DepthRange == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return {{x_axis, Type{0}, Type{0}, Type{0}}, {Type{0}, y_axis, Type{0}, Type{0}}, diff --git a/tests/general/unit_test_mat.cpp b/tests/general/unit_test_mat.cpp index 57c426d..0059b12 100644 --- a/tests/general/unit_test_mat.cpp +++ b/tests/general/unit_test_mat.cpp @@ -220,8 +220,8 @@ TEST(UnitTestMatStandalone, Equanity) constexpr omath::Vector3 left_handed = {0, 2, 10}; constexpr omath::Vector3 right_handed = {0, 2, -10}; - const auto proj_left_handed = omath::mat_perspective_left_handed(90.f, 16.f / 9.f, 0.1, 1000); - const auto proj_right_handed = omath::mat_perspective_right_handed(90.f, 16.f / 9.f, 0.1, 1000); + const auto proj_left_handed = omath::mat_perspective_left_handed(90.f, 16.f / 9.f, 0.1f, 1000.f); + const auto proj_right_handed = omath::mat_perspective_right_handed(90.f, 16.f / 9.f, 0.1f, 1000.f); auto ndc_left_handed = proj_left_handed * omath::mat_column_from_vector(left_handed); auto ndc_right_handed = proj_right_handed * omath::mat_column_from_vector(right_handed);