From c7b41bd1750807b366308a8eb41df3218efde1a7 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 19 Sep 2025 23:27:36 -0600 Subject: At least I dont shit done --- src/world.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/world.c b/src/world.c index 026a5ed..82ee6da 100644 --- a/src/world.c +++ b/src/world.c @@ -377,6 +377,39 @@ Seed putEntityInRandomPlace(const World* world, Seed seed, Entity* entity) return seed; } +void setWorldAreaToHeight(Color* heightmap, Rectangle area, int height) +{ + for (int y = area.y; y < area.y + area.height; ++y) + { + for (int x = area.x; x < area.x + area.width; ++x) + { + heightmap[y * WORLD_IMAGE_WIDTH + x] = + (Color){height, height, height, 255}; + } + } +} + +void averageOutAreaWorld(const World* world, Color* heightmap, Rectangle area) +{ + int height = 0; + int count = 0; + + // Get average height. + for (int y = area.y; y < area.y + area.height; ++y) + { + for (int x = area.x; x < area.x + area.width; ++x) + { + height += heightmap[y * WORLD_IMAGE_WIDTH + x].r; + ++count; + } + } + + height /= count; + + // Set to that height. + setWorldAreaToHeight(heightmap, area, height); +} + Seed generatePond(World* world, Color* heightmap, WorldUID id, Seed seed) { // Create pond entity. @@ -677,11 +710,6 @@ World createWorld(Seed seed, const Assets* assets) end = WORLD_ENTITY_MAX - 1; seed = generateWorldItems(&world, seed, start, end); - // Test Samantha. - Entity samantha = createEntity(SAMANTHA, Vector3Scale(world.size, 0.5)); - placeEntityOnGround(&samantha, &world); - world.entities[WORLD_ENTITY_MAX - 1] = samantha; - // Generate BVH. double currentTime = GetTime(); buildWorldBVH(&world); -- cgit v1.2.3