mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-19 16:57:15 +07:00
Large world size optimizations
This commit is contained in:
parent
9f84b84819
commit
5019f200b7
@ -109,7 +109,7 @@ public class Pathfinder{
|
||||
//add all targets to the frontier
|
||||
for(Tile other : world.indexer.getEnemy(team, BlockFlag.target)){
|
||||
path.weights[other.x][other.y] = 0;
|
||||
path.searches[other.x][other.y] = path.search;
|
||||
path.searches[other.x][other.y] = (short)path.search;
|
||||
path.frontier.addFirst(other);
|
||||
}
|
||||
}
|
||||
@ -117,6 +117,8 @@ public class Pathfinder{
|
||||
|
||||
private void createFor(Team team){
|
||||
PathData path = new PathData();
|
||||
path.weights = new float[world.width()][world.height()];
|
||||
path.searches = new short[world.width()][world.height()];
|
||||
path.search++;
|
||||
path.frontier.ensureCapacity((world.width() + world.height()) * 3);
|
||||
|
||||
@ -130,7 +132,7 @@ public class Pathfinder{
|
||||
&& tile.block().flags.contains(BlockFlag.target)){
|
||||
path.frontier.addFirst(tile);
|
||||
path.weights[x][y] = 0;
|
||||
path.searches[x][y] = path.search;
|
||||
path.searches[x][y] = (short)path.search;
|
||||
}else{
|
||||
path.weights[x][y] = Float.MAX_VALUE;
|
||||
}
|
||||
@ -159,7 +161,7 @@ public class Pathfinder{
|
||||
&& passable(other, team)){
|
||||
path.frontier.addFirst(world.tile(dx, dy));
|
||||
path.weights[dx][dy] = cost + other.cost;
|
||||
path.searches[dx][dy] = path.search;
|
||||
path.searches[dx][dy] = (short)path.search;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -186,14 +188,9 @@ public class Pathfinder{
|
||||
|
||||
class PathData{
|
||||
float[][] weights;
|
||||
int[][] searches;
|
||||
short[][] searches;
|
||||
int search = 0;
|
||||
long lastSearchTime;
|
||||
Queue<Tile> frontier = new Queue<>();
|
||||
|
||||
PathData(){
|
||||
weights = new float[world.width()][world.height()];
|
||||
searches = new int[world.width()][world.height()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class BlockRenderer{
|
||||
private final static int initialRequests = 32 * 32;
|
||||
private final static int expandr = 6;
|
||||
private final static boolean disableShadows = true;
|
||||
|
||||
public final FloorRenderer floor = new FloorRenderer();
|
||||
|
||||
@ -53,6 +54,8 @@ public class BlockRenderer{
|
||||
}
|
||||
|
||||
public void drawShadows(){
|
||||
if(disableShadows) return;
|
||||
|
||||
if(shadows.getWidth() != Core.graphics.getWidth() || shadows.getHeight() != Core.graphics.getHeight()){
|
||||
shadows.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||
}
|
||||
@ -107,7 +110,6 @@ public class BlockRenderer{
|
||||
|
||||
if(tile != null){
|
||||
Block block = tile.block();
|
||||
Team team = tile.getTeam();
|
||||
|
||||
if(!expanded && block != Blocks.air && world.isAccessible(x, y)){
|
||||
tile.block().drawShadow(tile);
|
||||
@ -133,8 +135,6 @@ public class BlockRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
Draw.proj(camera.projection());
|
||||
|
||||
Sort.instance().sort(requests.items, 0, requestidx);
|
||||
|
||||
lastCamX = avgx;
|
||||
|
@ -11,6 +11,7 @@ import io.anuke.arc.graphics.GL20;
|
||||
import io.anuke.arc.graphics.g2d.CacheBatch;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.SpriteBatch;
|
||||
import io.anuke.arc.graphics.g2d.SpriteCache;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Structs;
|
||||
@ -30,6 +31,7 @@ public class FloorRenderer{
|
||||
private CacheBatch cbatch;
|
||||
private IntSet drawnLayerSet = new IntSet();
|
||||
private IntArray drawnLayers = new IntArray();
|
||||
private ObjectSet<CacheLayer> used = new ObjectSet<>();
|
||||
|
||||
public FloorRenderer(){
|
||||
Events.on(WorldLoadEvent.class, event -> clearTiles());
|
||||
@ -142,10 +144,9 @@ public class FloorRenderer{
|
||||
}
|
||||
|
||||
private void cacheChunk(int cx, int cy){
|
||||
used.clear();
|
||||
Chunk chunk = cache[cx][cy];
|
||||
|
||||
ObjectSet<CacheLayer> used = new ObjectSet<>();
|
||||
|
||||
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||
Tile tile = world.tile(tilex, tiley);
|
||||
@ -195,7 +196,8 @@ public class FloorRenderer{
|
||||
int chunksx = Mathf.ceil((float) (world.width()) / chunksize),
|
||||
chunksy = Mathf.ceil((float) (world.height()) / chunksize) ;
|
||||
cache = new Chunk[chunksx][chunksy];
|
||||
cbatch = new CacheBatch(world.width() * world.height());
|
||||
SpriteCache sprites = new SpriteCache(world.width() * world.height(), (world.width() / chunksize) * (world.height() / chunksize) * 2, false);
|
||||
cbatch = new CacheBatch(sprites);
|
||||
|
||||
Time.mark();
|
||||
|
||||
|
@ -141,8 +141,8 @@ public class WorldGenerator{
|
||||
|
||||
int sx = (short)Mathf.range(Short.MAX_VALUE/2);
|
||||
int sy = (short)Mathf.range(Short.MAX_VALUE/2);
|
||||
int width = 380;
|
||||
int height = 380;
|
||||
int width = 512;
|
||||
int height = 512;
|
||||
Array<Point2> spawns = new Array<>();
|
||||
Array<Item> ores = Item.getAllOres();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user