Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed Aug 29, 2024
1 parent 118bd56 commit 64261c9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/chunk-walls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ using Wall::Group_;
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)
{
Expand Down
22 changes: 22 additions & 0 deletions test/hole.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "app.hpp"
#include "src/hole.hpp"
#include "src/hole-cut.hpp"
#include "src/tile-constants.hpp"

namespace floormat {
namespace {
Expand Down Expand Up @@ -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()
Expand All @@ -68,6 +88,8 @@ void Test::test_hole()

for (auto offset : offsets)
test1(offset);

test2();
}

} // namespace floormat

0 comments on commit 64261c9

Please sign in to comment.