reverted is out of bounds check + added extra test

This commit is contained in:
2025-12-09 10:06:25 +03:00
parent 3744a6cdec
commit ff35571231
2 changed files with 13 additions and 10 deletions

View File

@@ -242,16 +242,7 @@ namespace omath::projection
template<class Type>
[[nodiscard]] constexpr static bool is_ndc_out_of_bounds(const Type& ndc) noexcept
{
const auto& raw_array = ndc.raw_array();
if (raw_array[2] < 0.f || raw_array[2] > 1.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;
return std::ranges::any_of(ndc.raw_array(), [](const auto& val) { return val < -1 || val > 1; });
}
// NDC REPRESENTATION:

View File

@@ -82,6 +82,18 @@ TEST(unit_test_unreal_engine, ProjectTargetMovedFromCamera)
EXPECT_NEAR(projected->y, 360, 0.00001f);
}
}
TEST(unit_test_unreal_engine, ProjectTargetMovedFromCameraBehind)
{
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
const auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 10000.f);
for (float distance = 0.02f; distance < 9000.f; distance += 100.f)
{
const auto projected = cam.world_to_screen({-distance, 0, 0});
EXPECT_FALSE(projected.has_value());
}
}
TEST(unit_test_unreal_engine, CameraSetAndGetFov)
{