diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-08-27 14:27:50 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-09-20 16:08:46 +0200 |
| commit | d34cf9c575fef03c6505939fa77ebedabfae413a (patch) | |
| tree | 98bf903345e73c5ff56c671472d6100c2a1a59b3 | |
| parent | b0e86fb89d8ea94601b0244f918df07a3fa82a9e (diff) | |
wip
| -rw-r--r-- | src/chunk-walls.cpp | 21 | ||||
| -rw-r--r-- | test/hole.cpp | 22 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp index 17aac134..14249671 100644 --- a/src/chunk-walls.cpp +++ b/src/chunk-walls.cpp @@ -41,6 +41,27 @@ using Wall::Direction_; using Wall::Frame; template<Group_ G, bool IsWest> +constexpr Quads::texcoords hole_to_texcoord(CutResult<float>::rect hole) +{ + static_assert(G < Group_::COUNT); + + switch (G) + { + using enum Group_; + case COUNT: fm_assert(false); + case wall: + fm_assert(false); + break; + case corner: + case side: + case top: + fm_assert(false); + } + //std::unreachable(); + return {}; +} + +template<Group_ G, bool IsWest> constexpr Quads::quad get_quad(float depth) { static_assert(G < Group_::COUNT); diff --git a/test/hole.cpp b/test/hole.cpp index ade06a9c..f5cbb345 100644 --- a/test/hole.cpp +++ b/test/hole.cpp @@ -1,6 +1,7 @@ #include "app.hpp" #include "src/hole.hpp" #include "src/hole-cut.hpp" +#include "src/tile-constants.hpp" namespace floormat { namespace { @@ -54,6 +55,25 @@ void test1(Vector2i offset) #endif } +auto make_search_predicate(const CutResult<int>& res) +{ + return [&](Vector2i min, Vector2i max) -> bool { + for (auto i = 0u; i < res.size; i++) + if (res.array[i].min == min && res.array[i].max == max) + return true; + return false; + }; +} + +void test2() +{ + const auto res = CutResult<int>::cut({{}, Vector2ub{tile_size_xy}}, {Vector2i(-tile_size_xy/2), Vector2ub{tile_size_xy}}); + fm_assert(res.size == 2); + const auto has = make_search_predicate(res); + fm_assert(has({-32, 0}, {32, 32})); + fm_assert(has({0, -32}, {32, 0})); +} + } // namespace void Test::test_hole() @@ -68,6 +88,8 @@ void Test::test_hole() for (auto offset : offsets) test1(offset); + + test2(); } } // namespace floormat |
