diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-13 03:40:46 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-13 04:48:56 +0200 |
commit | ba8b4579d3daa545c98f6e6ef19e02f155515c88 (patch) | |
tree | c6e46405b09b53929077ffc67b87a36079df8ece /src | |
parent | ded20797c675228ff3d5c0bbc1e5f370e7f157b1 (diff) |
add right names for predicate functions
Diffstat (limited to 'src')
-rw-r--r-- | src/path-search.cpp | 14 | ||||
-rw-r--r-- | src/path-search.hpp | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/path-search.cpp b/src/path-search.cpp index ba8392f6..829c49cd 100644 --- a/src/path-search.cpp +++ b/src/path-search.cpp @@ -30,7 +30,7 @@ void search::ensure_allocated(chunk_coords a, chunk_coords b) x = {}; } -bool search::sample_rtree_1(chunk& c, Vector2 min, Vector2 max, object_id own_id) +bool search::is_passable_1(chunk& c, Vector2 min, Vector2 max, object_id own_id) { auto& rt = *c.rtree(); bool is_passable = true; @@ -47,12 +47,12 @@ 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 min, Vector2 max, object_id own_id) +bool search::is_passable(world& w, chunk_coords_ ch0, Vector2 min, Vector2 max, object_id own_id) { 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 - if (!sample_rtree_1(*c, min, max, own_id)) + if (!is_passable_1(*c, min, max, own_id)) return false; for (auto nb : world::neighbor_offsets) @@ -71,18 +71,18 @@ bool search::sample_rtree(world& w, chunk_coords_ ch0, Vector2 min, Vector2 max, continue; if (auto* c2 = w.at(ch0 + Vector2i(nb))) - if (!sample_rtree_1(*c2, min_, max_, own_id)) + if (!is_passable_1(*c2, min_, max_, own_id)) return false; } return true; } -bool search::sample_rtree(world& w, global_coords coord, Vector2b offset, Vector2ub size_, object_id own_id) +bool search::is_passable(world& w, global_coords coord, Vector2b offset, Vector2ub size_, object_id own_id) { auto center = iTILE_SIZE2 * Vector2i(coord.local()) + Vector2i(offset); auto size = Vector2(size_); auto min = Vector2(center) - size*.5f, max = min + size; - return sample_rtree(w, coord, min, max, own_id); + return is_passable(w, coord, min, max, own_id); } auto search::make_neighbor_tile_bbox(Vector2i coord, Vector2ub own_size, rotation r) -> bbox @@ -181,7 +181,7 @@ Optional<search_result> search::operator()(world& w, object_id own_id, return {}; // check if obj can actually move at all - if (!sample_rtree(w, from, from_offset, size, own_id)) + if (!is_passable(w, from, from_offset, size, own_id)) return {}; ensure_allocated(from.chunk(), to.chunk()); diff --git a/src/path-search.hpp b/src/path-search.hpp index cb58f531..651b719e 100644 --- a/src/path-search.hpp +++ b/src/path-search.hpp @@ -86,9 +86,9 @@ public: Optional<search_result> operator()(world& w, object_id own_id, global_coords from, Vector2b from_offset, Vector2ub size, global_coords to, Vector2b to_offset); Optional<search_result> 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 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 bool is_passable_1(chunk& c, Vector2 min, Vector2 max, object_id own_id); + static bool is_passable(world& w, chunk_coords_ ch0, Vector2 min, Vector2 max, object_id own_id); + static bool is_passable(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); static neighbors get_walkable_neighbor_tiles(world& w, global_coords pos, Vector2 size, object_id own_id); |