From 5af838f90642a4ecb63cec1b36a48c296a27d0b4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 14 Sep 2016 22:46:21 -0400 Subject: [PATCH] v0.4.2b: fixed more issues with tilemap culling --- SPD-classes/src/main/java/com/watabou/noosa/Tilemap.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/noosa/Tilemap.java b/SPD-classes/src/main/java/com/watabou/noosa/Tilemap.java index c9c44d2c2..8ae3f8148 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/Tilemap.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/Tilemap.java @@ -237,12 +237,12 @@ public class Tilemap extends Visual { //between them, this culls a good number of none-visible tiles while keeping to 1 draw topLeft = Math.max(camX, 0) + Math.max(camY*mapWidth, 0); - while(bufferPositions[topLeft] == -1) + while(topLeft < bufferPositions.length && bufferPositions[topLeft] == -1) topLeft++; bottomRight = Math.min(camX+camW, mapWidth-1) + Math.min((camY+camH)*mapWidth, (mapHeight-1)*mapWidth); - while(bufferPositions[bottomRight] == -1) + while(bottomRight >= topLeft && bufferPositions[bottomRight] == -1) bottomRight--; length = bufferPositions[bottomRight] - bufferPositions[topLeft] + 1; @@ -251,7 +251,8 @@ public class Tilemap extends Visual { if (camX >= mapWidth || camY >= mapHeight || camW + camW <= 0 - || camH + camH <= 0) + || camH + camH <= 0 + || length <= 0) return; NoosaScript script = NoosaScriptNoLighting.get();