From eeb89c9b1c64a3f738fd2790a15a6232d5e3e0bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Mar 2024 23:59:19 +0100 Subject: w --- src/search-result.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/search-result.cpp b/src/search-result.cpp index 8e21f8aa..4f25065d 100644 --- a/src/search-result.cpp +++ b/src/search-result.cpp @@ -3,7 +3,7 @@ #include "compat/assert.hpp" #include "compat/vector-wrapper.hpp" #include "search-node.hpp" -#include "src/point.hpp" +#include "src/point.inl" #include #include @@ -11,13 +11,50 @@ namespace floormat { namespace { -constexpr auto min_length = TILE_MAX_DIM*2; +struct off_pair +{ + unsigned val; + bool is_bad; + constexpr bool operator==(const off_pair&) const = default; +}; + +template constexpr off_pair offset_is_bad(Int x) +{ + switch (x) + { + case Int{-1}: + case Int{ 1}: + case Int{ 0}: + return { (unsigned(Int{1} + x)) << N, false }; + default: + return { (unsigned)-1, true }; + } +} +#if 0 +static_assert((2 | 2 << 8) == (offset_is_bad<0>(Int{1}).val | offset_is_bad<8>(Int{1}).val)); +static_assert((2 | 1 << 8) == (offset_is_bad<0>(Int{1}).val | offset_is_bad<8>(Int{0}).val)); +static_assert((1 | 1 << 8) == (offset_is_bad<0>(Int{0}).val | offset_is_bad<8>(Int{0}).val)); +static_assert((0 | 2 << 8) == (offset_is_bad<0>(Int{-1}).val | offset_is_bad<8>(Int{1}).val)); +static_assert((unsigned)-1 == (offset_is_bad<0>(Int{4242}).val | offset_is_bad<8>(Int{1}).val)); +#endif void simplify_path(const std::vector& src, std::vector& dest) { dest.clear(); + dest.reserve(src.size()); fm_assert(!src.empty()); + fm_assert(src.size() >= 2); + const auto size = (uint32_t)src.size(); + dest.push_back({src[0], 0}); + + auto last = src[0]; + auto cur = src[1] - src[0]; + size_t len = 1; + for (auto i = 1u; i < size; i++) + { + + } } } // namespace @@ -26,6 +63,7 @@ Pointer path_search_result::_pool; // NOLINT path_search_result::path_search_result() { + constexpr auto min_length = TILE_MAX_DIM*2; if (_pool) { auto ptr = move(_pool); -- cgit v1.2.3