summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-03 01:35:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-03 01:48:01 +0200
commit6538c66308b98bc0f9875355b1247502aff7c07c (patch)
treeac98846492ff23e83af41bd440c2c3521fcc42bc
parent181941780ae82c394754be42d28b92e57301fa77 (diff)
src/search: add tiny constant value to bbox size
-rw-r--r--editor/tests/path-test.cpp5
-rw-r--r--src/search-astar.cpp6
-rw-r--r--src/search-astar.hpp2
3 files changed, 8 insertions, 5 deletions
diff --git a/editor/tests/path-test.cpp b/editor/tests/path-test.cpp
index b5161e9f..84886a65 100644
--- a/editor/tests/path-test.cpp
+++ b/editor/tests/path-test.cpp
@@ -30,7 +30,7 @@ struct path_test final : base_test
point from, to;
object_id own_id;
uint32_t max_dist;
- Vector2ub own_size;
+ Vector2ui own_size;
} pending = {};
struct result_s
@@ -67,7 +67,8 @@ bool path_test::handle_mouse_click(app& a, const mouse_button_event& e, bool is_
has_pending = true;
pending = { .from = pt0, .to = *pt, .own_id = C->id,
- .max_dist = dist, .own_size = C->bbox_size, };
+ .max_dist = dist,
+ .own_size = Vector2ui(C->bbox_size) + Vector2ui(2), };
}
return true;
}
diff --git a/src/search-astar.cpp b/src/search-astar.cpp
index 1f1663f9..e86e6bee 100644
--- a/src/search-astar.cpp
+++ b/src/search-astar.cpp
@@ -192,7 +192,7 @@ uint32_t astar::pop_from_heap()
}
path_search_result astar::Dijkstra(world& w, const point from, const point to,
- object_id own_id, uint32_t max_dist, Vector2ub own_size_,
+ object_id own_id, uint32_t max_dist, Vector2ui own_size_,
int debug, const pred& p)
{
#ifdef FM_NO_DEBUG
@@ -207,7 +207,9 @@ path_search_result astar::Dijkstra(world& w, const point from, const point to,
auto& cache = *_cache;
cache.allocate(from, max_dist);
- const auto own_size = Math::max(Vector2ui(own_size_), min_size);
+ constexpr auto size_max = uint32_t{tile_size_xy}*uint32_t{TILE_MAX_DIM};
+ fm_assert(own_size_ < Vector2ui{size_max});
+ const auto own_size = Math::max(own_size_, min_size);
constexpr auto goal_thres = (uint32_t)(div_size.length() + 1.5f);
if (from.coord().z() != to.coord().z()) [[unlikely]]
diff --git a/src/search-astar.hpp b/src/search-astar.hpp
index 61553f80..dee9f5d6 100644
--- a/src/search-astar.hpp
+++ b/src/search-astar.hpp
@@ -26,7 +26,7 @@ public:
// todo add simple bresenham short-circuit
path_search_result Dijkstra(world& w, point from, point to,
- object_id own_id, uint32_t max_dist, Vector2ub own_size,
+ object_id own_id, uint32_t max_dist, Vector2ui own_size,
int debug = 0, const pred& p = Search::never_continue());
private: