1 #ifndef _CLIENT_TERRAIN_H_
2 #define _CLIENT_TERRAIN_H_
6 #include "client/model.h"
7 #include "common/terrain.h"
10 #define CHUNK_MODE_NOCREATE 2
22 TerrainChunkState state;
23 pthread_rwlock_t lock_state;
25 // accessed only by recv thread
26 TerrainChunk *neighbors[6];
27 unsigned int num_neighbors;
29 // write is protected by mtx_model, read is atomic
30 atomic_bool depends[6];
34 pthread_mutex_t mtx_model;
36 // protected by chunk data lock
39 // accessed only by sync thread
43 extern Terrain *client_terrain;
45 void client_terrain_init(); // called on startup
46 void client_terrain_deinit(); // called on shutdown
47 void client_terrain_set_load_distance(u32 dist); // update load distance
48 u32 client_terrain_get_load_distance(); // return load distance
49 void client_terrain_start(); // start meshgen and sync threads
50 void client_terrain_stop(); // stop meshgen and sync threads
51 void client_terrain_meshgen_task(TerrainChunk *chunk, bool changed); // enqueue chunk to mesh update queue
52 void client_terrain_receive_chunk(void *peer, ToClientChunk *pkt); // callback to deserialize chunk from network