From cbc8216fe09e65f4ea6866f283637ef022492d5f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 18 Sep 2023 00:05:53 -0400 Subject: [PATCH] Blender --- src/engine/InterestManagement/HeightMap.java | 28 ++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 64400671..6527deb4 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -118,8 +118,8 @@ public class HeightMap { int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; this.zoneLoadID = 0; this.seaLevel = 0; - this.zone_minBlend = 256; - this.zone_maxBlend = 256; + this.zone_minBlend = 0; + this.zone_maxBlend = 0; // Cache the full extents to avoid the calculation @@ -246,14 +246,26 @@ public class HeightMap { blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); - float currentArea = (blendBounds.getHalfExtents().x * 2) * - (blendBounds.getHalfExtents().y * 2); - float zoneArea = (heightMapZone.getBounds().getHalfExtents().x * 2) * - (heightMapZone.getBounds().getHalfExtents().y * 2); + float maxBlendArea = (heightMapZone.maxBlend.getHalfExtents().x) * + (heightMapZone.maxBlend.getHalfExtents().y); + float currentArea = (blendBounds.getHalfExtents().x) * + (blendBounds.getHalfExtents().y); + float zoneArea = (heightMapZone.getBounds().getHalfExtents().x) * + (heightMapZone.getBounds().getHalfExtents().y); - float areaDelta = currentArea / zoneArea; + float blendDelta = zoneArea - maxBlendArea; + float currentDelta = zoneArea - currentArea; - interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight); + float percentage; + + if (currentDelta != 0 && blendDelta != 0) + percentage = currentDelta / blendDelta; + else + percentage = 0.0f; + + interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); + + interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); return interpolatedTerrainHeight + heightMapZone.worldAltitude; }