From 5ba06796b19f4a92c7b634a4fe0e50e187f5491a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 18 Sep 2023 03:19:00 -0400 Subject: [PATCH] Interpolating from adjusted altitudes. --- src/engine/InterestManagement/HeightMap.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 09d7b83c..44de1097 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -229,16 +229,18 @@ public class HeightMap { // Interpolate height for this position using pixel array. float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); + interpolatedTerrainHeight += heightMapZone.worldAltitude; // Heightmap blending is based on distance to edge of zone. if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) - return interpolatedTerrainHeight + heightMapZone.worldAltitude; + return interpolatedTerrainHeight; // We will need the parent height if we got this far into the method parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); + interpolatedParentTerrainHeight += parentZone.worldAltitude; Bounds blendBounds = Bounds.borrow(); zoneLoc.x = abs(zoneLoc.x); @@ -262,9 +264,9 @@ public class HeightMap { percentage = currentDelta / blendDelta; else percentage = 0.0f; - float interpolatedWorldAltitude = FastMath.LERP(percentage, heightMapZone.worldAltitude, parentZone.worldAltitude); + interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); - return interpolatedTerrainHeight + interpolatedWorldAltitude; + return interpolatedTerrainHeight; }