From b0bd58ccb20903431039fe23c63497d92272fa21 Mon Sep 17 00:00:00 2001 From: Orange Date: Sat, 20 Sep 2025 16:36:05 +0300 Subject: [PATCH] improved opengl tests stability --- tests/engines/unit_test_open_gl.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/engines/unit_test_open_gl.cpp b/tests/engines/unit_test_open_gl.cpp index 57e92b9..f407f97 100644 --- a/tests/engines/unit_test_open_gl.cpp +++ b/tests/engines/unit_test_open_gl.cpp @@ -37,8 +37,6 @@ TEST(unit_test_opengl, ForwardVectorRotationYaw) EXPECT_NEAR(forward.z, omath::opengl_engine::k_abs_right.z, 0.00001f); } - - TEST(unit_test_opengl, ForwardVectorRotationPitch) { omath::opengl_engine::ViewAngles angles; @@ -68,7 +66,6 @@ TEST(unit_test_opengl, ProjectTargetMovedFromCamera) constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f); const auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f); - for (float distance = -10.f; distance > -1000.f; distance -= 0.01f) { const auto projected = cam.world_to_screen({0, 0, distance}); @@ -111,8 +108,6 @@ TEST(unit_test_opengl_engine, loook_at_random_all_axis) constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f); auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f); - - std::size_t failed_points = 0; for (int i = 0; i < 1000; i++) { @@ -130,7 +125,7 @@ TEST(unit_test_opengl_engine, loook_at_random_all_axis) if (!projected_pos) continue; - if (std::abs(projected_pos->x-0.f) >= 0.01f || std::abs(projected_pos->y-0.f) >= 0.01f) + if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f) failed_points++; } EXPECT_LE(failed_points, 100); @@ -144,11 +139,13 @@ TEST(unit_test_opengl_engine, loook_at_random_x_axis) constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f); auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f); - - for (int i = 0; i < 1000; i++) { const auto position_to_look = omath::Vector3{dist(gen), 0.f, 0.f}; + + if (cam.get_origin().distance_to(position_to_look) < 10) + continue; + cam.look_at(position_to_look); auto projected_pos = cam.world_to_view_port(position_to_look); @@ -171,11 +168,13 @@ TEST(unit_test_opengl_engine, loook_at_random_y_axis) constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f); auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f); - - for (int i = 0; i < 1000; i++) { const auto position_to_look = omath::Vector3{0.f, dist(gen), 0.f}; + + if (cam.get_origin().distance_to(position_to_look) < 10) + continue; + cam.look_at(position_to_look); auto projected_pos = cam.world_to_view_port(position_to_look); @@ -198,11 +197,12 @@ TEST(unit_test_opengl_engine, loook_at_random_z_axis) constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f); auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f); - - for (int i = 0; i < 1000; i++) { const auto position_to_look = omath::Vector3{0.f, 0.f, dist(gen)}; + + if (cam.get_origin().distance_to(position_to_look) < 10) + continue; cam.look_at(position_to_look); auto projected_pos = cam.world_to_view_port(position_to_look);