diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-05 21:32:57 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-06 01:35:11 +0100 |
| commit | 0a6612286bfa8c2503c757da2b39da37aa05deaf (patch) | |
| tree | 3606dbe2ee59026f0fcdba7377034dfcab13da0d /test/bbox.cpp | |
| parent | 2679d49a53a3f9825ce855f6ed25b3b045ec5aa1 (diff) | |
src/chunk: plug in lqt for collision detection
Diffstat (limited to 'test/bbox.cpp')
| -rw-r--r-- | test/bbox.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/bbox.cpp b/test/bbox.cpp new file mode 100644 index 00000000..c045d858 --- /dev/null +++ b/test/bbox.cpp @@ -0,0 +1,28 @@ +#include "app.hpp" +#include "src/chunk.hpp" +#include "compat/LooseQuadtree-impl.h" +#include <Magnum/Math/Vector2.h> + +namespace floormat { + +void test_app::test_bbox() +{ + auto c = make_test_chunk(); + auto& qt = c.ensure_passability(); + fm_assert(qt.GetSize() >= 2); + + using namespace loose_quadtree; + using bbox = BoundingBox<std::int16_t>; + constexpr auto pos1 = Vector2s(iTILE_SIZE2 * (TILE_MAX_DIM/2) - Vector2i(0, iTILE_SIZE[1]/2)), + size = Vector2s(iTILE_SIZE2); + constexpr auto b1 = bbox{pos1[0], pos1[1], size[0], size[1]}; + constexpr auto pos2 = Vector2s(iTILE_SIZE2 * (Vector2i(TILE_MAX_DIM/2) - Vector2i(-1, -1)) - Vector2i(0, iTILE_SIZE[1]/2)); + auto q1 = qt.QueryIntersectsRegion(b1); + fm_assert(!q1.EndOfQuery()); + do q1.Next(); while (!q1.EndOfQuery()); + constexpr auto b2 = bbox{pos2[0], pos2[1], size[0], size[1]}; + auto q2 = qt.QueryIntersectsRegion(b2); + fm_assert(q2.EndOfQuery()); +} + +} // namespace floormat |
