Browse Source

Interpolating from adjusted altitudes.

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
5ba06796b1
  1. 8
      src/engine/InterestManagement/HeightMap.java

8
src/engine/InterestManagement/HeightMap.java

@ -229,16 +229,18 @@ public class HeightMap {
// Interpolate height for this position using pixel array. // Interpolate height for this position using pixel array.
float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
interpolatedTerrainHeight += heightMapZone.worldAltitude;
// Heightmap blending is based on distance to edge of zone. // Heightmap blending is based on distance to edge of zone.
if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) 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 // We will need the parent height if we got this far into the method
parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent());
interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc);
interpolatedParentTerrainHeight += parentZone.worldAltitude;
Bounds blendBounds = Bounds.borrow(); Bounds blendBounds = Bounds.borrow();
zoneLoc.x = abs(zoneLoc.x); zoneLoc.x = abs(zoneLoc.x);
@ -262,9 +264,9 @@ public class HeightMap {
percentage = currentDelta / blendDelta; percentage = currentDelta / blendDelta;
else else
percentage = 0.0f; percentage = 0.0f;
float interpolatedWorldAltitude = FastMath.LERP(percentage, heightMapZone.worldAltitude, parentZone.worldAltitude);
interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight);
return interpolatedTerrainHeight + interpolatedWorldAltitude; return interpolatedTerrainHeight;
} }

Loading…
Cancel
Save