forked from MagicBane/Server
Blend lerp implemented.
This commit is contained in:
@@ -13,6 +13,7 @@ import engine.gameManager.ConfigManager;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
|
import engine.math.FastMath;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
@@ -231,13 +232,12 @@ 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);
|
||||||
|
worldHeight = 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)
|
||||||
worldHeight = interpolatedTerrainHeight + heightMapZone.worldAltitude;
|
|
||||||
return worldHeight;
|
return worldHeight;
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@@ -253,12 +253,21 @@ public class HeightMap {
|
|||||||
zoneLoc.y = abs(zoneLoc.x);
|
zoneLoc.y = abs(zoneLoc.x);
|
||||||
blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f);
|
blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f);
|
||||||
|
|
||||||
|
float childArea = (blendBounds.getHalfExtents().x * 2) *
|
||||||
|
(blendBounds.getHalfExtents().y * 2);
|
||||||
|
float parentArea = (parentZone.minBlend.getHalfExtents().x * 2) *
|
||||||
|
(parentZone.minBlend.getHalfExtents().y * 2);
|
||||||
|
|
||||||
|
float areaDelta = childArea / parentArea;
|
||||||
|
|
||||||
|
interpolatedTerrainHeight = FastMath.LERP(interpolatedTerrainHeight, parentHeight, areaDelta);
|
||||||
|
return interpolatedTerrainHeight + heightMapZone.worldAltitude;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position returned from Heightmap engine is relative to zone world height
|
// Past min blend we just return the parent height.
|
||||||
|
|
||||||
return interpolatedTerrainHeight + heightMapZone.worldAltitude;
|
return parentHeight + heightMapZone.worldAltitude;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user