From 04efdca2e10daa838dba5ea09a1b9552af1a6ba6 Mon Sep 17 00:00:00 2001
From: IR0NSIGHT <irnsght@googlemail.com>
Date: Wed, 25 Oct 2023 13:51:26 +0200
Subject: [PATCH] excavate x squared profile for rivers, puddles need new
 excavation too

---
 src/pathing/postprocessing.ts | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/pathing/postprocessing.ts b/src/pathing/postprocessing.ts
index 656e284..ddf18f2 100644
--- a/src/pathing/postprocessing.ts
+++ b/src/pathing/postprocessing.ts
@@ -34,7 +34,7 @@ type riverProfile = { width: number, depth: number, speed: number }
  * @param dist
  */
 const depthByDist = (maxWidth: number, maxDepth: number, dist: number): number => {
-    return (dist / maxWidth) * (dist / maxWidth) * maxDepth;
+    return maxDepth - ((dist / maxWidth) * (dist / maxWidth) * maxDepth);
 }
 
 export const applyRiverLayers = (river: point[], pondSurface: SeenSetReadOnly, riverExport: RiverExportTarget): void => {
@@ -44,7 +44,7 @@ export const applyRiverLayers = (river: point[], pondSurface: SeenSetReadOnly, r
             y: point.point.y,
             z: point.z,
             width: Math.sqrt(params.growthRate * index),
-            depth: 2,
+            depth: Math.sqrt(params.growthRate * index),
             speed: 1
         })
     )
@@ -64,7 +64,7 @@ export const applyRiverLayers = (river: point[], pondSurface: SeenSetReadOnly, r
             const lip = dimension.getSlope(point.x, point.y) > 1 ? 1 : 0 //1 == 45°
 
             const depth = depthByDist(profile.width, profile.depth, Math.sqrt(squaredDistToParent));
-            dimension.setHeightAt(point.x, point.y, point.parent.z - profile.depth - lip)
+            dimension.setHeightAt(point.x, point.y, point.parent.z - depth - lip)
             dimension.setWaterLevelAt(point.x, point.y, point.parent.z - lip)
         }