diff options
-rw-r--r-- | draw/anim.cpp | 23 | ||||
-rw-r--r-- | src/world.cpp | 4 |
2 files changed, 12 insertions, 15 deletions
diff --git a/draw/anim.cpp b/draw/anim.cpp index df67585b..47d84a97 100644 --- a/draw/anim.cpp +++ b/draw/anim.cpp @@ -52,15 +52,12 @@ void anim_mesh::draw(tile_shader& shader, chunk& c) const auto& es = c.entities(); GL::MeshView mesh{mesh_}; [[maybe_unused]] std::size_t draw_count = 0; - anim_atlas* bound = nullptr; const auto size = es.size(); const auto max_index = std::uint32_t(size*quad_index_count - 1); - const auto do_draw = [&](std::size_t from, std::size_t to, anim_atlas* atlas, std::uint32_t max_index) { - if (atlas != bound) - atlas->texture().bind(0); - bound = atlas; + const auto do_draw = [&](std::size_t from, std::size_t to, anim_atlas* atlas) { + atlas->texture().bind(0); mesh.setCount((int)(quad_index_count * (to-from))); mesh.setIndexRange((int)(from*quad_index_count), 0, max_index); shader.draw(mesh); @@ -80,27 +77,25 @@ void anim_mesh::draw(tile_shader& shader, chunk& c) { const auto& e = *es[k]; auto& atlas = *e.atlas; - if (atlas.info().fps > 0) + if (last && &atlas != last.atlas) + { + do_draw(last.run_from, i, last.atlas); + last = nullptr; + } + if (e.is_dynamic()) { - if (last) - do_draw(last.run_from, i, last.atlas, max_index); draw(shader, atlas, e.r, e.frame, e.coord.local(), e.offset, tile_shader::scenery_depth_offset); last = nullptr; } else { - if (last && &atlas != last.atlas) - { - do_draw(last.run_from, i, last.atlas, max_index); - last = nullptr; - } if (!last) last = { &atlas, i }; i++; } } if (last) - do_draw(last.run_from, size, last.atlas, max_index); + do_draw(last.run_from, i, last.atlas); //#define FM_DEBUG_DRAW_COUNT #ifdef FM_DEBUG_DRAW_COUNT diff --git a/src/world.cpp b/src/world.cpp index 71f6c7a9..a4035e14 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -130,7 +130,9 @@ void world::do_kill_entity(std::uint64_t id) std::shared_ptr<entity> world::find_entity_(std::uint64_t id) { auto it = _entities.find(id); - return it == _entities.end() ? nullptr : it->second.lock(); + auto ret = it == _entities.end() ? nullptr : it->second.lock(); + fm_debug_assert(&ret->c.world() == this); + return ret; } } // namespace floormat |