diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chunk-collision.cpp | 4 | ||||
-rw-r--r-- | src/tile-bbox.hpp | 16 |
2 files changed, 8 insertions, 12 deletions
diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp index d95a6a9b..4f94df6b 100644 --- a/src/chunk-collision.cpp +++ b/src/chunk-collision.cpp @@ -53,13 +53,13 @@ void chunk::ensure_passability() noexcept auto tile = operator[](i); if (const auto* atlas = tile.wall_north_atlas().get()) { - auto [min, max] = wall_north(i); + auto [min, max] = wall_north(i, atlas->info().depth); auto id = make_id(collision_type::geometry, atlas->info().passability, TILE_COUNT+i+1); _rtree.Insert(min.data(), max.data(), id); } if (const auto* atlas = tile.wall_west_atlas().get()) { - auto [min, max] = wall_west(i); + auto [min, max] = wall_west(i, atlas->info().depth); auto id = make_id(collision_type::geometry, atlas->info().passability, TILE_COUNT*2+i+1); _rtree.Insert(min.data(), max.data(), id); } diff --git a/src/tile-bbox.hpp b/src/tile-bbox.hpp index ba61f0bf..7f8a05b8 100644 --- a/src/tile-bbox.hpp +++ b/src/tile-bbox.hpp @@ -7,10 +7,6 @@ namespace floormat { -namespace { -constexpr float wall_depth = 8, wall_depth_2 = wall_depth*.5f; -} // namespace - constexpr Vector2 tile_start(size_t k) { constexpr auto half_tile = Vector2(TILE_SIZE2)/2; @@ -32,16 +28,16 @@ constexpr Pair<Vector2, Vector2> whole_tile(size_t k) return { min, min + TILE_SIZE2, }; } -constexpr Pair<Vector2, Vector2> wall_north(size_t k) +constexpr Pair<Vector2, Vector2> wall_north(size_t k, float wall_depth) { - auto min = tile_start(k) - Vector2(0, wall_depth_2); - return { min, min + Vector2(TILE_SIZE2[0], wall_depth), }; + auto min = tile_start(k) - Vector2{0, wall_depth}; + return { min, min + Vector2{TILE_SIZE2.x(), wall_depth}, }; } -constexpr Pair<Vector2, Vector2> wall_west(size_t k) +constexpr Pair<Vector2, Vector2> wall_west(size_t k, float wall_depth) { - auto min = tile_start(k) - Vector2(wall_depth_2, 0); - return { min, min + Vector2(wall_depth, TILE_SIZE2[1]), }; + auto min = tile_start(k) - Vector2{wall_depth, 0}; + return { min, min + Vector2{wall_depth, TILE_SIZE2.y()}, }; } } // namespace floormat |