aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);