From f3f153ad0fb35aae25cdd7f7071d3bbd892db9f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 11 Sep 2023 18:02:50 +0200 Subject: add failing test --- src/path-search.cpp | 9 +++++---- src/path-search.hpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/path-search.cpp b/src/path-search.cpp index 11fddce1..1f9b5bf9 100644 --- a/src/path-search.cpp +++ b/src/path-search.cpp @@ -54,9 +54,8 @@ bool search::sample_rtree_1(chunk& c, Vector2 min, Vector2 max, object_id own_id return is_passable; } -bool search::sample_rtree(world& w, chunk_coords_ ch0, Vector2 center, Vector2 size, object_id own_id) +bool search::sample_rtree(world& w, chunk_coords_ ch0, Vector2 min, Vector2 max, object_id own_id) { - const auto min = center - size*.5f, max = min + size; if (auto* c = w.at(ch0)) // it's not correct to return true if c == nullptr // because neighbors can still contain bounding boxes for that tile @@ -85,10 +84,12 @@ bool search::sample_rtree(world& w, chunk_coords_ ch0, Vector2 center, Vector2 s return true; } -bool search::sample_rtree(world& w, global_coords coord, Vector2b offset, Vector2ub size, object_id own_id) +bool search::sample_rtree(world& w, global_coords coord, Vector2b offset, Vector2ub size_, object_id own_id) { auto center = iTILE_SIZE2 * Vector2i(coord.local()) + Vector2i(offset); - return sample_rtree(w, coord, Vector2(center), Vector2(size), own_id); + auto size = Vector2(size_); + auto min = Vector2(center) - size*.5f, max = min + size; + return sample_rtree(w, coord, min, max, own_id); } auto search::make_neighbor_tile_bbox(Vector2i coord, Vector2ub own_size, rotation r) -> bbox diff --git a/src/path-search.hpp b/src/path-search.hpp index f044a381..cb58f531 100644 --- a/src/path-search.hpp +++ b/src/path-search.hpp @@ -87,7 +87,7 @@ public: Optional operator()(world& w, const object& obj, global_coords to, Vector2b to_offset); static bool sample_rtree_1(chunk& c, Vector2 min, Vector2 max, object_id own_id); - static bool sample_rtree(world& w, chunk_coords_ ch0, Vector2 center, Vector2 size, object_id own_id); + static bool sample_rtree(world& w, chunk_coords_ ch0, Vector2 min, Vector2 max, object_id own_id); static bool sample_rtree(world& w, global_coords coord, Vector2b offset, Vector2ub size, object_id own_id); static bbox make_neighbor_tile_bbox(Vector2i coord, Vector2ub own_size, rotation r); -- cgit v1.2.3