diff --git a/include/omath/linear_algebra/mat.hpp b/include/omath/linear_algebra/mat.hpp index ca04b8c..3ad8428 100644 --- a/include/omath/linear_algebra/mat.hpp +++ b/include/omath/linear_algebra/mat.hpp @@ -667,7 +667,7 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> mat_perspective_left_handed(const Type field_of_view, const Type aspect_ratio, + Mat<4, 4, Type, St> mat_perspective_left_handed_vertical_fov(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,7 +689,7 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> mat_perspective_right_handed(const Type field_of_view, const Type aspect_ratio, + Mat<4, 4, Type, St> mat_perspective_right_handed_vertical_fov(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}); diff --git a/source/engines/cry_engine/formulas.cpp b/source/engines/cry_engine/formulas.cpp index 301016b..ac63408 100644 --- a/source/engines/cry_engine/formulas.cpp +++ b/source/engines/cry_engine/formulas.cpp @@ -38,11 +38,11 @@ namespace omath::cry_engine const float far, const NDCDepthRange ndc_depth_range) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) - return mat_perspective_left_handed( + return mat_perspective_left_handed_vertical_fov( field_of_view, aspect_ratio, near, far); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) - return mat_perspective_left_handed( + return mat_perspective_left_handed_vertical_fov( field_of_view, aspect_ratio, near, far); std::unreachable(); } diff --git a/source/engines/frostbite_engine/formulas.cpp b/source/engines/frostbite_engine/formulas.cpp index c3193cb..981ca1c 100644 --- a/source/engines/frostbite_engine/formulas.cpp +++ b/source/engines/frostbite_engine/formulas.cpp @@ -38,11 +38,11 @@ namespace omath::frostbite_engine const float far, const NDCDepthRange ndc_depth_range) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) - return mat_perspective_left_handed( + return mat_perspective_left_handed_vertical_fov( field_of_view, aspect_ratio, near, far); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) - return mat_perspective_left_handed( + return mat_perspective_left_handed_vertical_fov( field_of_view, aspect_ratio, near, far); std::unreachable(); diff --git a/source/engines/iw_engine/formulas.cpp b/source/engines/iw_engine/formulas.cpp index 09ce04a..2592649 100644 --- a/source/engines/iw_engine/formulas.cpp +++ b/source/engines/iw_engine/formulas.cpp @@ -47,11 +47,11 @@ namespace omath::iw_engine const auto vertical_fov = angles::horizontal_fov_to_vertical(field_of_view, k_source_reference_aspect); if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) - return mat_perspective_left_handed< + return mat_perspective_left_handed_vertical_fov< float, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>( vertical_fov, aspect_ratio, near, far); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) - return mat_perspective_left_handed< + return mat_perspective_left_handed_vertical_fov< float, MatStoreType::ROW_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>( vertical_fov, aspect_ratio, near, far); std::unreachable(); diff --git a/source/engines/opengl_engine/formulas.cpp b/source/engines/opengl_engine/formulas.cpp index 93eec90..01d41b3 100644 --- a/source/engines/opengl_engine/formulas.cpp +++ b/source/engines/opengl_engine/formulas.cpp @@ -40,11 +40,11 @@ namespace omath::opengl_engine const float far, const NDCDepthRange ndc_depth_range) noexcept { if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) - return mat_perspective_right_handed( + return mat_perspective_right_handed_vertical_fov( field_of_view, aspect_ratio, near, far); if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) - return mat_perspective_right_handed( + return mat_perspective_right_handed_vertical_fov( field_of_view, aspect_ratio, near, far); std::unreachable(); diff --git a/source/engines/source_engine/formulas.cpp b/source/engines/source_engine/formulas.cpp index c8c5bc7..7718fde 100644 --- a/source/engines/source_engine/formulas.cpp +++ b/source/engines/source_engine/formulas.cpp @@ -47,11 +47,11 @@ namespace omath::source_engine const auto vertical_fov = angles::horizontal_fov_to_vertical(field_of_view, k_source_reference_aspect); if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) - return mat_perspective_left_handed< + return mat_perspective_left_handed_vertical_fov< float, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>( vertical_fov, aspect_ratio, near, far); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) - return mat_perspective_left_handed< + return mat_perspective_left_handed_vertical_fov< float, MatStoreType::ROW_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>( vertical_fov, aspect_ratio, near, far); std::unreachable(); diff --git a/source/engines/unity_engine/formulas.cpp b/source/engines/unity_engine/formulas.cpp index 51e4c4c..b10fa82 100644 --- a/source/engines/unity_engine/formulas.cpp +++ b/source/engines/unity_engine/formulas.cpp @@ -38,10 +38,10 @@ namespace omath::unity_engine const float far, const NDCDepthRange ndc_depth_range) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) - return omath::mat_perspective_right_handed( + return omath::mat_perspective_right_handed_vertical_fov( field_of_view, aspect_ratio, near, far); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) - return omath::mat_perspective_right_handed(field_of_view, aspect_ratio, near, far); std::unreachable(); diff --git a/tests/general/unit_test_mat.cpp b/tests/general/unit_test_mat.cpp index 0059b12..5418862 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.1f, 1000.f); - const auto proj_right_handed = omath::mat_perspective_right_handed(90.f, 16.f / 9.f, 0.1f, 1000.f); + const auto proj_left_handed = omath::mat_perspective_left_handed_vertical_fov(90.f, 16.f / 9.f, 0.1f, 1000.f); + const auto proj_right_handed = omath::mat_perspective_right_handed_vertical_fov(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); @@ -233,7 +233,7 @@ TEST(UnitTestMatStandalone, Equanity) } TEST(UnitTestMatStandalone, MatPerspectiveLeftHanded) { - const auto perspective_proj = mat_perspective_left_handed(90.f, 16.f/9.f, 0.1f, 1000.f); + const auto perspective_proj = mat_perspective_left_handed_vertical_fov(90.f, 16.f/9.f, 0.1f, 1000.f); auto projected = perspective_proj * mat_column_from_vector({0, 0, 0.1001}); @@ -244,7 +244,7 @@ TEST(UnitTestMatStandalone, MatPerspectiveLeftHanded) TEST(UnitTestMatStandalone, MatPerspectiveLeftHandedZeroToOne) { - const auto proj = mat_perspective_left_handed( + const auto proj = mat_perspective_left_handed_vertical_fov( 90.f, 16.f / 9.f, 0.1f, 1000.f); // Near plane point should map to z ~ 0 @@ -266,7 +266,7 @@ TEST(UnitTestMatStandalone, MatPerspectiveLeftHandedZeroToOne) TEST(UnitTestMatStandalone, MatPerspectiveRightHandedZeroToOne) { - const auto proj = mat_perspective_right_handed( + const auto proj = mat_perspective_right_handed_vertical_fov( 90.f, 16.f / 9.f, 0.1f, 1000.f); // Near plane point (negative z for right-handed) should map to z ~ 0 @@ -289,8 +289,8 @@ TEST(UnitTestMatStandalone, MatPerspectiveRightHandedZeroToOne) TEST(UnitTestMatStandalone, MatPerspectiveNegativeOneToOneRange) { // Verify existing [-1, 1] behavior with explicit template arg matches default - const auto proj_default = mat_perspective_left_handed(90.f, 16.f / 9.f, 0.1f, 1000.f); - const auto proj_explicit = mat_perspective_left_handed(90.f, 16.f / 9.f, 0.1f, 1000.f); EXPECT_EQ(proj_default, proj_explicit); @@ -312,9 +312,9 @@ TEST(UnitTestMatStandalone, MatPerspectiveZeroToOneEquanity) constexpr omath::Vector3 left_handed = {0, 2, 10}; constexpr omath::Vector3 right_handed = {0, 2, -10}; - const auto proj_lh = mat_perspective_left_handed( + const auto proj_lh = mat_perspective_left_handed_vertical_fov( 90.f, 16.f / 9.f, 0.1f, 1000.f); - const auto proj_rh = mat_perspective_right_handed( + const auto proj_rh = mat_perspective_right_handed_vertical_fov( 90.f, 16.f / 9.f, 0.1f, 1000.f); auto ndc_lh = proj_lh * mat_column_from_vector(left_handed);