Browse Source

Preparation for blend lerp insertion.

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
d33ad0cdef
  1. 22
      src/engine/InterestManagement/HeightMap.java

22
src/engine/InterestManagement/HeightMap.java

@ -12,6 +12,7 @@ import engine.Enum;
import engine.gameManager.ConfigManager; 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.Vector2f; import engine.math.Vector2f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.Zone; import engine.objects.Zone;
@ -26,6 +27,8 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import static java.lang.Math.abs;
public class HeightMap { public class HeightMap {
// Class variables // Class variables
@ -206,6 +209,7 @@ public class HeightMap {
public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) {
Zone heightMapZone; Zone heightMapZone;
float worldHeight;
// Seafloor is rather flat. // Seafloor is rather flat.
@ -226,6 +230,24 @@ public class HeightMap {
float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
// Heightmap blending is based on distance to edge of zone.
if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) {
worldHeight = interpolatedTerrainHeight + heightMapZone.worldAltitude;
return worldHeight;
}
if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) {
// How far into blend zone are we?
Bounds blendBounds = Bounds.borrow();
zoneLoc.x = abs(zoneLoc.x);
zoneLoc.y = abs(zoneLoc.x);
blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f);
}
// Position returned from Heightmap engine is relative to zone world height // Position returned from Heightmap engine is relative to zone world height
return interpolatedTerrainHeight + heightMapZone.worldAltitude; return interpolatedTerrainHeight + heightMapZone.worldAltitude;

Loading…
Cancel
Save