From 4be27816c2a403aca0313b39262d67609bff0bf1 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Sun, 3 Nov 2024 23:09:10 +0300 Subject: [PATCH] scenery: make render distance come from a define --- apps/demos/scenery/scenes/ingame.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/demos/scenery/scenes/ingame.c b/apps/demos/scenery/scenes/ingame.c index ef0c468..2e3ecc2 100644 --- a/apps/demos/scenery/scenes/ingame.c +++ b/apps/demos/scenery/scenes/ingame.c @@ -60,11 +60,14 @@ static void ingame_tick(State *state) { input_mouse_captured(scn->mouse_captured); #define TERRAIN_FREQUENCY 0.1f + #define TERRAIN_DISTANCE 64 - for (int ly = 128; ly--;) { - for (int lx = 128; lx--;) { - float x = SDL_truncf(scn->pos.x + 64 - (float)lx); - float y = SDL_truncf(scn->pos.z + 64 - (float)ly); + float const half_terrain_distance = (float)TERRAIN_DISTANCE / 2; + + for (int ly = TERRAIN_DISTANCE; ly--;) { + for (int lx = TERRAIN_DISTANCE; lx--;) { + float x = SDL_truncf(scn->pos.x + half_terrain_distance - (float)lx); + float y = SDL_truncf(scn->pos.z + half_terrain_distance - (float)ly); float d0 = stb_perlin_noise3((float)x * TERRAIN_FREQUENCY, (float)y * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6; float d1 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)y * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6;