diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-12 17:58:17 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-12-12 17:58:17 +0100 |
commit | afc63fbba0e6009ec4132922545335594a20493e (patch) | |
tree | 86dabe87bfdc536e7ffe9fb22c1125dea4e73b1c /src | |
parent | 6944f24118eee8135f2465bed4f728fe1445f723 (diff) |
w
Diffstat (limited to 'src')
-rw-r--r-- | src/chunk-walls.cpp | 25 | ||||
-rw-r--r-- | src/global-coords.hpp | 4 |
2 files changed, 6 insertions, 23 deletions
diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp index 24049094..6021aa3a 100644 --- a/src/chunk-walls.cpp +++ b/src/chunk-walls.cpp @@ -185,6 +185,7 @@ GL::Mesh chunk::make_wall_mesh() const auto pos = local_coords{k / 2u}; const auto center = Vector3(pos) * TILE_SIZE; const auto& dir = atlas->calc_direction(D); + const auto vpos = (uint8_t)Vector2ui(global_coords{_coord, pos}.raw()).sum(); for (auto [_, member, G] : Wall::Direction::groups) { @@ -216,7 +217,7 @@ GL::Mesh chunk::make_wall_mesh() fm_debug_assert(i < max_wall_quad_count); _walls->mesh_indexes[i] = (uint16_t)k; const auto frames = atlas->frames(group); - const auto variant = variant_ % frames.size(); + const auto variant = (variant_ != (uint8_t)-1 ? variant_ : vpos) % frames.size(); const auto& frame = frames[variant]; const auto texcoords = Quads::texcoords_at(frame.offset, frame.size, atlas->image_size()); const auto depth = tile_shader::depth_value(pos, depth_offset); @@ -226,11 +227,8 @@ GL::Mesh chunk::make_wall_mesh() } } - const auto comp = [&A = _walls->atlases](const auto& a, const auto& b) { - return A[a.second] < A[b.second]; - }; - - ranges::sort(ranges::zip_view(vertexes, _walls->mesh_indexes), comp); + ranges::sort(ranges::zip_view(vertexes, _walls->mesh_indexes), + [&A = _walls->atlases](const auto& a, const auto& b) { return A[a.second] < A[b.second]; }); auto vertex_view = std::as_const(vertexes).prefix(N); auto index_view = make_indexes(N); @@ -253,21 +251,6 @@ auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple return { wall_mesh, _walls->mesh_indexes, size_t(wall_mesh.count()/6) }; _walls_modified = false; -#if 0 - size_t count = 0; - for (auto i = 0uz; i < TILE_COUNT*2; i++) - if (_walls->atlases[i]) - _walls->mesh_indexes[count++] = uint16_t(i); - - if (count == 0) - return {wall_mesh, {}, 0}; - - std::sort(_walls->mesh_indexes.data(), _walls->mesh_indexes.data() + (ptrdiff_t)count, - [this](uint16_t a, uint16_t b) { - return _walls->atlases[a] < _walls->atlases[b]; - }); -#endif - wall_mesh = make_wall_mesh(); return { wall_mesh, _walls->mesh_indexes, (size_t)wall_mesh.count()/6u }; } diff --git a/src/global-coords.hpp b/src/global-coords.hpp index 8e0cf5a8..1f6c2def 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -80,8 +80,8 @@ constexpr inline int8_t chunk_z_min = -1, chunk_z_max = 14; struct global_coords final { - struct raw_coords final { uint32_t &x, &y; }; // NOLINT - struct raw_coords_ final { uint32_t x, y; }; + struct raw_coords { uint32_t &x, &y; operator Vector2ui() const { return {x, y}; } }; // NOLINT + struct raw_coords_ { uint32_t x, y; operator Vector2ui() const { return {x, y}; } }; private: using u0 = std::integral_constant<uint32_t, (1<<15)>; |