Minor floor renderer optimization
This commit is contained in:
@@ -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++){
|
||||
|
||||
Reference in New Issue
Block a user