Speed up terrain generation

This commit is contained in:
chelsea
2026-05-02 19:03:57 -05:00
parent d5fd7e6bb5
commit 1addbada63
3 changed files with 68 additions and 30 deletions

View File

@@ -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);