forked from MagicBane/Server
Cleanup of getWorldHeight()
This commit is contained in:
@@ -199,28 +199,31 @@ public class HeightMap {
|
||||
|
||||
public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) {
|
||||
|
||||
if (currentZone == null)
|
||||
return 0;
|
||||
Zone heightMapZone;
|
||||
|
||||
currentZone = getNextZoneWithTerrain(currentZone);
|
||||
// Seafloor is rather flat.
|
||||
|
||||
if (currentZone == ZoneManager.getSeaFloor())
|
||||
return currentZone.getAbsY();
|
||||
return currentZone.worldAltitude;
|
||||
|
||||
HeightMap heightMap = currentZone.getHeightMap();
|
||||
// Retrieve the next zone with a heightmap attached.
|
||||
// Zones without a heightmap use the next zone up the
|
||||
// tree to calculate heights from.
|
||||
|
||||
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor()))
|
||||
return currentZone.getAbsY();
|
||||
heightMapZone = getNextZoneWithTerrain(currentZone);
|
||||
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, currentZone);
|
||||
// Transform world loc into zone space coordinate system
|
||||
|
||||
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, heightMapZone);
|
||||
|
||||
float worldAltitude = currentZone.worldAltitude;
|
||||
// Interpolate height for this position using pixel array.
|
||||
|
||||
float realWorldAltitude = interaltitude + worldAltitude;
|
||||
float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||
|
||||
// Position returned from Heightmap engine is relative to zone world height
|
||||
|
||||
return interpolatedTerrainHeight + heightMapZone.worldAltitude;
|
||||
|
||||
return realWorldAltitude;
|
||||
}
|
||||
|
||||
public static float getWorldHeight(Vector3fImmutable worldLoc) {
|
||||
|
||||
Reference in New Issue
Block a user