diff --git a/include/omath/engines/cry_engine/formulas.hpp b/include/omath/engines/cry_engine/formulas.hpp index 0338260..18d8e9a 100644 --- a/include/omath/engines/cry_engine/formulas.hpp +++ b/include/omath/engines/cry_engine/formulas.hpp @@ -70,17 +70,17 @@ namespace omath::cry_engine } [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::ZERO_TO_ONE) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_left_handed_vertical_fov( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_left_handed_vertical_fov( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/cry_engine/traits/camera_trait.hpp b/include/omath/engines/cry_engine/traits/camera_trait.hpp index 58e2927..7137581 100644 --- a/include/omath/engines/cry_engine/traits/camera_trait.hpp +++ b/include/omath/engines/cry_engine/traits/camera_trait.hpp @@ -29,9 +29,10 @@ namespace omath::cry_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/frostbite_engine/formulas.hpp b/include/omath/engines/frostbite_engine/formulas.hpp index 7f7b115..3ea697e 100644 --- a/include/omath/engines/frostbite_engine/formulas.hpp +++ b/include/omath/engines/frostbite_engine/formulas.hpp @@ -75,17 +75,17 @@ namespace omath::frostbite_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_left_handed_vertical_fov( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_left_handed_vertical_fov( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/frostbite_engine/traits/camera_trait.hpp b/include/omath/engines/frostbite_engine/traits/camera_trait.hpp index 9156a76..866f188 100644 --- a/include/omath/engines/frostbite_engine/traits/camera_trait.hpp +++ b/include/omath/engines/frostbite_engine/traits/camera_trait.hpp @@ -31,9 +31,10 @@ namespace omath::frostbite_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/iw_engine/formulas.hpp b/include/omath/engines/iw_engine/formulas.hpp index 6cb962f..042af08 100644 --- a/include/omath/engines/iw_engine/formulas.hpp +++ b/include/omath/engines/iw_engine/formulas.hpp @@ -72,7 +72,7 @@ namespace omath::iw_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { constexpr float k_source_reference_aspect = 4.f / 3.f; @@ -80,11 +80,11 @@ namespace omath::iw_engine if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_left_handed_vertical_fov( - vertical_fov, aspect_ratio, near, far); + vertical_fov, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_left_handed_vertical_fov( - vertical_fov, aspect_ratio, near, far); + vertical_fov, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/iw_engine/traits/camera_trait.hpp b/include/omath/engines/iw_engine/traits/camera_trait.hpp index a50a87d..10be763 100644 --- a/include/omath/engines/iw_engine/traits/camera_trait.hpp +++ b/include/omath/engines/iw_engine/traits/camera_trait.hpp @@ -31,9 +31,10 @@ namespace omath::iw_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/opengl_engine/formulas.hpp b/include/omath/engines/opengl_engine/formulas.hpp index c74c0a4..424d337 100644 --- a/include/omath/engines/opengl_engine/formulas.hpp +++ b/include/omath/engines/opengl_engine/formulas.hpp @@ -75,18 +75,18 @@ namespace omath::opengl_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_right_handed_vertical_fov< float, MatStoreType::COLUMN_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_right_handed_vertical_fov< float, MatStoreType::COLUMN_MAJOR, NDCDepthRange::ZERO_TO_ONE>( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/opengl_engine/traits/camera_trait.hpp b/include/omath/engines/opengl_engine/traits/camera_trait.hpp index f16457c..cd0e43e 100644 --- a/include/omath/engines/opengl_engine/traits/camera_trait.hpp +++ b/include/omath/engines/opengl_engine/traits/camera_trait.hpp @@ -32,9 +32,10 @@ namespace omath::opengl_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/rage_engine/formulas.hpp b/include/omath/engines/rage_engine/formulas.hpp index f2bc04f..d89493b 100644 --- a/include/omath/engines/rage_engine/formulas.hpp +++ b/include/omath/engines/rage_engine/formulas.hpp @@ -76,17 +76,17 @@ namespace omath::rage_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::ZERO_TO_ONE) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_left_handed_vertical_fov( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_left_handed_vertical_fov( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/rage_engine/traits/camera_trait.hpp b/include/omath/engines/rage_engine/traits/camera_trait.hpp index 8395af8..7dc013f 100644 --- a/include/omath/engines/rage_engine/traits/camera_trait.hpp +++ b/include/omath/engines/rage_engine/traits/camera_trait.hpp @@ -31,9 +31,10 @@ namespace omath::rage_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/source_engine/formulas.hpp b/include/omath/engines/source_engine/formulas.hpp index 60e3d7c..5a7b523 100644 --- a/include/omath/engines/source_engine/formulas.hpp +++ b/include/omath/engines/source_engine/formulas.hpp @@ -71,7 +71,7 @@ namespace omath::source_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { constexpr float k_source_reference_aspect = 4.f / 3.f; @@ -79,11 +79,11 @@ namespace omath::source_engine if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_left_handed_vertical_fov( - vertical_fov, aspect_ratio, near, far); + vertical_fov, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_left_handed_vertical_fov( - vertical_fov, aspect_ratio, near, far); + vertical_fov, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/source_engine/traits/camera_trait.hpp b/include/omath/engines/source_engine/traits/camera_trait.hpp index 09d9ed9..61cc9c7 100644 --- a/include/omath/engines/source_engine/traits/camera_trait.hpp +++ b/include/omath/engines/source_engine/traits/camera_trait.hpp @@ -31,9 +31,10 @@ namespace omath::source_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/unity_engine/formulas.hpp b/include/omath/engines/unity_engine/formulas.hpp index 65e8356..350b30b 100644 --- a/include/omath/engines/unity_engine/formulas.hpp +++ b/include/omath/engines/unity_engine/formulas.hpp @@ -75,17 +75,17 @@ namespace omath::unity_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const float field_of_view, const float aspect_ratio, const float near, const float far, + const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return omath::mat_perspective_right_handed_vertical_fov< float, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return omath::mat_perspective_right_handed_vertical_fov< float, MatStoreType::ROW_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/unity_engine/traits/camera_trait.hpp b/include/omath/engines/unity_engine/traits/camera_trait.hpp index c7b89ed..08faafb 100644 --- a/include/omath/engines/unity_engine/traits/camera_trait.hpp +++ b/include/omath/engines/unity_engine/traits/camera_trait.hpp @@ -31,9 +31,10 @@ namespace omath::unity_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept + const float near_plane, const float far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/include/omath/engines/unreal_engine/formulas.hpp b/include/omath/engines/unreal_engine/formulas.hpp index 4df684d..558afb7 100644 --- a/include/omath/engines/unreal_engine/formulas.hpp +++ b/include/omath/engines/unreal_engine/formulas.hpp @@ -75,17 +75,17 @@ namespace omath::unreal_engine [[nodiscard]] inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix( - const double field_of_view, const double aspect_ratio, const double near, const double far, + const double field_of_view, const double aspect_ratio, const double near_plane, const double far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE) return mat_perspective_left_handed_horizontal_fov< double, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE) return mat_perspective_left_handed_horizontal_fov< double, MatStoreType::ROW_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>( - field_of_view, aspect_ratio, near, far); + field_of_view, aspect_ratio, near_plane, far_plane); std::unreachable(); } diff --git a/include/omath/engines/unreal_engine/traits/camera_trait.hpp b/include/omath/engines/unreal_engine/traits/camera_trait.hpp index 826e17d..cb04cec 100644 --- a/include/omath/engines/unreal_engine/traits/camera_trait.hpp +++ b/include/omath/engines/unreal_engine/traits/camera_trait.hpp @@ -31,9 +31,10 @@ namespace omath::unreal_engine [[nodiscard]] OMATH_CONSTEXPR static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port, - const double near, const double far, const NDCDepthRange ndc_depth_range) noexcept + const double near_plane, const double far_plane, + const NDCDepthRange ndc_depth_range) noexcept { - return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far, + return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane, ndc_depth_range); } }; diff --git a/tests/general/unit_test_projection.cpp b/tests/general/unit_test_projection.cpp index 0c5cebd..8c7f4b9 100644 --- a/tests/general/unit_test_projection.cpp +++ b/tests/general/unit_test_projection.cpp @@ -84,13 +84,13 @@ static_assert(source_camera_constexpr_projection_round_trip()); TEST(UnitTestProjection, Projection) { - constexpr auto fov = omath::Angle::from_degrees(90.f); - constexpr auto cam = omath::source_engine::Camera({0, 0, 0}, omath::source_engine::ViewAngles{}, {1920.f, 1080.f}, fov, - 0.01f, 1000.f); + OMATH_CONSTEXPR auto fov = omath::Angle::from_degrees(90.f); + OMATH_CONSTEXPR auto cam = omath::source_engine::Camera( + {0, 0, 0}, omath::source_engine::ViewAngles{}, {1920.f, 1080.f}, fov, 0.01f, 1000.f); - constexpr auto projected = cam.world_to_screen({1000.f, 0, 50.f}); - constexpr auto result = cam.screen_to_world(projected.value()); - constexpr auto result2 = cam.world_to_screen(result.value()); + OMATH_CONSTEXPR auto projected = cam.world_to_screen({1000.f, 0, 50.f}); + OMATH_CONSTEXPR auto result = cam.screen_to_world(projected.value()); + OMATH_CONSTEXPR auto result2 = cam.world_to_screen(result.value()); EXPECT_EQ(static_cast>(projected.value()), static_cast>(result2.value()));