1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#include "app.hpp"
#include "compat/assert.hpp"
#include "loader/loader.hpp"
#include "src/world.hpp"
#include "src/scenery.hpp"
#include "src/path-search.hpp"
namespace floormat {
namespace {
void test_bbox()
{
constexpr auto is_passable_1 = [](chunk& c, path_search::bbox bb) {
return path_search::is_passable_1(c, bb.min, bb.max, (object_id)-1);
};
constexpr auto is_passable = [](world& w, chunk_coords_ ch, path_search::bbox bb) {
return path_search::is_passable(w, ch, bb.min, bb.max, (object_id)-1);
};
constexpr auto bbox = [](Vector2i coord, rotation r) {
return path_search::make_neighbor_tile_bbox(coord, {}, r);
};
const auto metal2 = loader.tile_atlas("metal2", {2, 2}, pass_mode::blocked);
const auto table = loader.scenery("table1");
{
constexpr auto coord1 = chunk_coords_{10, 11, 0},
coord2 = chunk_coords_{10, 12, 0};
constexpr auto _15 = TILE_MAX_DIM-1;
using enum rotation;
{
auto w = world();
[[maybe_unused]] auto& c12 = w[coord2];
[[maybe_unused]] auto& c11 = w[coord1];
c12[{0, 0}].wall_north() = {metal2, 0};
fm_assert( !is_passable_1(c12, bbox({}, N)) );
fm_assert( is_passable_1(c12, bbox({}, E)) );
fm_assert( is_passable_1(c12, bbox({}, S)) );
fm_assert( is_passable_1(c12, bbox({}, W)) );
fm_assert( is_passable(w, coord1, bbox({0, _15}, N)) );
fm_assert( is_passable(w, coord1, bbox({0, _15}, E)) );
fm_assert( !is_passable(w, coord1, bbox({0, _15}, S)) );
fm_assert( is_passable(w, coord1, bbox({0, _15}, W)) );
}
}
{
using enum rotation;
constexpr auto C = rotation_COUNT;
constexpr auto ch = chunk_coords_{21, 22, 0};
auto w = world();
auto& c = w[ch];
c[{8, 7}].wall_north() = {metal2,0};
c[{8, 9}].wall_north() = {metal2,0};
fm_assert( is_passable_1(c, bbox({8, 8}, N)) );
fm_assert( is_passable_1(c, bbox({8, 8}, E)) );
fm_assert( !is_passable_1(c, bbox({8, 8}, S)) );
fm_assert( is_passable_1(c, bbox({8, 8}, W)) );
c[{8, 8}].wall_north() = {metal2,0};
c.mark_passability_modified();
fm_assert( is_passable_1(c, bbox({8, 8}, C)));
fm_assert( !is_passable_1(c, bbox({8, 8}, N)) );
fm_assert( is_passable_1(c, bbox({8, 8}, E)) );
fm_assert( !is_passable_1(c, bbox({8, 8}, S)) );
fm_assert( is_passable_1(c, bbox({8, 8}, W)) );
}
// todo use test chunk
}
} // namespace
void test_app::test_path_search()
{
test_bbox();
}
} // namespace floormat
|