From 2742fef458c3626476193c9e2d1b9231e042e420 Mon Sep 17 00:00:00 2001 From: paradust7 <102263465+paradust7@users.noreply.github.com> Date: Sat, 21 May 2022 15:11:49 -0700 Subject: Fixes needed to use irrArray backed by std::vector (#12263) --- src/client/mapblock_mesh.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/client/mapblock_mesh.cpp') diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 868573bf0..965dd5e29 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -1162,15 +1162,16 @@ void MapBlockBspTree::traverse(s32 node, v3f viewpoint, std::vector &output void PartialMeshBuffer::beforeDraw() const { // Patch the indexes in the mesh buffer before draw - - m_buffer->Indices.clear(); - if (!m_vertex_indexes.empty()) { - for (auto index : m_vertex_indexes) - m_buffer->Indices.push_back(index); - } + m_buffer->Indices = std::move(m_vertex_indexes); m_buffer->setDirty(scene::EBT_INDEX); } +void PartialMeshBuffer::afterDraw() const +{ + // Take the data back + m_vertex_indexes = std::move(m_buffer->Indices.steal()); +} + /* MapBlockMesh */ @@ -1514,7 +1515,7 @@ void MapBlockMesh::updateTransparentBuffers(v3f camera_pos, v3s16 block_pos) const auto &t = m_transparent_triangles[i]; if (current_buffer != t.buffer) { if (current_buffer) { - m_transparent_buffers.emplace_back(current_buffer, current_strain); + m_transparent_buffers.emplace_back(current_buffer, std::move(current_strain)); current_strain.clear(); } current_buffer = t.buffer; @@ -1525,7 +1526,7 @@ void MapBlockMesh::updateTransparentBuffers(v3f camera_pos, v3s16 block_pos) } if (!current_strain.empty()) - m_transparent_buffers.emplace_back(current_buffer, current_strain); + m_transparent_buffers.emplace_back(current_buffer, std::move(current_strain)); } void MapBlockMesh::consolidateTransparentBuffers() @@ -1539,7 +1540,7 @@ void MapBlockMesh::consolidateTransparentBuffers() for (const auto &t : m_transparent_triangles) { if (current_buffer != t.buffer) { if (current_buffer != nullptr) { - this->m_transparent_buffers.emplace_back(current_buffer, current_strain); + this->m_transparent_buffers.emplace_back(current_buffer, std::move(current_strain)); current_strain.clear(); } current_buffer = t.buffer; @@ -1550,7 +1551,7 @@ void MapBlockMesh::consolidateTransparentBuffers() } if (!current_strain.empty()) { - this->m_transparent_buffers.emplace_back(current_buffer, current_strain); + this->m_transparent_buffers.emplace_back(current_buffer, std::move(current_strain)); } } -- cgit v1.2.3