Skip to content

Commit

Permalink
Add mesh generation delay
Browse files Browse the repository at this point in the history
  • Loading branch information
numberZero authored and paramat committed Mar 26, 2017
1 parent 22567d1 commit 4d5177f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions builtin/settingtypes.txt
Expand Up @@ -511,6 +511,10 @@ hud_hotbar_max_width (Maximum hotbar width) float 1.0
# Enables caching of facedir rotated meshes.
enable_mesh_cache (Mesh cache) bool false

# Delay between mesh updates on the client in ms. Increasing this will slow
# down the rate of mesh updates, thus reducing jitter on slower clients.
mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50

# Enables minimap.
enable_minimap (Minimap) bool true

Expand Down
5 changes: 5 additions & 0 deletions minetest.conf.example
Expand Up @@ -594,6 +594,11 @@ enable_client_modding (Client modding) bool false
# type: bool
# enable_mesh_cache = false

# Delay between mesh updates on the client in ms. Increasing this will slow
# down the rate of mesh updates, thus reducing jitter on slower clients.
# type: int min: 0 max: 50
# mesh_generation_interval = 0

# Enables minimap.
# type: bool
# enable_minimap = true
Expand Down
9 changes: 8 additions & 1 deletion src/client.cpp
Expand Up @@ -157,6 +157,12 @@ QueuedMeshUpdate *MeshUpdateQueue::pop()
MeshUpdateThread
*/

MeshUpdateThread::MeshUpdateThread() : UpdateThread("Mesh")
{
m_generation_interval = g_settings->getU16("mesh_generation_interval");
m_generation_interval = rangelim(m_generation_interval, 0, 50);
}

void MeshUpdateThread::enqueueUpdate(v3s16 p, MeshMakeData *data,
bool ack_block_to_server, bool urgent)
{
Expand All @@ -168,7 +174,8 @@ void MeshUpdateThread::doUpdate()
{
QueuedMeshUpdate *q;
while ((q = m_queue_in.pop())) {

if (m_generation_interval)
sleep_ms(m_generation_interval);
ScopeProfiler sp(g_profiler, "Client: Mesh making");

MapBlockMesh *mesh_new = new MapBlockMesh(q->data, m_camera_offset);
Expand Down
3 changes: 2 additions & 1 deletion src/client.h
Expand Up @@ -120,13 +120,14 @@ class MeshUpdateThread : public UpdateThread
{
private:
MeshUpdateQueue m_queue_in;
int m_generation_interval;

protected:
virtual void doUpdate();

public:

MeshUpdateThread() : UpdateThread("Mesh") {}
MeshUpdateThread();

void enqueueUpdate(v3s16 p, MeshMakeData *data,
bool ack_block_to_server, bool urgent);
Expand Down
1 change: 1 addition & 0 deletions src/defaultsettings.cpp
Expand Up @@ -38,6 +38,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_sound", "true");
settings->setDefault("sound_volume", "0.8");
settings->setDefault("enable_mesh_cache", "false");
settings->setDefault("mesh_generation_interval", "0");
settings->setDefault("enable_vbo", "true");
settings->setDefault("free_move", "false");
settings->setDefault("fast_move", "false");
Expand Down
2 changes: 2 additions & 0 deletions src/settings_translation_file.cpp
Expand Up @@ -245,6 +245,8 @@ fake_function() {
gettext("Maximum proportion of current window to be used for hotbar.\nUseful if there's something to be displayed right or left of hotbar.");
gettext("Mesh cache");
gettext("Enables caching of facedir rotated meshes.");
gettext("Mapblock mesh generation delay");
gettext("Delay between mesh updates on the client in ms. Increasing this will slow\ndown the rate of mesh updates, thus reducing jitter on slower clients.");
gettext("Minimap");
gettext("Enables minimap.");
gettext("Round minimap");
Expand Down

0 comments on commit 4d5177f

Please sign in to comment.