summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-24 23:59:19 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-25 01:45:01 +0100
commiteeb89c9b1c64a3f738fd2790a15a6232d5e3e0bf (patch)
tree88433e428b206cb1a76c15026692887f24dd80eb /src
parent88de6c67ff8fd2d8c9e311b0a518c797ae53bcd4 (diff)
w
Diffstat (limited to 'src')
-rw-r--r--src/search-result.cpp42
1 files changed, 40 insertions, 2 deletions
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 <cr/ArrayView.h>
#include <mg/Functions.h>
@@ -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<unsigned N> 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<point>& src, std::vector<path_search_result::pair>& 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::node> 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);