diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/chunk-render.cpp | 6 | ||||
| -rw-r--r-- | src/chunk-scenery.cpp | 19 | ||||
| -rw-r--r-- | src/chunk-walls.cpp | 3 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp index 0cc88af2..0c5d5bc6 100644 --- a/src/chunk-render.cpp +++ b/src/chunk-render.cpp @@ -52,6 +52,12 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple if (_ground->atlases[i]) _ground->indexes[count++] = uint8_t(i); + if (count == 0) + { + ground_mesh = GL::Mesh{NoCreate}; + return { ground_mesh, {}, 0 }; + } + std::sort(_ground->indexes.begin(), _ground->indexes.begin() + count, [this](uint8_t a, uint8_t b) { return _ground->atlases[a].get() < _ground->atlases[b].get(); diff --git a/src/chunk-scenery.cpp b/src/chunk-scenery.cpp index 2e491d4d..4bf55312 100644 --- a/src/chunk-scenery.cpp +++ b/src/chunk-scenery.cpp @@ -177,13 +177,18 @@ auto chunk::ensure_scenery_mesh(scenery_scratch_buffers buffers) noexcept -> sce i++; } - GL::Mesh mesh{GL::MeshPrimitive::Triangles}; - auto vert_view = ArrayView<const std::array<vertex, 4>>{scenery_vertexes, count}; - auto index_view = ArrayView<const std::array<UnsignedShort, 6>>{scenery_indexes, count}; - mesh.addVertexBuffer(GL::Buffer{vert_view}, 0, tile_shader::Position{}, tile_shader::TextureCoordinates{}, tile_shader::Depth{}) - .setIndexBuffer(GL::Buffer{index_view}, 0, GL::MeshIndexType::UnsignedShort) - .setCount(int32_t(6 * count)); - scenery_mesh = move(mesh); + if (count == 0) + scenery_mesh = GL::Mesh{NoCreate}; + else + { + GL::Mesh mesh{GL::MeshPrimitive::Triangles}; + auto vert_view = ArrayView<const std::array<vertex, 4>>{scenery_vertexes, count}; + auto index_view = ArrayView<const std::array<UnsignedShort, 6>>{scenery_indexes, count}; + mesh.addVertexBuffer(GL::Buffer{vert_view}, 0, tile_shader::Position{}, tile_shader::TextureCoordinates{}, tile_shader::Depth{}) + .setIndexBuffer(GL::Buffer{index_view}, 0, GL::MeshIndexType::UnsignedShort) + .setCount(int32_t(6 * count)); + scenery_mesh = move(mesh); + } } const auto size = _objects.size(); diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp index 9971bcde..efff51b8 100644 --- a/src/chunk-walls.cpp +++ b/src/chunk-walls.cpp @@ -323,6 +323,9 @@ GL::Mesh chunk::make_wall_mesh() } } + if (N == 0) + return GL::Mesh{NoCreate}; + ranges::sort(ranges::zip_view(vertexes.prefix(N), ArrayView{_walls->mesh_indexes.data(), N}), [&A = _walls->atlases](const auto& a, const auto& b) { |
