Browse Source

Blender

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
cbc8216fe0
  1. 28
      src/engine/InterestManagement/HeightMap.java

28
src/engine/InterestManagement/HeightMap.java

@ -118,8 +118,8 @@ public class HeightMap {
int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents;
this.zoneLoadID = 0; this.zoneLoadID = 0;
this.seaLevel = 0; this.seaLevel = 0;
this.zone_minBlend = 256; this.zone_minBlend = 0;
this.zone_maxBlend = 256; this.zone_maxBlend = 0;
// Cache the full extents to avoid the calculation // 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); blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f);
float currentArea = (blendBounds.getHalfExtents().x * 2) * float maxBlendArea = (heightMapZone.maxBlend.getHalfExtents().x) *
(blendBounds.getHalfExtents().y * 2); (heightMapZone.maxBlend.getHalfExtents().y);
float zoneArea = (heightMapZone.getBounds().getHalfExtents().x * 2) * float currentArea = (blendBounds.getHalfExtents().x) *
(heightMapZone.getBounds().getHalfExtents().y * 2); (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; return interpolatedTerrainHeight + heightMapZone.worldAltitude;
} }

Loading…
Cancel
Save