summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-24 23:24:04 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-24 23:24:04 +0100
commitaba8a1a31d912d1a77b827fbd1c55dc3134f6327 (patch)
tree4148b714307376ebfa7d2fff4f2b53606986949d /src
parent004ba665948a7c41c15e2353bd82e20447646aca (diff)
wip broken
Diffstat (limited to 'src')
-rw-r--r--src/chunk-bbox.cpp14
-rw-r--r--src/scenery.hpp3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/chunk-bbox.cpp b/src/chunk-bbox.cpp
index 291056a8..382e4abb 100644
--- a/src/chunk-bbox.cpp
+++ b/src/chunk-bbox.cpp
@@ -50,6 +50,14 @@ void chunk::ensure_passability() noexcept
_bboxes.clear();
bboxes.reserve(TILE_COUNT*4);
+ constexpr auto scenery_tile = [](std::size_t k, pass_mode p, const scenery& sc) constexpr -> collision_bbox {
+ constexpr auto half = sTILE_SIZE2/2;
+ auto center = tile_start(k) + Vector2s(sc.bbox_offset) + half;
+ auto size = Vector2us(sc.bbox_size)*2;
+ auto start = center - Vector2s(sc.bbox_size);
+ return { start[0], start[1], size[0], size[1], p };
+ };
+
constexpr auto whole_tile = [](std::size_t k, pass_mode p) constexpr -> collision_bbox {
auto start = tile_start(k);
return { start[0], start[1], usTILE_SIZE2[0], usTILE_SIZE2[1], p };
@@ -68,9 +76,9 @@ void chunk::ensure_passability() noexcept
for (std::size_t i = 0; i < TILE_COUNT; i++)
{
const auto tile = const_cast<chunk&>(*this)[i];
- if (auto s = tile.scenery())
- if (auto p = s.frame.passability; p != pass_mode::pass)
- bboxes.push_back(whole_tile(i, p));
+ if (auto s = tile.scenery(); s && s.frame.passability != pass_mode::pass)
+ if (auto bb = scenery_tile(i, s.frame.passability, s.frame); bb.width && bb.height)
+ bboxes.push_back(bb);
if (auto atlas = tile.ground_atlas())
if (auto p = atlas->pass_mode(pass_mode::pass); p != pass_mode::pass)
bboxes.push_back(whole_tile(i, p));
diff --git a/src/scenery.hpp b/src/scenery.hpp
index 9186f9cf..ea662d92 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -37,7 +37,8 @@ struct scenery final
std::uint16_t delta = 0;
frame_t frame = 0;
- Vector2b offset, bbox_size{iTILE_SIZE2/2}, bbox_offset;
+ Vector2b offset, bbox_offset;
+ Vector2ub bbox_size{usTILE_SIZE2/2};
rotation r : 3 = rotation::N;
scenery_type type : 3 = scenery_type::none;
pass_mode passability : 2 = pass_mode::shoot_through;