diff --git a/include/omath/projection/camera.hpp b/include/omath/projection/camera.hpp index 35bb1f0..4fca833 100644 --- a/include/omath/projection/camera.hpp +++ b/include/omath/projection/camera.hpp @@ -242,7 +242,16 @@ namespace omath::projection template [[nodiscard]] constexpr static bool is_ndc_out_of_bounds(const Type& ndc) noexcept { - return std::ranges::any_of(ndc.raw_array(), [](const auto& val) { return val < -1 || val > 1; }); + const auto& raw_array = ndc.raw_array(); + + if (raw_array[2] < 0.f) + return true; + + for (std::size_t i = 0; i < 2; i++) + if (raw_array[i] < -1.f || raw_array[i] > 1.f) + return true; + + return false; } // NDC REPRESENTATION: diff --git a/source/engines/unreal_engine/formulas.cpp b/source/engines/unreal_engine/formulas.cpp index e4a0ad9..9b40124 100644 --- a/source/engines/unreal_engine/formulas.cpp +++ b/source/engines/unreal_engine/formulas.cpp @@ -37,13 +37,6 @@ namespace omath::unreal_engine Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, const float far) noexcept { - const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f); - - return { - {1.f / (aspect_ratio * fov_half_tan), 0, 0, 0}, - {0, 1.f / (fov_half_tan), 0, 0}, - {0, 0, (far + near) / (far - near), -(2.f * far * near) / (far - near)}, - {0, 0, -1.f, 0}, - }; + return mat_perspective_left_handed(field_of_view, aspect_ratio, near, far); } } // namespace omath::unreal_engine