summaryrefslogtreecommitdiff
path: root/src/client.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2017-04-15 10:55:52 +0300
committerceleron55 <celeron55@gmail.com>2017-04-17 14:58:29 +0300
commit04cc9de8f2fbcb11f133c88f02fc11504b3ea6f3 (patch)
treeed13d87b714cb58e1e318458bdfcb5ed9e827819 /src/client.h
parent4323ad163f8d8217cbfc926cf212d02386ae0646 (diff)
downloadminetest-04cc9de8f2fbcb11f133c88f02fc11504b3ea6f3.tar.gz
minetest-04cc9de8f2fbcb11f133c88f02fc11504b3ea6f3.tar.bz2
minetest-04cc9de8f2fbcb11f133c88f02fc11504b3ea6f3.zip
MeshUpdateQueue: Add a MapBlock cache that minimizes the amount of MapBlock copying done in the main thread
Cache size is configurable by the meshgen_block_cache_size (default 20 MB). New profiler stats: - MeshUpdateQueue MapBlock cache hit % - MeshUpdateQueue MapBlock cache size kB Removes one type of stutter that was seen on the client when received MapBlocks were being handled. (the "MeshMakeData::fill" stutter) Kind of related to at least #5239 Originally preceded by these commits, now includes them: - Move the mesh generator thread into src/mesh_generator_thread.{cpp,h} - mesh_generator_thread.cpp: Update code style - MeshUpdateThread: Modify interface to house a different implementation: Actual functionality will be changed by next commits. - MeshMakeData: Add fillBlockData() interface (so that caller can fill in stuff from eg. a MapBlock cache)
Diffstat (limited to 'src/client.h')
-rw-r--r--src/client.h83
1 files changed, 2 insertions, 81 deletions
diff --git a/src/client.h b/src/client.h
index e565acd93..e7fcb597d 100644
--- a/src/client.h
+++ b/src/client.h
@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "particles.h"
#include "mapnode.h"
#include "tileanimation.h"
+#include "mesh_generator_thread.h"
struct MeshMakeData;
class MapBlockMesh;
@@ -54,88 +55,12 @@ struct MinimapMapblock;
class Camera;
class NetworkPacket;
-struct QueuedMeshUpdate
-{
- v3s16 p;
- MeshMakeData *data;
- bool ack_block_to_server;
-
- QueuedMeshUpdate();
- ~QueuedMeshUpdate();
-};
-
enum LocalClientState {
LC_Created,
LC_Init,
LC_Ready
};
-/*
- A thread-safe queue of mesh update tasks
-*/
-class MeshUpdateQueue
-{
-public:
- MeshUpdateQueue();
-
- ~MeshUpdateQueue();
-
- /*
- peer_id=0 adds with nobody to send to
- */
- void addBlock(v3s16 p, MeshMakeData *data,
- bool ack_block_to_server, bool urgent);
-
- // Returned pointer must be deleted
- // Returns NULL if queue is empty
- QueuedMeshUpdate * pop();
-
- u32 size()
- {
- MutexAutoLock lock(m_mutex);
- return m_queue.size();
- }
-
-private:
- std::vector<QueuedMeshUpdate*> m_queue;
- std::set<v3s16> m_urgents;
- Mutex m_mutex;
-};
-
-struct MeshUpdateResult
-{
- v3s16 p;
- MapBlockMesh *mesh;
- bool ack_block_to_server;
-
- MeshUpdateResult():
- p(-1338,-1338,-1338),
- mesh(NULL),
- ack_block_to_server(false)
- {
- }
-};
-
-class MeshUpdateThread : public UpdateThread
-{
-private:
- MeshUpdateQueue m_queue_in;
- int m_generation_interval;
-
-protected:
- virtual void doUpdate();
-
-public:
-
- MeshUpdateThread();
-
- void enqueueUpdate(v3s16 p, MeshMakeData *data,
- bool ack_block_to_server, bool urgent);
- MutexedQueue<MeshUpdateResult> m_queue_out;
-
- v3s16 m_camera_offset;
-};
-
enum ClientEventType
{
CE_NONE,
@@ -471,6 +396,7 @@ public:
float getAnimationTime();
int getCrackLevel();
+ v3s16 getCrackPos();
void setCrack(int level, v3s16 pos);
u16 getHP();
@@ -726,11 +652,6 @@ private:
IntervalLimiter m_localdb_save_interval;
u16 m_cache_save_interval;
- // TODO: Add callback to update these when g_settings changes
- bool m_cache_smooth_lighting;
- bool m_cache_enable_shaders;
- bool m_cache_use_tangent_vertices;
-
ClientScripting *m_script;
bool m_modding_enabled;
UNORDERED_MAP<std::string, ModMetadata *> m_mod_storages;