From 6bcf165f3af3da713953b9b3b80b4f101f7a0f7a Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 28 Jul 2025 21:07:22 -0600 Subject: Lazy --- src/game.c | 8 ++++---- src/world.c | 19 ++++++++++++------- src/world.h | 7 +++++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/game.c b/src/game.c index 3669c10..427ffdf 100644 --- a/src/game.c +++ b/src/game.c @@ -29,13 +29,13 @@ void initGame(Game* game) LoadTextureCubemap(game->assets.images[SKYBOX_IMAGE], CUBEMAP_LAYOUT_AUTO_DETECT); - // Player. - game->player = createPlayer(); - game->player.position = (Vector3){0.0, 30.0, 0.0}; - // World. game->world = createWorld(134235234); + // Player. + game->player = createPlayer(); + game->player.position = Vector3Scale(game->world.size, 0.5); + DisableCursor(); } diff --git a/src/world.c b/src/world.c index c2159d8..fd6fc19 100644 --- a/src/world.c +++ b/src/world.c @@ -328,9 +328,9 @@ void buildWorldBVH(World* world) world->bvhDebugSelect = 0; } -Seed generateWorldPlants(World* world, Seed seed) +Seed generateWorldPlants(World* world, Seed seed, int start, int end) { - for (int index = 0; index < WORLD_PLANT_COUNT; ++index) + for (int index = start; index < end; ++index) { FT_RANDOM16(seed); @@ -355,9 +355,9 @@ Seed generateWorldPlants(World* world, Seed seed) return seed; } -Seed generateWorldItems(World* world, Seed seed) +Seed generateWorldItems(World* world, Seed seed, int start, int end) { - for (int index = WORLD_PLANT_COUNT; index < WORLD_ENTITY_MAX; ++index) + for (int index = start; index < end; ++index) { FT_RANDOM16(seed); @@ -381,7 +381,12 @@ Seed generateWorldItems(World* world, Seed seed) Seed generatePond(World* world, Seed seed) { - Vector3 position; + // Get position. + int distanceRange = PLACE_POND_MAX_DISTANCE * 2; + Vector3 position = Vector3Scale(world->size, 0.5); + position.x += FT_RANDOM16(seed) % distanceRange - PLACE_POND_MAX_DISTANCE; + position.z += FT_RANDOM16(seed) % distanceRange - PLACE_POND_MAX_DISTANCE; + return seed; } @@ -415,8 +420,8 @@ World createWorld(Seed seed) // Places. generatePond(&world, seed); - seed = generateWorldPlants(&world, seed); - seed = generateWorldItems(&world, seed); + seed = generateWorldPlants(&world, seed, 0, WORLD_PLANT_COUNT); + seed = generateWorldItems(&world, seed, WORLD_PLANT_COUNT, WORLD_ENTITY_MAX); // Generate BVH. double currentTime = GetTime(); diff --git a/src/world.h b/src/world.h index 3b1ca4d..2097c94 100644 --- a/src/world.h +++ b/src/world.h @@ -5,8 +5,8 @@ #ifndef WORLD_H #define WORLD_H -#define WORLD_ENTITY_MAX 1500 -#define WORLD_PLANT_COUNT 500 +#define WORLD_ENTITY_MAX 3000 +#define WORLD_PLANT_COUNT 1000 #define WORLD_PLACE_COUNT 1 #define WORLD_SIZE (Vector3){4096.0, 256.0, 4096.0} @@ -23,6 +23,9 @@ #define BVH_MAX_BRANCH_COUNT 8 #define BVH_BOX_MAX 100.0 +// Places. +#define PLACE_POND_MAX_DISTANCE 100 // Max distance from center. + // UID for anything in the world. typedef int16_t WorldUID; typedef int Seed; -- cgit v1.2.3