summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-09-11 18:02:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-09-11 18:02:40 +0200
commiteb3f2bbd5b62063397d3ed4b4c6da2016e6efe8c (patch)
tree8109e18ea349e4efac29cf1d772f88f94a8c6d0a /src
parentee39bb46e698cb302e3c5a5cfb1a0f533fcea148 (diff)
fix rectangle intersection (still fails test)
Diffstat (limited to 'src')
-rw-r--r--src/path-search.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/path-search.cpp b/src/path-search.cpp
index b8c7c023..11fddce1 100644
--- a/src/path-search.cpp
+++ b/src/path-search.cpp
@@ -68,15 +68,14 @@ bool search::sample_rtree(world& w, chunk_coords_ ch0, Vector2 center, Vector2 s
static_assert(iTILE_SIZE2.x() == iTILE_SIZE2.y());
constexpr auto chunk_size = iTILE_SIZE2 * TILE_MAX_DIM;
constexpr int bbox_max = 1 << sizeof(Vector2b().x())*8;
- constexpr auto chunk_max = (chunk_size + Vector2i(bbox_max)).x();
+ constexpr auto chunk_max = chunk_size + Vector2i(bbox_max);
const auto off = Vector2(nb)*Vector2(chunk_size);
- const auto min_ = min + off, max_ = max + off;
+ const auto min_ = min - off, max_ = max - off;
- const auto bmin = std::min({ min_.x(), min_.y(), max_.x(), max_.y() }),
- bmax = std::max({ min_.x(), min_.y(), max_.x(), max_.y() });
-
- if (bmin < -bbox_max || bmax > chunk_max)
+ if (min_.x() > chunk_max.x() || min_.y() > chunk_max.y())
+ continue;
+ if (max_.x() < -bbox_max || max_.y() < -bbox_max)
continue;
if (auto* c2 = w.at(ch0 + Vector2i(nb)))