aboutsummaryrefslogtreecommitdiff
path: root/src/client/client.cpp
diff options
context:
space:
mode:
authorlhofhansl <larsh@apache.org>2023-02-08 13:42:12 -0800
committerGitHub <noreply@github.com>2023-02-08 13:42:12 -0800
commitd3a6ee00e63cc0a4adcaa7598ad5614f1e419515 (patch)
treeab82ef6f25fe7f314c0065334f7c9c4d56f65426 /src/client/client.cpp
parent56d2567b5dcf9556cef8352032cede48a5610801 (diff)
downloadminetest-d3a6ee00e63cc0a4adcaa7598ad5614f1e419515.tar.xz
Generalize mesh chunking, and make it configurable. (#13179)
* Generalize mesh chunking. Set 3x3x3 chunks. * Make mesh chunk size configurable... Default to 1 (off). * Extract all mesh grid maths into a dedicated class --------- Co-authored-by: x2048 <codeforsmile@gmail.com>
Diffstat (limited to 'src/client/client.cpp')
-rw-r--r--src/client/client.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 66dee613f..8fbd56ac8 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -143,6 +143,7 @@ Client::Client(
}
m_cache_save_interval = g_settings->getU16("server_map_save_interval");
+ m_mesh_grid = { g_settings->getU16("client_mesh_chunk") };
}
void Client::migrateModStorage()
@@ -564,7 +565,7 @@ void Client::step(float dtime)
MapBlock *block = sector->getBlockNoCreateNoEx(r.p.Y);
// The block in question is not visible (perhaps it is culled at the server),
- // create a blank block just to hold the 2x2x2 mesh.
+ // create a blank block just to hold the chunk's mesh.
// If the block becomes visible later it will replace the blank block.
if (!block && r.mesh)
block = sector->createBlankBlock(r.p.Y);
@@ -607,10 +608,10 @@ void Client::step(float dtime)
v3s16 ofs;
// See also mapblock_mesh.cpp for the code that creates the array of minimap blocks.
- for (ofs.Z = 0; ofs.Z <= 1; ofs.Z++)
- for (ofs.Y = 0; ofs.Y <= 1; ofs.Y++)
- for (ofs.X = 0; ofs.X <= 1; ofs.X++) {
- size_t i = ofs.Z * 4 + ofs.Y * 2 + ofs.X;
+ for (ofs.Z = 0; ofs.Z < m_mesh_grid.cell_size; ofs.Z++)
+ for (ofs.Y = 0; ofs.Y < m_mesh_grid.cell_size; ofs.Y++)
+ for (ofs.X = 0; ofs.X < m_mesh_grid.cell_size; ofs.X++) {
+ size_t i = m_mesh_grid.getOffsetIndex(ofs);
if (i < minimap_mapblocks.size() && minimap_mapblocks[i])
m_minimap->addBlock(r.p + ofs, minimap_mapblocks[i]);
}