summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-03 01:22:51 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-03 01:22:51 +0200
commit19efa645ab26175056440c7dda267893b8dd3372 (patch)
tree984d4c2a49b7ec3c957e6ef127337938148bc28c /src
parentc9d56d6fb1c8eca558db937b99b89535893950a0 (diff)
src: "fix" msvc miscompiling chunk::ensure_wall_mesh()
Diffstat (limited to 'src')
-rw-r--r--src/chunk-render.cpp41
-rw-r--r--src/chunk.hpp1
2 files changed, 23 insertions, 19 deletions
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp
index 9eba6446..9e216e8d 100644
--- a/src/chunk-render.cpp
+++ b/src/chunk-render.cpp
@@ -58,23 +58,11 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple
return { ground_mesh, ground_indexes, count };
}
-auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
+fm_noinline
+GL::Mesh chunk::make_wall_mesh(size_t count)
{
- if (!_walls_modified)
- return { wall_mesh, wall_indexes, size_t(wall_mesh.count()/6) };
- _walls_modified = false;
-
- size_t count = 0;
- for (auto i = 0uz; i < TILE_COUNT*2; i++)
- if (_wall_atlases[i])
- wall_indexes[count++] = uint16_t(i);
-
- std::sort(wall_indexes.data(), wall_indexes.data() + (ptrdiff_t)count,
- [this](uint16_t a, uint16_t b) {
- return _wall_atlases[a] < _wall_atlases[b];
- });
-
- std::array<std::array<vertex, 4>, TILE_COUNT*2> vertexes;
+ //std::array<std::array<vertex, 4>, TILE_COUNT*2> vertexes;
+ vertex vertexes[TILE_COUNT*2][4];
for (auto k = 0uz; k < count; k++)
{
const uint16_t i = wall_indexes[k];
@@ -91,19 +79,34 @@ auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
}
auto indexes = make_index_array<2>(count);
- const auto vertex_view = ArrayView{vertexes.data(), count};
+ const auto vertex_view = ArrayView{&vertexes[0], count};
const auto vert_index_view = ArrayView{indexes.data(), count};
GL::Mesh mesh{GL::MeshPrimitive::Triangles};
mesh.addVertexBuffer(GL::Buffer{vertex_view}, 0, tile_shader::Position{}, tile_shader::TextureCoordinates{}, tile_shader::Depth{})
.setIndexBuffer(GL::Buffer{vert_index_view}, 0, GL::MeshIndexType::UnsignedShort)
.setCount(int32_t(6 * count));
- wall_mesh = Utility::move(mesh);
- return { wall_mesh, wall_indexes, count };
+ return mesh;
}
+auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
+{
+ if (!_walls_modified)
+ return { wall_mesh, wall_indexes, size_t(wall_mesh.count()/6) };
+ _walls_modified = false;
+ size_t count = 0;
+ for (auto i = 0uz; i < TILE_COUNT*2; i++)
+ if (_wall_atlases[i])
+ wall_indexes[count++] = uint16_t(i);
+ std::sort(wall_indexes.data(), wall_indexes.data() + (ptrdiff_t)count,
+ [this](uint16_t a, uint16_t b) {
+ return _wall_atlases[a] < _wall_atlases[b];
+ });
+ wall_mesh = make_wall_mesh(count);
+ return { wall_mesh, wall_indexes, count };
+}
} // namespace floormat
diff --git a/src/chunk.hpp b/src/chunk.hpp
index 385ba72e..be90c89a 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -152,6 +152,7 @@ private:
void _remove_bbox(const bbox& x);
void _add_bbox(const bbox& x);
void _replace_bbox(const bbox& x0, const bbox& x, bool b0, bool b);
+ GL::Mesh make_wall_mesh(size_t count);
};
} // namespace floormat