aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-09-20 05:27:36 +0000
committernathan <nathansmith@disroot.org>2025-09-20 05:27:36 +0000
commitc7b41bd1750807b366308a8eb41df3218efde1a7 (patch)
tree1cb4382c2001802cc775462fc0c6cec145dcabb1
parent5e3794220e5eb520c207a80aee5e706c28bcd743 (diff)
downloadFindThings-c7b41bd1750807b366308a8eb41df3218efde1a7.tar.gz
FindThings-c7b41bd1750807b366308a8eb41df3218efde1a7.tar.bz2
FindThings-c7b41bd1750807b366308a8eb41df3218efde1a7.zip
At least I dont shit done
-rw-r--r--src/world.c38
1 files changed, 33 insertions, 5 deletions
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);