summaryrefslogtreecommitdiffhomepage
path: root/src/chunk-scenery.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-09 21:54:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-09 21:55:29 +0200
commit3c6e95bd369270e90472bc25f91dff76d0811b71 (patch)
tree62e1ee33f244252ba854d5494fd2ce8c8de83fe0 /src/chunk-scenery.cpp
parent3694207151dbee36ea89681fc0fd163bdac5695c (diff)
draw: do batching in an easier way for now
Diffstat (limited to 'src/chunk-scenery.cpp')
-rw-r--r--src/chunk-scenery.cpp50
1 files changed, 1 insertions, 49 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)