diff --git a/core/src/mindustry/graphics/FloorRenderer.java b/core/src/mindustry/graphics/FloorRenderer.java index 9f46b65c87..e52bb5c04f 100644 --- a/core/src/mindustry/graphics/FloorRenderer.java +++ b/core/src/mindustry/graphics/FloorRenderer.java @@ -17,7 +17,7 @@ import java.util.*; import static mindustry.Vars.*; public class FloorRenderer implements Disposable{ - private static final int chunksize = mobile ? 16 : 32; + private static final int chunksize = mobile ? 16 : 32, chunkunits = chunksize * tilesize; private int[][][] cache; private MultiCacheBatch cbatch; @@ -43,11 +43,13 @@ public class FloorRenderer implements Disposable{ Camera camera = Core.camera; - int crangex = (int)(camera.width / (chunksize * tilesize)) + 1; - int crangey = (int)(camera.height / (chunksize * tilesize)) + 1; + float pad = tilesize/2f; - int camx = (int)(camera.position.x / (chunksize * tilesize)); - int camy = (int)(camera.position.y / (chunksize * tilesize)); + int + minx = (int)((camera.position.x - camera.width/2f - pad) / chunkunits), + miny = (int)((camera.position.y - camera.height/2f - pad) / chunkunits), + maxx = Mathf.ceil((camera.position.x + camera.width/2f + pad) / chunkunits), + maxy = Mathf.ceil((camera.position.y + camera.height/2f + pad) / chunkunits); int layers = CacheLayer.all.length; @@ -55,15 +57,12 @@ public class FloorRenderer implements Disposable{ drawnLayerSet.clear(); //preliminary layer check - for(int x = -crangex; x <= crangex; x++){ - for(int y = -crangey; y <= crangey; y++){ - int worldx = camx + x; - int worldy = camy + y; + for(int x = minx; x <= maxx; x++){ + for(int y = miny; y <= maxy; y++){ - if(!Structs.inBounds(worldx, worldy, cache)) - continue; + if(!Structs.inBounds(x, y, cache)) continue; - int[] chunk = cache[worldx][worldy]; + int[] chunk = cache[x][y]; //loop through all layers, and add layer index if it exists for(int i = 0; i < layers; i++){ diff --git a/gradle.properties b/gradle.properties index 6ba4b66232..e5e9f62ef1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=363054f79b8c38a279c261677bd008392926f286 +archash=13b82d76b623e9c6492f3005adc17babad5cb9bf