Fix rendering bug

This commit is contained in:
Anuken
2017-12-22 00:25:48 -05:00
parent 569de6de8f
commit cbcdc96aaa
3 changed files with 23 additions and 5 deletions

View File

@@ -317,6 +317,10 @@ public class Renderer extends RendererModule{
Draw.color(); Draw.color();
} }
public BlockRenderer getBlocks() {
return blocks;
}
public void addShieldHit(float x, float y){ public void addShieldHit(float x, float y){
shieldHits.addAll(x, y, 0f); shieldHits.addAll(x, y, 0f);
} }

View File

@@ -17,6 +17,7 @@ import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.Blocks;
import io.anuke.mindustry.world.blocks.types.StaticBlock; import io.anuke.mindustry.world.blocks.types.StaticBlock;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Graphics; import io.anuke.ucore.core.Graphics;
@@ -48,6 +49,11 @@ public class BlockRenderer{
public int compareTo(BlockRequest other){ public int compareTo(BlockRequest other){
return layer.compareTo(other.layer); return layer.compareTo(other.layer);
} }
@Override
public String toString(){
return tile.block().name + ":" + layer.toString();
}
} }
/**Process all blocks to draw, simultaneously drawing block shadows and static blocks.*/ /**Process all blocks to draw, simultaneously drawing block shadows and static blocks.*/
@@ -115,16 +121,22 @@ public class BlockRenderer{
iterateidx = 0; iterateidx = 0;
} }
public int getRequests(){
return requestidx;
}
public void drawBlocks(boolean top){ public void drawBlocks(boolean top){
Layer stopAt = top ? Layer.laser : Layer.overlay; Layer stopAt = top ? Layer.laser : Layer.overlay;
for(; iterateidx < requests.size; iterateidx ++){ for(; iterateidx < requestidx; iterateidx ++){
if(iterateidx < requests.size - 1 && requests.get(iterateidx).layer.ordinal() > stopAt.ordinal()){ if(iterateidx < requests.size - 1 && requests.get(iterateidx).layer.ordinal() > stopAt.ordinal()){
break; break;
} }
BlockRequest req = requests.get(iterateidx); BlockRequest req = requests.get(iterateidx);
Block block = req.tile.block(); Block block = req.tile.block();
if(req.layer == Layer.block){ if(req.layer == Layer.block){
block.draw(req.tile); block.draw(req.tile);
}else if(req.layer == block.layer){ }else if(req.layer == block.layer){

View File

@@ -136,11 +136,13 @@ public class HudFragment implements Fragment{
aleft(); aleft();
new label("[green]density: " + Gdx.graphics.getDensity()).left(); new label("[green]density: " + Gdx.graphics.getDensity()).left();
row(); row();
new label(()->"[purple]tiles: " + Vars.control.tileGroup.amount()).left(); new label(() -> "[blue]requests: " + renderer.getBlocks().getRequests()).left();
row(); row();
new label(()->"[purple]enemies: " + Vars.control.enemyGroup.amount()).left(); new label(() -> "[purple]tiles: " + Vars.control.tileGroup.amount()).left();
row(); row();
new label(()->"[orange]noclip: " + Vars.noclip).left(); new label(() -> "[purple]enemies: " + Vars.control.enemyGroup.amount()).left();
row();
new label(() -> "[orange]noclip: " + Vars.noclip).left();
row(); row();
new label("[red]DEBUG MODE").scale(0.5f).left(); new label("[red]DEBUG MODE").scale(0.5f).left();
}}.end(); }}.end();