diff options
-rw-r--r-- | ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java index 9d4b343..1e50ba7 100644 --- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java +++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/TerrainGridCache.java @@ -298,14 +298,21 @@ public class TerrainGridCache implements TerrainCache, Runnable { int tileX = MathUtils.floor((float) x / tileSize); int tileY = MathUtils.floor((float) z / tileSize); final CacheData tileData; - final int cacheMin = -cacheSize / 2, cacheMax = cacheSize / 2 - (cacheSize % 2 == 0 ? 1 : 0); - if (tileX < cacheMin || tileX > cacheMax || tileY < cacheMin || tileY > cacheMax) { - tileData = null; - } else { - tileX = MathUtils.moduloPositive(tileX, cacheSize); - tileY = MathUtils.moduloPositive(tileY, cacheSize); - tileData = cache[tileX][tileY]; - } + // mallan - 2016-01-26: this conditional will ALWAYS fail once view has + // moved outside the origin cache bounds (tileX,tileY are source tile coordinates, + // cacheSize are desintation tile coordinates). The moduloPositive does what we need, + // this conditional breaks the terrain. + // final int cacheMin = -cacheSize / 2, cacheMax = cacheSize / 2 - (cacheSize % 2 == 0 ? 1 : 0); + // if (tileX < cacheMin || tileX > cacheMax || tileY < cacheMin || tileY > cacheMax) { + // tileData = null; + // } else { + // tileX = MathUtils.moduloPositive(tileX, cacheSize); + // tileY = MathUtils.moduloPositive(tileY, cacheSize); + // tileData = cache[tileX][tileY]; + // } + tileX = MathUtils.moduloPositive(tileX, cacheSize); + tileY = MathUtils.moduloPositive(tileY, cacheSize); + tileData = cache[tileX][tileY]; if (tileData == null || !tileData.isValid) { if (parentCache != null) { |