diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-09-09 14:42:29 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-09-20 16:08:47 +0200 |
commit | 40868868dd7ba77099637a23140bf90f9148c34d (patch) | |
tree | dcf2a12ea309a1c7a5d349dbd6f197769d7292d3 | |
parent | 8c276bb216a5ec870c8f30a3b1fa22dfee7b1ce3 (diff) |
src/hole: prep for wall hole rendering
-rw-r--r-- | src/hole-cut.cpp | 4 | ||||
-rw-r--r-- | test/hole.cpp | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/hole-cut.cpp b/src/hole-cut.cpp index 70f4ad34..7e580e9f 100644 --- a/src/hole-cut.cpp +++ b/src/hole-cut.cpp @@ -142,13 +142,13 @@ template<typename T> [[nodiscard]] constexpr bool check_empty(Vec2ʹ<T> r0, Vec2ʹ<T> r1, Vec2ʹ<T> h0, Vec2ʹ<T> h1) { - bool iempty = r0.x() == r1.x() | r0.y() == r1.y(); + //bool iempty = r0.x() == r1.x() | r0.y() == r1.y(); bool hempty = h0.x() == h1.x() | h0.y() == h1.y(); bool empty_before_x = h1.x() <= r0.x(); bool empty_after_x = h0.x() >= r1.x(); bool empty_before_y = h1.y() <= r0.y(); bool empty_after_y = h0.y() >= r1.y(); - return iempty | hempty | empty_before_x | empty_after_x | empty_before_y | empty_after_y; + return /*iempty |*/ hempty | empty_before_x | empty_after_x | empty_before_y | empty_after_y; } template<typename T> diff --git a/test/hole.cpp b/test/hole.cpp index f5cbb345..09395c47 100644 --- a/test/hole.cpp +++ b/test/hole.cpp @@ -74,6 +74,25 @@ void test2() fm_assert(has({0, -32}, {32, 0})); } +void test3() +{ + constexpr auto h = tile_size_xy/2; + + { + const auto res = CutResult<Int>::cut({-h, -1}, {h, 1}, {-2, -100}, {2, 100}); + fm_assert(res.found()); + fm_assert_equal(2, (int)res.size); + } + { + const auto res = CutResult<Int>::cut({-h, 0}, {h, 0}, {-2, -100}, {2, 100}); + fm_assert(res.found()); + fm_assert_equal(2, (int)res.size); + const auto has = make_search_predicate(res); + fm_assert(has({-h, 0}, {-2, 0})); + fm_assert(has({ 2, 0}, { h, 0})); + } +} + } // namespace void Test::test_hole() @@ -90,6 +109,7 @@ void Test::test_hole() test1(offset); test2(); + test3(); } } // namespace floormat |