chunk.h (732B)
1 #ifndef CHUNK_H 2 #define CHUNK_H 3 4 #include "mesh.h" 5 #include "sdf.h" 6 #include "threadpool.h" 7 #include "types.h" 8 9 #include <pthread.h> 10 11 #define CHUNK_WIDTH 16 12 #define CHUNK_VOLUME (CHUNK_WIDTH * CHUNK_WIDTH * CHUNK_WIDTH) 13 14 #define CHUNK_PWIDTH (CHUNK_WIDTH + 1) 15 #define CHUNK_PVOLUME (CHUNK_PWIDTH * CHUNK_PWIDTH * CHUNK_PWIDTH) 16 17 typedef struct UpdateArgs UpdateArgs; 18 19 typedef struct { 20 IVec3 origin; 21 Mesh mesh; 22 23 UpdateArgs *update_args; 24 pthread_mutex_t mesh_mutex; 25 u32 mesh_update_count; 26 } Chunk; 27 28 void Chunk_init(Chunk *c); 29 void Chunk_free(Chunk *c); 30 31 void Chunk_updateOrigin(Chunk *c, IVec3 origin); 32 void Chunk_updateMesh(Chunk *c, SDF f, f32 isolevel, ThreadPool *pool); 33 34 void Chunk_drawMesh(Chunk *c); 35 36 #endif