diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-06 15:29:33 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-06 15:29:33 +0200 |
commit | 82ec1a07c79b1c96688464609d043d6ce23685b1 (patch) | |
tree | 90473a42d3799bafb4fd9fd2a23f779bf36770db /main | |
parent | 9703532543d528757e4635f0eb5c91ccb4c2e300 (diff) |
a
Diffstat (limited to 'main')
-rw-r--r-- | main/draw.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index 37b88e7c..f87f2e9c 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -97,11 +97,12 @@ void main_impl::draw_world() noexcept for (int16_t x = minx; x <= maxx; x++) { const chunk_coords pos{x, y}; - if (!_world.contains(pos)) + if (pos == chunk_coords_{} && !_world.contains(pos)) app.maybe_initialize_chunk(pos, _world[pos]); - auto& c = _world[pos]; - if (c.empty()) + auto* c_ = _world.at(pos); + if (!c_) continue; + auto& c = *c_; const with_shifted_camera_offset o{_shader, pos, {minx, miny}, {maxx, maxy}}; if (check_chunk_visible(_shader.camera_offset(), sz)) _floor_mesh.draw(_shader, c); @@ -113,9 +114,10 @@ void main_impl::draw_world() noexcept for (int16_t x = minx; x <= maxx; x++) { const chunk_coords pos{x, y}; - auto& c = _world[pos]; - if (c.empty()) + auto* c_ = _world.at(pos); + if (!c_) continue; + auto& c = *c_; const with_shifted_camera_offset o{_shader, pos, {minx, miny}, {maxx, maxy}}; if (check_chunk_visible(_shader.camera_offset(), sz)) _wall_mesh.draw(_shader, c); @@ -129,9 +131,10 @@ void main_impl::draw_world() noexcept for (int16_t x = minx; x <= maxx; x++) { const chunk_coords pos{x, y}; - auto& c = _world[pos]; - if (c.empty()) + auto* c_ = _world.at(pos); + if (!c_) continue; + auto& c = *c_; const with_shifted_camera_offset o{_shader, pos, {minx, miny}, {maxx, maxy}}; if (check_chunk_visible(_shader.camera_offset(), sz)) _anim_mesh.draw(_shader, sz, c, _clickable_scenery); |