mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
fixed bug due to on screen ndc check
This commit is contained in:
@@ -242,7 +242,16 @@ namespace omath::projection
|
||||
template<class Type>
|
||||
[[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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user