Speed up terrain generation
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#define CHUNK_SIZE 16
|
||||
#define CHUNK_HEIGHT 256
|
||||
#define WORLDGEN_HEIGHT_CACHE_SIZE 32768
|
||||
|
||||
enum BlockId {
|
||||
BLOCK_BEDROCK = 0,
|
||||
@@ -64,6 +65,13 @@ typedef struct {
|
||||
uint16_t blocks[CHUNK_HEIGHT][CHUNK_SIZE][CHUNK_SIZE];
|
||||
} chunk_data;
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int z;
|
||||
int value;
|
||||
uint8_t valid;
|
||||
} worldgen_height_cache_entry;
|
||||
|
||||
typedef struct {
|
||||
simplex_noise noise;
|
||||
int sea_level;
|
||||
@@ -75,6 +83,7 @@ typedef struct {
|
||||
size_t trail_segment_cap;
|
||||
int prepass_done;
|
||||
int prepass_min_x, prepass_max_x, prepass_min_z, prepass_max_z;
|
||||
worldgen_height_cache_entry height_cache[WORLDGEN_HEIGHT_CACHE_SIZE];
|
||||
} worldgen_ctx;
|
||||
|
||||
void worldgen_init(worldgen_ctx *ctx, int world_seed, int sea_level, int snow_line);
|
||||
|
||||
Reference in New Issue
Block a user