Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wip5.8.0' into wip5.8.0webport
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 15, 2024
2 parents e129062 + c32dae8 commit 24a8007
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,34 +773,34 @@ const MapBlock::mesh_type empty_mesh;
#if BUILD_CLIENT
const MapBlock::mesh_type MapBlock::getLodMesh(block_step_t step, bool allow_other)
{
if (m_lod_mesh[step].load(std::memory_order::relaxed) || !allow_other)
return m_lod_mesh[step].load(std::memory_order::relaxed);
if (m_lod_mesh[step] || !allow_other)
return m_lod_mesh[step];

for (int inc = 1; inc < 4; ++inc) {
if (step + inc < m_lod_mesh.size() && m_lod_mesh[step + inc].load(std::memory_order::relaxed))
return m_lod_mesh[step + inc].load(std::memory_order::relaxed);
if (step - inc >= 0 && m_lod_mesh[step - inc].load(std::memory_order::relaxed))
return m_lod_mesh[step - inc].load(std::memory_order::relaxed);
if (step + inc < m_lod_mesh.size() && m_lod_mesh[step + inc])
return m_lod_mesh[step + inc];
if (step - inc >= 0 && m_lod_mesh[step - inc])
return m_lod_mesh[step - inc];
}
return empty_mesh;
}

const MapBlock::mesh_type MapBlock::getFarMesh(block_step_t step)
{
return m_far_mesh[step].load(std::memory_order::relaxed);
return m_far_mesh[step];
}

void MapBlock::setLodMesh(const MapBlock::mesh_type &rmesh)
{
const auto ms = rmesh->lod_step;
if (auto mesh = std::move(m_lod_mesh[ms].load(std::memory_order::relaxed)))
if (auto mesh = std::move(m_lod_mesh[ms]))
delete_mesh = std::move(mesh);
m_lod_mesh[ms] = rmesh;
}

void MapBlock::setFarMesh(const MapBlock::mesh_type &rmesh, block_step_t step)
{
if (auto mesh = std::move(m_far_mesh[step].load(std::memory_order::relaxed))) {
if (auto mesh = std::move(m_far_mesh[step])) {
delete_mesh = std::move(mesh);
}
m_far_mesh[step] = rmesh;
Expand Down
4 changes: 2 additions & 2 deletions src/mapblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ class MapBlock
uint8_t mesh_requested_step {};

private:
std::array<std::atomic<MapBlock::mesh_type>, LODMESH_STEP_MAX + 1> m_lod_mesh;
std::array<std::atomic<MapBlock::mesh_type>, FARMESH_STEP_MAX + 1> m_far_mesh;
std::array<MapBlock::mesh_type, LODMESH_STEP_MAX + 1> m_lod_mesh;
std::array<MapBlock::mesh_type, FARMESH_STEP_MAX + 1> m_far_mesh;
MapBlock::mesh_type delete_mesh;

public:
Expand Down

0 comments on commit 24a8007

Please sign in to comment.