From 5db8c47aa898ce338f6f385540695c2874c60d4d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:47:35 -0400 Subject: [PATCH] Clamp value at pole --- src/engine/InterestManagement/HeightMap.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 3439663a..d3361472 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -327,15 +327,15 @@ public class HeightMap { // Clamp values. - if (zoneLoc.x >= this.fullExtentsX) - Logger.error("Outside of zone"); - - if (zoneLoc.y >= this.fullExtentsY) - Logger.error("Outside of zone"); - float xBucket = zoneLoc.x / this.bucketWidthX; float yBucket = zoneLoc.y / this.bucketWidthY; + if (xBucket >= this.bucketCountX) + xBucket = this.bucketCountX - 1; + + if (yBucket >= this.bucketCountY) + yBucket = this.bucketCountY - 1; + return new Vector2f(xBucket, yBucket); }