Skip to content

Commit

Permalink
src/search: add tiny constant value to bbox size
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed May 2, 2024
1 parent 1819417 commit 6538c66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions editor/tests/path-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/search-astar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]]
Expand Down
2 changes: 1 addition & 1 deletion src/search-astar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class astar

// 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:
Expand Down

0 comments on commit 6538c66

Please sign in to comment.