mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
More rendering optimizations
This commit is contained in:
parent
aef3cd14e9
commit
db79d59701
Binary file not shown.
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 253 B |
Binary file not shown.
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 236 B |
Binary file not shown.
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
@ -59,6 +59,7 @@ public class Renderer extends RendererModule{
|
||||
});
|
||||
|
||||
clearColor = Hue.lightness(0.4f);
|
||||
clearColor.a = 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -320,7 +321,6 @@ public class Renderer extends RendererModule{
|
||||
shieldHits.addAll(x, y, 0f);
|
||||
}
|
||||
|
||||
|
||||
void drawOverlay(){
|
||||
|
||||
//draw tutorial placement point
|
||||
|
@ -72,6 +72,16 @@ public class World extends Module{
|
||||
return !wallSolid(x, y-1) || !wallSolid(x, y+1) || !wallSolid(x-1, y) ||!wallSolid(x+1, y);
|
||||
}
|
||||
|
||||
public boolean blends(Block block, int x, int y){
|
||||
return !floorBlends(x, y-1, block) || !floorBlends(x, y+1, block)
|
||||
|| !floorBlends(x-1, y, block) ||!floorBlends(x+1, y, block);
|
||||
}
|
||||
|
||||
public boolean floorBlends(int x, int y, Block block){
|
||||
Tile tile = tile(x, y);
|
||||
return tile == null || tile.floor().id <= block.id;
|
||||
}
|
||||
|
||||
public Map getMap(){
|
||||
return currentMap;
|
||||
}
|
||||
|
@ -148,81 +148,6 @@ public class BlockRenderer{
|
||||
requestidx ++;
|
||||
}
|
||||
|
||||
/*
|
||||
public void drawBlocks(boolean top){
|
||||
int crangex = (int) (camera.viewportWidth / (chunksize * tilesize)) + 1;
|
||||
int crangey = (int) (camera.viewportHeight / (chunksize * tilesize)) + 1;
|
||||
|
||||
int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2)+2;
|
||||
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2)+2;
|
||||
|
||||
boolean noshadows = Settings.getBool("noshadows");
|
||||
|
||||
boolean drawTiles = Settings.getBool("drawblocks");
|
||||
|
||||
if(!drawTiles) return;
|
||||
|
||||
Layer[] layers = Layer.values();
|
||||
|
||||
int start = (top ? 4 : (noshadows ? 1 : 0));
|
||||
int end = (top ? 4 + layers.length-1 : 4);
|
||||
|
||||
//0 = shadows
|
||||
//1 = cache blocks
|
||||
//2 = normal blocks
|
||||
//3+ = layers
|
||||
for(int l = start; l < end; l++){
|
||||
if(l == 0){
|
||||
Graphics.surface(renderer.shadowSurface);
|
||||
}
|
||||
|
||||
Layer layer = l >= 3 ? layers[l - 3] : null;
|
||||
|
||||
boolean expand = layer == Layer.power;
|
||||
int expandr = (expand ? 3 : 0);
|
||||
|
||||
if(l == 1){
|
||||
Graphics.end();
|
||||
drawCache(1, crangex, crangey);
|
||||
Graphics.begin();
|
||||
}else{
|
||||
for(int x = -rangex - expandr; x <= rangex + expandr; x++){
|
||||
for(int y = -rangey - expandr; y <= rangey + expandr; y++){
|
||||
int worldx = Mathf.scl(camera.position.x, tilesize) + x;
|
||||
int worldy = Mathf.scl(camera.position.y, tilesize) + y;
|
||||
boolean expanded = (x < -rangex || x > rangex || y < -rangey || y > rangey);
|
||||
|
||||
if(world.tile(worldx, worldy) != null){
|
||||
Tile tile = world.tile(worldx, worldy);
|
||||
if(l == 0 && !expanded){
|
||||
if(tile.block() != Blocks.air && world.isAccessible(worldx, worldy)){
|
||||
tile.block().drawShadow(tile);
|
||||
}
|
||||
}else if(!(tile.block() instanceof StaticBlock) &&
|
||||
(!expanded || tile.block().expanded)){
|
||||
if(l == 2){
|
||||
tile.block().draw(tile);
|
||||
}else{
|
||||
if(tile.block().layer == layer)
|
||||
tile.block().drawLayer(tile);
|
||||
|
||||
if(tile.block().layer2 == layer)
|
||||
tile.block().drawLayer2(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(l == 0){
|
||||
Draw.color(0, 0, 0, 0.15f);
|
||||
Graphics.flushSurface();
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void drawFloor(){
|
||||
int chunksx = world.width() / chunksize, chunksy = world.height() / chunksize;
|
||||
|
||||
@ -315,7 +240,9 @@ public class BlockRenderer{
|
||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||
Tile tile = world.tile(tilex, tiley);
|
||||
if(floor){
|
||||
tile.floor().draw(tile);
|
||||
if(!(tile.block() instanceof StaticBlock)){
|
||||
tile.floor().draw(tile);
|
||||
}
|
||||
}else if(tile.block() instanceof StaticBlock){
|
||||
tile.block().draw(tile);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Floor extends Block{
|
||||
protected Predicate<Block> blends = block -> block != this;
|
||||
protected boolean blend = true;
|
||||
|
||||
public Floor(String name) {
|
||||
super(name);
|
||||
@ -24,6 +25,7 @@ public class Floor extends Block{
|
||||
|
||||
Draw.rect(variants > 0 ? (name() + MathUtils.random(1, variants)) : name(), tile.worldx(), tile.worldy());
|
||||
|
||||
if(blend)
|
||||
for(int dx = -1; dx <= 1; dx ++){
|
||||
for(int dy = -1; dy <= 1; dy ++){
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user