forked from MagicBane/Server
Update to blend logic.
This commit is contained in:
@@ -34,28 +34,23 @@ public class HeightMap {
|
|||||||
|
|
||||||
// Class variables
|
// Class variables
|
||||||
|
|
||||||
public static float SCALEVALUE = 1.0f / 255;
|
|
||||||
// Heightmap data for all zones.
|
|
||||||
|
|
||||||
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>();
|
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>();
|
||||||
|
// Heightmap data for all zones.
|
||||||
|
public static float SCALEVALUE = 1.0f / 255;
|
||||||
|
|
||||||
// Bootstrap Tracking
|
// Bootstrap Tracking
|
||||||
|
|
||||||
public static int heightMapsCreated = 0;
|
public static int heightMapsCreated = 0;
|
||||||
public static HeightMap PlayerCityHeightMap;
|
public static HeightMap PlayerCityHeightMap;
|
||||||
|
|
||||||
// Heightmap data for this heightmap
|
// Heightmap data for this heightmap
|
||||||
|
|
||||||
public BufferedImage heightmapImage;
|
|
||||||
|
|
||||||
public final int heightMapID;
|
public final int heightMapID;
|
||||||
public final int maxHeight;
|
public final int maxHeight;
|
||||||
public final int fullExtentsX;
|
public final int fullExtentsX;
|
||||||
public final int fullExtentsY;
|
public final int fullExtentsY;
|
||||||
|
public final int zoneLoadID;
|
||||||
|
public BufferedImage heightmapImage;
|
||||||
public float bucketWidthX;
|
public float bucketWidthX;
|
||||||
public float bucketWidthY;
|
public float bucketWidthY;
|
||||||
public final int zoneLoadID;
|
|
||||||
public float seaLevel = 0;
|
public float seaLevel = 0;
|
||||||
public int[][] pixelColorValues;
|
public int[][] pixelColorValues;
|
||||||
|
|
||||||
@@ -246,31 +241,21 @@ public class HeightMap {
|
|||||||
parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent());
|
parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent());
|
||||||
interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc);
|
interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc);
|
||||||
|
|
||||||
// Between maxBlend and minBlend distance from edge of zone we LERP between the two heights
|
Bounds blendBounds = Bounds.borrow();
|
||||||
|
zoneLoc.x = abs(zoneLoc.x);
|
||||||
|
zoneLoc.y = abs(zoneLoc.x);
|
||||||
|
|
||||||
if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) {
|
blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f);
|
||||||
|
|
||||||
Bounds blendBounds = Bounds.borrow();
|
float currentArea = (blendBounds.getHalfExtents().x * 2) *
|
||||||
zoneLoc.x = abs(zoneLoc.x);
|
(blendBounds.getHalfExtents().y * 2);
|
||||||
zoneLoc.y = abs(zoneLoc.x);
|
float zoneArea = (heightMapZone.getBounds().getHalfExtents().x * 2) *
|
||||||
blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f);
|
(heightMapZone.getBounds().getHalfExtents().y * 2);
|
||||||
|
|
||||||
float childArea = (blendBounds.getHalfExtents().x * 2) *
|
float areaDelta = currentArea / zoneArea;
|
||||||
(blendBounds.getHalfExtents().y * 2);
|
|
||||||
float parentArea = (parentZone.minBlend.getHalfExtents().x * 2) *
|
|
||||||
(parentZone.minBlend.getHalfExtents().y * 2);
|
|
||||||
|
|
||||||
float areaDelta = childArea / parentArea;
|
interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight);
|
||||||
|
return interpolatedTerrainHeight + heightMapZone.worldAltitude;
|
||||||
interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight);
|
|
||||||
return interpolatedTerrainHeight + heightMapZone.worldAltitude;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Past min blend we just return the parent height.
|
|
||||||
// This should never be reached
|
|
||||||
|
|
||||||
return interpolatedParentTerrainHeight + heightMapZone.worldAltitude;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,12 +64,7 @@ public class GetHeightCmd extends AbstractDevCmd {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.minBlend)) {
|
this.throwbackInfo(playerCharacter, "Blend: Min (LERP)");
|
||||||
this.throwbackInfo(playerCharacter, "Blend: Min (LERP)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.throwbackInfo(playerCharacter, "Blend: None (Parent)");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ public class Zone extends AbstractGameObject {
|
|||||||
private float seaLevel = 0f;
|
private float seaLevel = 0f;
|
||||||
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
public static long lastRespawn = 0;
|
public static long lastRespawn = 0;
|
||||||
|
|
||||||
public Bounds minBlend;
|
|
||||||
public Bounds maxBlend;
|
public Bounds maxBlend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,14 +189,10 @@ public class Zone extends AbstractGameObject {
|
|||||||
// Set heightmap blending bounds
|
// Set heightmap blending bounds
|
||||||
|
|
||||||
if (heightMap == null) {
|
if (heightMap == null) {
|
||||||
this.minBlend = this.getBounds();
|
|
||||||
this.maxBlend = this.getBounds();
|
this.maxBlend = this.getBounds();
|
||||||
} else {
|
} else {
|
||||||
this.minBlend = Bounds.borrow();
|
|
||||||
this.maxBlend = Bounds.borrow();
|
this.maxBlend = Bounds.borrow();
|
||||||
|
this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f);
|
||||||
this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f);
|
|
||||||
this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.minBlend.getHalfExtents().subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user