diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index f49eb9f3..9de5e0a6 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -102,17 +102,26 @@ public class Terrain { // Retrieve the next zone with a terrain defined. Zone terrainZone = getNextZoneWithTerrain(zone); + Zone parentZone = getNextZoneWithTerrain(zone); // Transform world loc into zone space coordinate system Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(world_loc, terrainZone); + Vector2f terrainOffset = ZoneManager.worldToZoneOffset(world_loc, terrainZone); + Vector2f parentLoc = ZoneManager.worldToTerrainSpace(world_loc, parentZone); // Interpolate height for this position in terrain float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedChildHeight += terrainZone.global_height; - return interpolatedChildHeight; + float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc); + interpolatedParentTerrainHeight += parentZone.global_height; + + // Blend between terrains + + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + } public static float getWorldHeight(Vector3fImmutable world_loc) {