improvement

This commit is contained in:
2026-02-05 23:27:31 +03:00
parent 63b4327c91
commit 32e0f9e636
8 changed files with 92 additions and 93 deletions

View File

@@ -47,7 +47,7 @@ namespace
// -----------------------------------------------------------------------------
struct TraceCase
{
Ray ray;
Ray<> ray;
bool expected_clear; // true => segment does NOT hit the triangle
friend std::ostream& operator<<(std::ostream& os, const TraceCase& tc)
{
@@ -66,7 +66,7 @@ namespace
TEST_P(CanTraceLineParam, VariousRays)
{
const auto& [ray, expected_clear] = GetParam();
EXPECT_EQ(LineTracer::can_trace_line(ray, triangle), expected_clear);
EXPECT_EQ(LineTracer<>::can_trace_line(ray, triangle), expected_clear);
}
INSTANTIATE_TEST_SUITE_P(
@@ -91,7 +91,7 @@ namespace
constexpr Ray ray{{0.3f, 0.3f, -1.f}, {0.3f, 0.3f, 1.f}};
constexpr Vec3 expected{0.3f, 0.3f, 0.f};
const Vec3 hit = LineTracer::get_ray_hit_point(ray, triangle);
const Vec3 hit = LineTracer<>::get_ray_hit_point(ray, triangle);
ASSERT_FALSE(vec_equal(hit, ray.end));
EXPECT_TRUE(vec_equal(hit, expected));
}
@@ -106,7 +106,7 @@ namespace
{1001.f, 1000.f, 1000.f},
{1000.f, 1001.f, 1000.f}};
EXPECT_TRUE(LineTracer::can_trace_line(short_ray, distant));
EXPECT_TRUE(LineTracer<>::can_trace_line(short_ray, distant));
}
TEST(unit_test_unity_engine, CantHit)
@@ -115,13 +115,13 @@ namespace
constexpr Ray ray{{}, {1.0, 0, 0}, false};
EXPECT_TRUE(omath::collision::LineTracer::can_trace_line(ray, triangle));
EXPECT_TRUE(omath::collision::LineTracer<>::can_trace_line(ray, triangle));
}
TEST(unit_test_unity_engine, CanHit)
{
constexpr omath::Triangle<Vector3<float>> triangle{{2, 0, 0}, {2, 2, 0}, {2, 2, 2}};
constexpr Ray ray{{}, {2.1, 0, 0}, false};
EXPECT_FALSE(omath::collision::LineTracer::can_trace_line(ray, triangle));
EXPECT_FALSE(omath::collision::LineTracer<>::can_trace_line(ray, triangle));
}
} // namespace