Re-packed sprites from PR

This commit is contained in:
Anuken
2020-09-28 18:42:09 -04:00
parent d3863a7550
commit c89d6f6b74
11 changed files with 14 additions and 24 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 KiB

After

Width:  |  Height:  |  Size: 968 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 KiB

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

After

Width:  |  Height:  |  Size: 419 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

After

Width:  |  Height:  |  Size: 419 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -20,7 +20,7 @@ public class FloorRenderer implements Disposable{
//TODO find out number with best performance //TODO find out number with best performance
private static final int chunksize = mobile ? 16 : 32; private static final int chunksize = mobile ? 16 : 32;
private Chunk[][] cache; private int[][][] cache;
private MultiCacheBatch cbatch; private MultiCacheBatch cbatch;
private IntSet drawnLayerSet = new IntSet(); private IntSet drawnLayerSet = new IntSet();
private IntSet recacheSet = new IntSet(); private IntSet recacheSet = new IntSet();
@@ -63,11 +63,11 @@ public class FloorRenderer implements Disposable{
if(!Structs.inBounds(worldx, worldy, cache)) if(!Structs.inBounds(worldx, worldy, cache))
continue; continue;
Chunk chunk = cache[worldx][worldy]; int[] chunk = cache[worldx][worldy];
//loop through all layers, and add layer index if it exists //loop through all layers, and add layer index if it exists
for(int i = 0; i < layers; i++){ for(int i = 0; i < layers; i++){
if(chunk.caches[i] != -1 && i != CacheLayer.walls.ordinal()){ if(chunk[i] != -1 && i != CacheLayer.walls.ordinal()){
drawnLayerSet.add(i); drawnLayerSet.add(i);
} }
} }
@@ -154,9 +154,9 @@ public class FloorRenderer implements Disposable{
continue; continue;
} }
Chunk chunk = cache[worldx][worldy]; int[] chunk = cache[worldx][worldy];
if(chunk.caches[layer.ordinal()] == -1) continue; if(chunk[layer.ordinal()] == -1) continue;
cbatch.drawCache(chunk.caches[layer.ordinal()]); cbatch.drawCache(chunk[layer.ordinal()]);
} }
} }
@@ -165,7 +165,7 @@ public class FloorRenderer implements Disposable{
private void cacheChunk(int cx, int cy){ private void cacheChunk(int cx, int cy){
used.clear(); used.clear();
Chunk chunk = cache[cx][cy]; int[] chunk = cache[cx][cy];
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize && tilex < world.width(); tilex++){ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize && tilex < world.width(); tilex++){
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize && tiley < world.height(); tiley++){ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize && tiley < world.height(); tiley++){
@@ -184,15 +184,15 @@ public class FloorRenderer implements Disposable{
} }
} }
private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){ private void cacheChunkLayer(int cx, int cy, int[] chunk, CacheLayer layer){
Batch current = Core.batch; Batch current = Core.batch;
Core.batch = cbatch; Core.batch = cbatch;
//begin a new cache //begin a new cache
if(chunk.caches[layer.ordinal()] == -1){ if(chunk[layer.ordinal()] == -1){
cbatch.beginCache(); cbatch.beginCache();
}else{ }else{
cbatch.beginCache(chunk.caches[layer.ordinal()]); cbatch.beginCache(chunk[layer.ordinal()]);
} }
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
@@ -218,7 +218,7 @@ public class FloorRenderer implements Disposable{
Core.batch = current; Core.batch = current;
cbatch.reserve(layer.capacity * chunksize * chunksize); cbatch.reserve(layer.capacity * chunksize * chunksize);
chunk.caches[layer.ordinal()] = cbatch.endCache(); chunk[layer.ordinal()] = cbatch.endCache();
} }
public void clearTiles(){ public void clearTiles(){
@@ -227,15 +227,14 @@ public class FloorRenderer implements Disposable{
recacheSet.clear(); recacheSet.clear();
int chunksx = Mathf.ceil((float)(world.width()) / chunksize), int chunksx = Mathf.ceil((float)(world.width()) / chunksize),
chunksy = Mathf.ceil((float)(world.height()) / chunksize); chunksy = Mathf.ceil((float)(world.height()) / chunksize);
cache = new Chunk[chunksx][chunksy]; cache = new int[chunksx][chunksy][CacheLayer.all.length];
cbatch = new MultiCacheBatch(chunksize * chunksize * 8); cbatch = new MultiCacheBatch(chunksize * chunksize * 9);
Time.mark(); Time.mark();
for(int x = 0; x < chunksx; x++){ for(int x = 0; x < chunksx; x++){
for(int y = 0; y < chunksy; y++){ for(int y = 0; y < chunksy; y++){
cache[x][y] = new Chunk(); Arrays.fill(cache[x][y], -1);
Arrays.fill(cache[x][y].caches, -1);
cacheChunk(x, y); cacheChunk(x, y);
} }
@@ -251,13 +250,4 @@ public class FloorRenderer implements Disposable{
cbatch = null; cbatch = null;
} }
} }
private static class Chunk{
/** Maps cache layer ID to cache ID in the batch.
* -1 means that this cache is unoccupied. */
int[] caches = new int[CacheLayer.all.length];
Chunk(){
}
}
} }