Consolidate transparent buffers lazily

This commit is contained in:
sfan5 2024-08-27 10:03:13 +02:00
parent c00fed20b7
commit 39970fed38
2 changed files with 7 additions and 0 deletions

@ -906,6 +906,7 @@ void MapBlockMesh::updateTransparentBuffers(v3f camera_pos, v3s16 block_pos)
m_bsp_tree.traverse(rel_camera_pos, triangle_refs);
// arrange index sequences into partial buffers
m_transparent_buffers_consolidated = false;
m_transparent_buffers.clear();
scene::SMeshBuffer *current_buffer = nullptr;
@ -930,6 +931,8 @@ void MapBlockMesh::updateTransparentBuffers(v3f camera_pos, v3s16 block_pos)
void MapBlockMesh::consolidateTransparentBuffers()
{
if (m_transparent_buffers_consolidated)
return;
m_transparent_buffers.clear();
scene::SMeshBuffer *current_buffer = nullptr;
@ -952,6 +955,8 @@ void MapBlockMesh::consolidateTransparentBuffers()
if (!current_strain.empty()) {
this->m_transparent_buffers.emplace_back(current_buffer, std::move(current_strain));
}
m_transparent_buffers_consolidated = true;
}
video::SColor encode_light(u16 light, u8 emissive_light)

@ -282,6 +282,8 @@ private:
MapBlockBspTree m_bsp_tree;
// Ordered list of references to parts of transparent buffers to draw
std::vector<PartialMeshBuffer> m_transparent_buffers;
// Is m_transparent_buffers currently in consolidated form?
bool m_transparent_buffers_consolidated = false;
};
/*!