summaryrefslogtreecommitdiffhomepage
path: root/editor/update.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-08 11:12:50 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-08 11:12:50 +0200
commitd1984938e4f0cbc24b7b8cc6e219fa873d39418a (patch)
treed00c6cf0ba66c3285d145527360a0e3aeaef6671 /editor/update.cpp
parentd17ed6b4ba01a73d33e3ff3ca8f0f6fb25259223 (diff)
a
Diffstat (limited to 'editor/update.cpp')
-rw-r--r--editor/update.cpp48
1 files changed, 29 insertions, 19 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
index 6bb1ff66..f36b2905 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -185,33 +185,35 @@ void app::update_world(float dt)
{
auto& world = M->world();
const auto curframe = world.increment_frame_no();
+ auto [z_min, z_max] = get_z_bounds();
auto [minx, maxx, miny, maxy] = M->get_draw_bounds();
minx--; miny--; maxx++; maxy++;
- for (int16_t y = miny; y <= maxy; y++)
- for (int16_t x = minx; x <= maxx; x++)
- {
- auto* c_ = world.at(chunk_coords{x, y});
- if (!c_)
- continue;
- auto& c = *c_;
- const auto& es = c.entities();
-start: const auto size = es.size();
- for (auto i = size-1; i != (size_t)-1; i--)
+ for (int8_t z = z_min; z <= z_max; z++)
+ for (int16_t y = miny; y <= maxy; y++)
+ for (int16_t x = minx; x <= maxx; x++)
{
- auto& e = *es[i];
- fm_debug_assert(!(e.last_update > curframe));
- if (curframe > e.last_update) [[likely]]
+ auto* c_ = world.at({x, y, z});
+ if (!c_)
+ continue;
+ auto& c = *c_;
+ const auto& es = c.entities();
+start: const auto size = es.size();
+ for (auto i = size-1; i != (size_t)-1; i--)
{
- e.last_update = curframe;
- auto status = e.update(i, dt);
- if (status)
+ auto& e = *es[i];
+ fm_debug_assert(!(e.last_update > curframe));
+ if (curframe > e.last_update) [[likely]]
{
- //Debug{} << "goto start";
- goto start;
+ e.last_update = curframe;
+ auto status = e.update(i, dt);
+ if (status)
+ {
+ //Debug{} << "goto start";
+ goto start;
+ }
}
}
}
- }
}
void app::update_character([[maybe_unused]] float dt)
@@ -238,6 +240,14 @@ void app::set_cursor()
set_cursor_from_imgui();
}
+auto app::get_z_bounds() -> z_bounds
+{
+ if (_render_all_z_levels)
+ return { chunk_min_z, chunk_max_z };
+ else
+ return { _z_level, _z_level };
+}
+
void app::update(float dt)
{
apply_commands(keys);