diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-09 08:32:42 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-09 08:32:42 +0200 |
commit | e5876e1627597076a26b0c3b49b132705fc4b760 (patch) | |
tree | 5cfc8cc9b511bda34df4210125a2d786a70256e9 | |
parent | 003b0bf828408e8b95ccab404f0c7fca0d7de362 (diff) |
a
-rw-r--r-- | src/object.cpp | 3 | ||||
-rw-r--r-- | test/coords.cpp | 17 | ||||
-rw-r--r-- | test/main.cpp | 4 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/object.cpp b/src/object.cpp index d5133337..848fad64 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -116,6 +116,7 @@ point object::normalize_coords(global_coords coord, Vector2b cur_offset, Vector2 { auto off_tmp = Vector2i(cur_offset) + new_offset; auto off_new = off_tmp % iTILE_SIZE2; + auto tiles = off_tmp / iTILE_SIZE2; constexpr auto half_tile = iTILE_SIZE2/2; for (auto i = 0uz; i < 2; i++) { @@ -129,7 +130,7 @@ point object::normalize_coords(global_coords coord, Vector2b cur_offset, Vector2 off_new[i] = (iTILE_SIZE[i] - absval)*-sign; } } - return { coord, Vector2b(off_new) }; + return { coord + tiles, Vector2b(off_new) }; } point object::normalize_coords(const point& pt, Vector2i delta) diff --git a/test/coords.cpp b/test/coords.cpp index f673e7cd..62f86fc5 100644 --- a/test/coords.cpp +++ b/test/coords.cpp @@ -9,13 +9,16 @@ constexpr auto norm = [](const point& pt, Vector2i delta) { return object::norma void test_normalize_point() { - auto a = point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }, - b = point{{{ 0, -1, 0}, {15, 15}}, { 0, 0} }, - c = point{{{-1, 1, 1}, { 0, 0}}, { 1, 31} }, - d = point{{{ 1, 0, 1}, {15, 15}}, {-31, 31} }, - e = point{{{ 1, 0, 1}, {15, 15}}, {-31, 31} }; - - fm_assert_equal(norm(a, {}), point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }); + auto a = point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }, + b = point{{{ -1, 1, 0}, { 0, 15}}, { 0, 0} }, + c = point{{{ -1, 1, 1}, { 0, 0}}, { 1, 31} }, + d = point{{{ 1, 0, 1}, {15, 15}}, {-31, 31} }, + e = point{{{ 1, 0, 1}, {15, 15}}, {-31, 31} }, + f = point{{{16384, -16384, 2}, {15, 0}}, {1, 2} }; + + fm_assert_equal(norm(a, {}), point{{{ 0, 0, 0}, { 0, 0}}, { 0, 0} }); + fm_assert_equal(norm(b, { 1, -1}), point{{{ -1, 1 , 0}, { 0, 15}}, { 1, -1} }); + fm_assert_equal(norm(b, { -65, 65}), point{{{ -2, 2, 0}, {15, 0}}, { -1, 1} }); } } // namespace diff --git a/test/main.cpp b/test/main.cpp index 7855a87a..af64dfec 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -33,8 +33,10 @@ int test_app::exec() test_math(); test_hash(); test_path_search_node_pool(); - test_dijkstra(); test_coords(); + + test_dijkstra(); + zzz_test_misc(); return 0; |