diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-03 07:59:48 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-04 09:05:16 +0200 |
commit | 4291d046bfe7eaa2212e2a8c5afc59234ff8c236 (patch) | |
tree | b847504ef9e5ff31c511a94c5a52823ad0de6bea /src/chunk-collision.cpp | |
parent | 2f4d634061fb5a537c1ce0b58a9c985b328a9327 (diff) |
allow placing tile-sized scenery next to one another
Diffstat (limited to 'src/chunk-collision.cpp')
-rw-r--r-- | src/chunk-collision.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp index db7f3ede..003485e5 100644 --- a/src/chunk-collision.cpp +++ b/src/chunk-collision.cpp @@ -130,8 +130,17 @@ bool chunk::can_place_object(const object_proto& proto, local_coords pos) return true; } + if (!proto.bbox_size.x() || proto.bbox_size.y()) + return true; + + auto bbox_size = Vector2i(proto.bbox_size); + if (bbox_size.x() > 1) + bbox_size.x() -= 1; + if (bbox_size.y() > 1) + bbox_size.y() -= 1; + const auto center = Vector2(pos)*TILE_SIZE2 + Vector2(proto.offset) + Vector2(proto.bbox_offset), - min = center - Vector2(proto.bbox_size/2), max = min + Vector2(proto.bbox_size); + min = center - Vector2(bbox_size)*.5f, max = min + Vector2(bbox_size); bool ret = true; _rtree.Search(min.data(), max.data(), [&](uint64_t data, const auto&) { [[maybe_unused]] auto x = std::bit_cast<collision_data>(data); |