transfered from codeberg
This commit is contained in:
66
source_code/chunk_module/chunk/chunk.h
Normal file
66
source_code/chunk_module/chunk/chunk.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef chunk_h
|
||||
#define chunk_h
|
||||
|
||||
#include "raylib.h"
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#define chunk_size 32
|
||||
|
||||
struct cpu_mesh_data_struct;
|
||||
|
||||
typedef enum chunk_state_enum
|
||||
{
|
||||
state_new = 0,
|
||||
state_needs_data,
|
||||
state_getting_data,
|
||||
|
||||
state_needs_terrain,
|
||||
state_getting_terrain,
|
||||
|
||||
state_needs_lighting,
|
||||
state_getting_lighting,
|
||||
|
||||
state_needs_mesh,
|
||||
state_getting_mesh,
|
||||
|
||||
state_need_upload_to_gpu,
|
||||
state_chunk_pending_upload,
|
||||
state_chunk_uploaded_to_render_queue,
|
||||
state_chunk_is_uploading,
|
||||
state_chunk_finished_uploading
|
||||
} chunk_state_enum;
|
||||
|
||||
|
||||
typedef struct chunk_position_struct
|
||||
{
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
} chunk_position_struct;
|
||||
|
||||
typedef struct chunk_struct
|
||||
{
|
||||
_Atomic uint32_t reference_counter;
|
||||
chunk_position_struct position;
|
||||
atomic_int build_state;
|
||||
atomic_bool marked_for_unload;
|
||||
BoundingBox bounds;
|
||||
Model model;
|
||||
struct cpu_mesh_data_struct* pending_mesh;
|
||||
uint16_t block_data[chunk_size * chunk_size * chunk_size];
|
||||
uint8_t light_data[chunk_size * chunk_size * chunk_size];
|
||||
} chunk_struct;
|
||||
|
||||
chunk_struct* initialize_chunk(struct chunk_position_struct position_in_world);
|
||||
|
||||
chunk_position_struct offset_chunk_position(struct chunk_position_struct origin_to_offset,
|
||||
int32_t x_offset,
|
||||
int32_t y_offset,
|
||||
int32_t z_offset);
|
||||
|
||||
void destroy_chunk(struct chunk_struct* chunk);
|
||||
uint32_t index_chunk(int32_t x, int32_t y, int32_t z);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user