From 279a0aed9149b7492dca32a4d9a34d5c581ea803 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 07:04:27 -0400 Subject: [PATCH] Use half extents as offset from center --- src/engine/InterestManagement/Terrain.java | 4 ++-- src/engine/devcmd/cmds/GetHeightCmd.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 99b07424..dddd4a1c 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -184,8 +184,8 @@ public class Terrain { // Normalize terrain offset - Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.terrain_size.x, - Math.abs(zone_offset.y) / terrain_size.y); + Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.major_radius, + Math.abs(zone_offset.y) / this.zone.minor_radius); float xval; diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 12701f12..ff88d6f0 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -40,8 +40,8 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); - Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.terrain.terrain_size.x, - Math.abs(zoneOffset.y) / heightmapZone.terrain.terrain_size.y); + Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.major_radius, + Math.abs(zoneOffset.y) / heightmapZone.minor_radius); Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); gridSquare.x = (float) Math.floor(gridSquare.x);