diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-06-07 23:37:51 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-06-08 01:11:44 +0200 |
commit | 05804f5f7f8b2dfad65e51a0e37ccb3c16b4d477 (patch) | |
tree | d2b7d8d65bb3944c26303cd4e1c0a39e21aefc4c | |
parent | ec524fddfa0d2583d06ee194b06720be0eee8341 (diff) |
a
-rw-r--r-- | test/collisions.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/collisions.cpp b/test/collisions.cpp index c675546d..958676d0 100644 --- a/test/collisions.cpp +++ b/test/collisions.cpp @@ -2,6 +2,7 @@ #include "src/world.hpp" #include "src/critter.hpp" #include "src/RTree.hpp" +#include "src/nanosecond.inl" #include "loader/loader.hpp" namespace floormat { @@ -43,12 +44,39 @@ void test1() (void)index; } +void test2() +{ + auto w = world(); + constexpr auto ch = chunk_coords_{0, 0, 0}; + constexpr auto pos = global_coords{ch, {0, 0}}; + auto& c = w[ch]; + fm_assert(c.rtree()->Count() == 0); + auto C = w.make_object<critter>(w.make_id(), pos, make_critter_proto()); + fm_assert(C->offset == Vector2b{}); + fm_assert(c.objects().size() == 1); + fm_assert(c.rtree()->Count() == 1); + auto index = C->index(); + bool moved = false; + c.ensure_passability(); + for (int i = 0; i < tile_size_xy*2; i++) + { + auto dt = Ns{Seconds / 60}; + auto result = C->move_toward(index, dt, {{-10, 0, 0}, {}, {}}); + fm_assert(!result.blocked); + moved |= result.moved; + fm_assert(!c.is_passability_modified()); + fm_assert(c.rtree()->Count() < 2); + } + fm_assert(moved); +} + } // namespace void Test::test_collisions() { test1(); + test2(); } } // namespace floormat |