summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-25 21:23:01 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-25 21:23:01 +0100
commit6a4ac0dc015106801d79cc258b06f896ea0e2716 (patch)
tree6b43962db0ae82a26b38785e14ac3de0a1ceb441
parent0b694f21edc97bd95faa65197bdda6b440479df3 (diff)
a
-rw-r--r--editor/update.cpp8
-rw-r--r--src/chunk-collision.cpp10
2 files changed, 10 insertions, 8 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
index 2b693526..7423ef76 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -152,10 +152,12 @@ void app::update_world(float dt)
if (auto [atlas, scenery] = x.scenery(); atlas != nullptr)
{
auto pass0 = scenery.passability;
- auto offset0 = scenery.bbox_offset;
- auto size0 = scenery.bbox_size;
+ auto offset0 = scenery.offset;
+ auto bb_offset0 = scenery.bbox_offset;
+ auto bb_size0 = scenery.bbox_size;
scenery.update(dt, *atlas);
- if (pass0 != scenery.passability || offset0 != scenery.offset || size0 != scenery.bbox_size)
+ if (pass0 != scenery.passability || offset0 != scenery.offset ||
+ bb_offset0 != scenery.bbox_offset || bb_size0 != scenery.bbox_size)
c.mark_scenery_modified();
}
}
diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp
index 80436ad2..de4f484e 100644
--- a/src/chunk-collision.cpp
+++ b/src/chunk-collision.cpp
@@ -13,15 +13,15 @@ namespace {
constexpr Vector2 tile_start(std::size_t k)
{
- const auto i = std::uint8_t(k);
- const local_coords coord{i};
- return TILE_SIZE2 * Vector2(coord.x, coord.y) - TILE_SIZE2*.5f;
+ constexpr auto half_tile = Vector2(TILE_SIZE2)/2;
+ const local_coords coord{k};
+ return TILE_SIZE2 * Vector2(coord.x, coord.y) - half_tile;
}
constexpr Pair<Vector2, Vector2> scenery_tile(std::size_t k, const scenery& sc)
{
- constexpr auto half = Vector2(TILE_SIZE2)/2;
- auto center = tile_start(k) + Vector2(sc.bbox_offset) + half;
+ const local_coords coord{k};
+ auto center = TILE_SIZE2 * Vector2(coord.x, coord.y) + Vector2(sc.offset) + Vector2(sc.bbox_offset);
auto start = center - Vector2(sc.bbox_size);
auto size = Vector2(sc.bbox_size)*2;
return { start, start + size, };