diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-09 21:54:56 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-09 21:55:29 +0200 |
commit | 3c6e95bd369270e90472bc25f91dff76d0811b71 (patch) | |
tree | 62e1ee33f244252ba854d5494fd2ce8c8de83fe0 /src | |
parent | 3694207151dbee36ea89681fc0fd163bdac5695c (diff) |
draw: do batching in an easier way for now
Diffstat (limited to 'src')
-rw-r--r-- | src/chunk-scenery.cpp | 50 | ||||
-rw-r--r-- | src/chunk-scenery.hpp | 2 | ||||
-rw-r--r-- | src/chunk.hpp | 2 |
3 files changed, 2 insertions, 52 deletions
diff --git a/src/chunk-scenery.cpp b/src/chunk-scenery.cpp index 66f6a733..40a99487 100644 --- a/src/chunk-scenery.cpp +++ b/src/chunk-scenery.cpp @@ -132,55 +132,7 @@ auto chunk::ensure_scenery_mesh(Array<entity_draw_order>& array) noexcept -> sce std::sort(array.begin(), array.begin() + size, [](const auto& a, const auto& b) { return a.ord < b.ord; }); topological_sort(array, size); - const auto es = ArrayView<entity_draw_order>{array, size}; - - if (_scenery_modified) - { - _scenery_modified = false; - - const auto count = fm_begin( - size_t ret = 0; - for (const auto& [e, ord, _data] : es) - ret += !e->is_dynamic(); - return ret; - ); - - scenery_indexes.clear(); - scenery_indexes.reserve(count); - scenery_vertexes.clear(); - scenery_vertexes.reserve(count); - - for (const auto& [e, ord, _data] : es) - { - if (e->is_dynamic()) - continue; - - const auto i = scenery_indexes.size(); - scenery_indexes.emplace_back(tile_atlas::indices(i)); - const auto& atlas = e->atlas; - const auto& fr = *e; - const auto pos = e->coord.local(); - const auto coord = Vector3(pos) * TILE_SIZE + Vector3(Vector2(fr.offset), 0); - const auto quad = atlas->frame_quad(coord, fr.r, fr.frame); - const auto& group = atlas->group(fr.r); - const auto texcoords = atlas->texcoords_for_frame(fr.r, fr.frame, !group.mirror_from.isEmpty()); - const float depth = tile_shader::depth_value(pos, tile_shader::scenery_depth_offset); - scenery_vertexes.emplace_back(); - auto& v = scenery_vertexes.back(); - for (auto j = 0uz; j < 4; j++) - v[j] = { quad[j], texcoords[j], depth }; - } - - GL::Mesh mesh{GL::MeshPrimitive::Triangles}; - mesh.addVertexBuffer(GL::Buffer{scenery_vertexes}, 0, tile_shader::Position{}, tile_shader::TextureCoordinates{}, tile_shader::Depth{}) - .setIndexBuffer(GL::Buffer{scenery_indexes}, 0, GL::MeshIndexType::UnsignedShort) - .setCount(int32_t(6 * count)); - scenery_mesh = Utility::move(mesh); - } - - fm_assert(!size || es); - - return { scenery_mesh, es, size }; + return { ArrayView<entity_draw_order>{array, size} }; } void chunk::ensure_scenery_draw_array(Array<entity_draw_order>& array) diff --git a/src/chunk-scenery.hpp b/src/chunk-scenery.hpp index cbe2ea83..067f176a 100644 --- a/src/chunk-scenery.hpp +++ b/src/chunk-scenery.hpp @@ -25,9 +25,7 @@ struct chunk::entity_draw_order topo_sort_data data; }; struct chunk::scenery_mesh_tuple { - GL::Mesh& mesh; ArrayView<entity_draw_order> array; - size_t size; }; } // namespace floormat diff --git a/src/chunk.hpp b/src/chunk.hpp index be90c89a..db6f96f7 100644 --- a/src/chunk.hpp +++ b/src/chunk.hpp @@ -125,7 +125,7 @@ private: std::vector<std::array<vertex, 4>> scenery_vertexes; struct world* _world; - GL::Mesh ground_mesh{NoCreate}, wall_mesh{NoCreate}, scenery_mesh{NoCreate}; + GL::Mesh ground_mesh{NoCreate}, wall_mesh{NoCreate}; RTree _rtree; |