|
|
|
@ -118,8 +118,8 @@ public class HeightMap {
@@ -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 {
@@ -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; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|