diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index aa395368..5566f6e0 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -53,8 +53,6 @@ public class HeightMap { private float bucketWidthY; private final int zoneLoadID; private float seaLevel = 0; - private final float outsetX; - private final float outsetZ; private int[][] pixelColorValues; public HeightMap(ResultSet rs) throws SQLException { @@ -65,9 +63,6 @@ public class HeightMap { int halfExtentsY = rs.getInt("zRadius"); this.zoneLoadID = rs.getInt("zoneLoadID"); this.seaLevel = rs.getFloat("seaLevel"); - this.outsetX = rs.getFloat("outsetX"); - this.outsetZ = rs.getFloat("outsetZ"); - // Cache the full extents to avoid the calculation @@ -90,16 +85,15 @@ public class HeightMap { Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e); } - // We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin. - - // this.heightmapImage = MapLoader.flipImage(this.heightmapImage); - // Calculate the data we do not load from table - float numOfBuckets = this.heightmapImage.getWidth() - 1; - float calculatedWidth = this.fullExtentsX / numOfBuckets; - this.bucketWidthX = calculatedWidth; - this.bucketWidthY = this.bucketWidthX; // This makes no sense. + float numOfBucketsX = this.heightmapImage.getWidth() - 1; + float calculatedWidthX = this.fullExtentsX / numOfBucketsX; + this.bucketWidthX = calculatedWidthX; + + float numOfBucketsY = this.heightmapImage.getWidth() - 1; + float calculatedWidthY = this.fullExtentsY / numOfBucketsY; + this.bucketWidthX = calculatedWidthY; // Generate pixel array from image data @@ -119,8 +113,6 @@ public class HeightMap { int halfExtentsY = (int) Enum.CityBoundsType.ZONE.extents; this.zoneLoadID = 0; this.seaLevel = 0; - this.outsetX = 128; - this.outsetZ = 128; // Cache the full extents to avoid the calculation @@ -152,8 +144,6 @@ public class HeightMap { int halfExtentsY = (int) zone.getBounds().getHalfExtents().y; this.zoneLoadID = 0; this.seaLevel = 0; - this.outsetX = 0; - this.outsetZ = 0; // Cache the full extents to avoid the calculation @@ -209,8 +199,6 @@ public class HeightMap { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { - Vector2f parentLoc = new Vector2f(-1, -1); - if (currentZone == null) return 0; @@ -219,17 +207,12 @@ public class HeightMap { if (currentZone == ZoneManager.getSeaFloor()) return currentZone.getAbsY(); - Zone parentZone = getNextZoneWithTerrain(currentZone.getParent()); HeightMap heightMap = currentZone.getHeightMap(); if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) return currentZone.getAbsY(); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, currentZone); - Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLoc, currentZone); - - if ((parentZone != null) && (parentZone.getHeightMap() != null)) - parentLoc = ZoneManager.worldToZoneSpace(worldLoc, parentZone); float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); @@ -237,66 +220,6 @@ public class HeightMap { float realWorldAltitude = interaltitude + worldAltitude; - //OUTSET - - if (parentZone != null) { - - float parentXRadius = currentZone.getBounds().getHalfExtents().x; - float parentZRadius = currentZone.getBounds().getHalfExtents().y; - - float offsetX = Math.abs((localLocFromCenter.x / parentXRadius)); - float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius)); - - float bucketScaleX = heightMap.outsetX / parentXRadius; - float bucketScaleZ = heightMap.outsetZ / parentZRadius; - - float outsideGridSizeX = 1 - bucketScaleX; //32/256 - float outsideGridSizeZ = 1 - bucketScaleZ; - float weight; - - double scale; - - if (offsetX > outsideGridSizeX && offsetX > offsetZ) { - weight = (offsetX - outsideGridSizeX) / bucketScaleX; - scale = Math.atan2((.5 - weight) * 3.1415927, 1); - - float scaleChild = (float) ((scale + 1) * .5); - float scaleParent = 1 - scaleChild; - - float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc); - float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone)); - - parentCenterAltitude += currentZone.getYCoord(); - parentCenterAltitude += interaltitude; - - float firstScale = parentAltitude * scaleParent; - float secondScale = parentCenterAltitude * scaleChild; - float outsetALt = firstScale + secondScale; - - outsetALt += currentZone.getParent().worldAltitude; - realWorldAltitude = outsetALt; - - } else if (offsetZ > outsideGridSizeZ) { - - weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ; - scale = Math.atan2((.5 - weight) * 3.1415927, 1); - - float scaleChild = (float) ((scale + 1) * .5); - float scaleParent = 1 - scaleChild; - float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc); - float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone)); - - parentCenterAltitude += currentZone.getYCoord(); - parentCenterAltitude += interaltitude; - float firstScale = parentAltitude * scaleParent; - float secondScale = parentCenterAltitude * scaleChild; - float outsetALt = firstScale + secondScale; - - outsetALt += currentZone.getParent().worldAltitude; - realWorldAltitude = outsetALt; - } - } - return realWorldAltitude; }